|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 06/23] xen/domctl: Add XEN_DOMCTL_CONFIG_VIOMMU_* and viommu config param
On Mon, Mar 23, 2026 at 6:51 PM Milan Djokic <milan_djokic@xxxxxxxx> wrote:
>
> From: Rahul Singh <rahul.singh@xxxxxxx>
>
> Add new viommu_type field and field values XEN_DOMCTL_CONFIG_VIOMMU_NONE
> XEN_DOMCTL_CONFIG_VIOMMU_SMMUV3 in xen_arch_domainconfig to
> enable/disable vIOMMU support for domains.
>
> Also add viommu="N" parameter to xl domain configuration to enable the
> vIOMMU for the domains. Currently, only the "smmuv3" type is supported
> for ARM.
>
> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
> Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>
> ---
> docs/man/xl.cfg.5.pod.in | 13 +++++++++++++
> tools/golang/xenlight/helpers.gen.go | 2 ++
> tools/golang/xenlight/types.gen.go | 1 +
> tools/include/libxl.h | 5 +++++
> tools/libs/light/libxl_arm.c | 13 +++++++++++++
> tools/libs/light/libxl_types.idl | 6 ++++++
> tools/xl/xl_parse.c | 9 +++++++++
> 7 files changed, 49 insertions(+)
>
> diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
> index 27c455210b..f69cdee55c 100644
> --- a/docs/man/xl.cfg.5.pod.in
> +++ b/docs/man/xl.cfg.5.pod.in
> @@ -3162,6 +3162,19 @@ option.
>
> =back
>
> +=over 4
> +
> +=item B<viommu="N">
> +
> +To enable viommu, user must specify the following option in the VM
> +config file:
> +
> +viommu = "smmuv3"
> +
> +Currently, only the "smmuv3" type is supported for ARM.
> +
> +=back
> +
> =head3 x86
>
> =over 4
> diff --git a/tools/golang/xenlight/helpers.gen.go
> b/tools/golang/xenlight/helpers.gen.go
> index 8909fe8a1b..4f0997f02f 100644
> --- a/tools/golang/xenlight/helpers.gen.go
> +++ b/tools/golang/xenlight/helpers.gen.go
> @@ -1195,6 +1195,7 @@ x.ArchArm.NrSpis = uint32(xc.arch_arm.nr_spis)
> if err := x.ArchArm.ArmSci.fromC(&xc.arch_arm.arm_sci);err != nil {
> return fmt.Errorf("converting field ArchArm.ArmSci: %v", err)
> }
> +x.ArchArm.Viommu = ViommuType(xc.arch_arm.viommu)
> if err := x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err != nil {
> return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
> }
> @@ -1734,6 +1735,7 @@ xc.arch_arm.nr_spis = C.uint32_t(x.ArchArm.NrSpis)
> if err := x.ArchArm.ArmSci.toC(&xc.arch_arm.arm_sci); err != nil {
> return fmt.Errorf("converting field ArchArm.ArmSci: %v", err)
> }
> +xc.arch_arm.viommu = C.libxl_viommu_type(x.ArchArm.Viommu)
> if err := x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err != nil {
> return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err)
> }
> diff --git a/tools/golang/xenlight/types.gen.go
> b/tools/golang/xenlight/types.gen.go
> index ab9d4ca7b4..8a37b52a82 100644
> --- a/tools/golang/xenlight/types.gen.go
> +++ b/tools/golang/xenlight/types.gen.go
> @@ -610,6 +610,7 @@ Vuart VuartType
> SveVl SveType
> NrSpis uint32
> ArmSci ArmSci
> +Viommu ViommuType
> }
> ArchX86 struct {
> MsrRelaxed Defbool
The generated go code doesn't look right - it appears to be missing a
definition for `ViommuType` and the associated constants for the
"viommu_type" Enumeration added to libxl_types.idl. Does the code need
re-generating?
> diff --git a/tools/include/libxl.h b/tools/include/libxl.h
> index bc35e412da..f7d5c77e23 100644
> --- a/tools/include/libxl.h
> +++ b/tools/include/libxl.h
> @@ -318,6 +318,11 @@
> */
> #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SCI 1
>
> +/*
> + * libxl_domain_build_info has the arch_arm.viommu_type field.
> + */
> +#define LIBXL_HAVE_BUILDINFO_ARM_VIOMMU 1
> +
> /*
> * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing
> * 'soft reset' for domains and there is 'soft_reset' shutdown reason
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 7e9f8a1bc3..a248793588 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -247,6 +247,19 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
> }
> LOG(DEBUG, " - SCI type=%u", config->arch.arm_sci_type);
>
> + switch (d_config->b_info.arch_arm.viommu_type) {
> + case LIBXL_VIOMMU_TYPE_NONE:
> + config->arch.viommu_type = XEN_DOMCTL_CONFIG_VIOMMU_NONE;
> + break;
> + case LIBXL_VIOMMU_TYPE_SMMUV3:
> + config->arch.viommu_type = XEN_DOMCTL_CONFIG_VIOMMU_SMMUV3;
> + break;
> + default:
> + LOG(ERROR, "Unknown vIOMMU type %d",
> + d_config->b_info.arch_arm.viommu_type);
> + return ERROR_FAIL;
> + }
> +
> return 0;
> }
>
> diff --git a/tools/libs/light/libxl_types.idl
> b/tools/libs/light/libxl_types.idl
> index d64a573ff3..c7ad0e77b2 100644
> --- a/tools/libs/light/libxl_types.idl
> +++ b/tools/libs/light/libxl_types.idl
> @@ -561,6 +561,11 @@ libxl_arm_sci = Struct("arm_sci", [
> ("type", libxl_arm_sci_type),
> ])
>
> +libxl_viommu_type = Enumeration("viommu_type", [
> + (0, "none"),
> + (1, "smmuv3")
> + ], init_val = "LIBXL_VIOMMU_TYPE_NONE")
> +
> libxl_rdm_reserve = Struct("rdm_reserve", [
> ("strategy", libxl_rdm_reserve_strategy),
> ("policy", libxl_rdm_reserve_policy),
> @@ -736,6 +741,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
> ("sve_vl", libxl_sve_type),
> ("nr_spis", uint32, {'init_val':
> 'LIBXL_NR_SPIS_DEFAULT'}),
> ("arm_sci", libxl_arm_sci),
> + ("viommu_type", libxl_viommu_type),
> ])),
> ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool),
> ])),
> diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
> index 1a2ea8b5d5..dcae8314fe 100644
> --- a/tools/xl/xl_parse.c
> +++ b/tools/xl/xl_parse.c
> @@ -3033,6 +3033,15 @@ skip_usbdev:
> }
> }
>
> + if (!xlu_cfg_get_string (config, "viommu", &buf, 1)) {
> + e = libxl_viommu_type_from_string(buf,
> &b_info->arch_arm.viommu_type);
> + if (e) {
> + fprintf(stderr,
> + "Unknown vIOMMU type \"%s\" specified\n", buf);
> + exit(-ERROR_FAIL);
> + }
> + }
> +
> parse_vkb_list(config, d_config);
>
> d_config->virtios = NULL;
> --
> 2.43.0
-Nick
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |