]> xenbits.xensource.com Git - xen.git/commit
mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()
authorPaul Durrant <paul.durrant@citrix.com>
Fri, 5 Oct 2018 14:47:10 +0000 (16:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Oct 2018 14:47:10 +0000 (16:47 +0200)
commit91d4eca7add6a7a114bc05cc6d38223a0c0b5575
treec880442ceab893ef46744b44e4fce24483392cf9
parent2916951c1bb943e79bf965cde66a78b0e841455b
mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()

The name 'need_iommu()' is a little confusing as it suggests a domain needs
to use the IOMMU but something might not be set up yet, when in fact it
represents a tri-state value (not a boolean as might be expected) where
-1 means 'IOMMU mappings being set up' and 1 means 'IOMMU mappings have
been fully set up'.

Two different meanings are also inferred from the macro it in various
places in the code:

- Some callers want to test whether a domain has IOMMU mappings at all
- Some callers want to test whether they need to synchronize the domain's
  P2M and IOMMU mappings

This patch replaces the 'need_iommu' tri-state value with a defined
enumeration and adds a boolean flag 'need_sync' to separate these meanings,
and places both of these in struct domain_iommu, rather than directly in
struct domain.
This patch also creates two new boolean macros:

- 'has_iommu_pt()' evaluates to true if a domain has IOMMU mappings, even
  if they are still under construction.
- 'need_iommu_pt_sync()' evaluates to true if a domain requires explicit
  synchronization of the P2M and IOMMU mappings.

All callers of need_iommu() are then modified to use the macro appropriate
to what they are trying to test, except for the instance in
xen/drivers/passthrough/pci.c:assign_device() which has simply been
removed since it appears to be unnecessary.

NOTE: There are some callers of need_iommu() that strictly operate on
      the hardware domain. In some of these case a more global flag is
      used instead.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
21 files changed:
xen/arch/arm/p2m.c
xen/arch/x86/hvm/mtrr.c
xen/arch/x86/mm.c
xen/arch/x86/mm/mem_sharing.c
xen/arch/x86/mm/p2m-ept.c
xen/arch/x86/mm/p2m-pt.c
xen/arch/x86/mm/p2m.c
xen/arch/x86/mm/paging.c
xen/arch/x86/x86_64/mm.c
xen/common/memory.c
xen/common/vm_event.c
xen/drivers/passthrough/device_tree.c
xen/drivers/passthrough/iommu.c
xen/drivers/passthrough/pci.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-arm/grant_table.h
xen/include/asm-arm/iommu.h
xen/include/asm-x86/grant_table.h
xen/include/asm-x86/iommu.h
xen/include/xen/iommu.h
xen/include/xen/sched.h