domain: introduce XEN_DOMCTL_CDF_iommu flag
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 17 Sep 2019 14:10:38 +0000 (16:10 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 17 Sep 2019 14:10:38 +0000 (16:10 +0200)
commitc45f59292367ca61059fc1be6f198c0f78f25b8b
tree6be751dd341813f29bc56e42bbc21a8dd32cc98a
parentb0000b128adb07f4107c6e324d32ab025a73a6c8
domain: introduce XEN_DOMCTL_CDF_iommu flag

This patch introduces a common domain creation flag to determine whether
the domain is permitted to make use of the IOMMU. Currently the flag is
always set for both dom0 and any domU created by libxl if the IOMMU is
globally enabled (i.e. iommu_enabled == 1). sanitise_domain_config() is
modified to reject the flag if !iommu_enabled.

A new helper function, is_iommu_enabled(), is added to test the flag and
iommu_domain_init() will return immediately if !is_iommu_enabled(). This is
slightly different to the previous behaviour based on !iommu_enabled where
the call to arch_iommu_domain_init() was made regardless, however it appears
that this call was only necessary to initialize the dt_devices list for ARM
such that iommu_release_dt_devices() can be called unconditionally by
domain_relinquish_resources(). Adding a simple check of is_iommu_enabled()
into iommu_release_dt_devices() keeps this unconditional call working.

No functional change should be observed with this patch applied.

Subsequent patches will allow the toolstack to control whether use of the
IOMMU is enabled for a domain.

NOTE: The introduction of the is_iommu_enabled() helper function might
      seem excessive but its use is expected to increase with subsequent
      patches. Also, having iommu_domain_init() bail before calling
      arch_iommu_domain_init() is not strictly necessary, but I think the
      consequent addition of the call to is_iommu_enabled() in
      iommu_release_dt_devices() makes the code clearer.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: "Roger Pau Monné" <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
tools/ocaml/libs/xc/xenctrl.ml
tools/ocaml/libs/xc/xenctrl.mli
xen/arch/arm/domain.c
xen/arch/arm/setup.c
xen/arch/x86/setup.c
xen/common/domain.c
xen/common/domctl.c
xen/drivers/passthrough/device_tree.c
xen/drivers/passthrough/iommu.c
xen/include/public/domctl.h
xen/include/xen/sched.h