]> xenbits.xensource.com Git - people/liuw/xen.git/commit
remove late (on-demand) construction of IOMMU page tables
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 25 Sep 2019 14:12:02 +0000 (16:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Sep 2019 14:12:02 +0000 (16:12 +0200)
commitf89f555827a6634582ff78ef26e7167b2bddbbfa
treee289060710e89732ed3f9865d0078205d5fe2700
parent322609f9c9809ddc106362c24683c939524510d8
remove late (on-demand) construction of IOMMU page tables

Now that there is a per-domain IOMMU-enable flag, which should be set if
any device is going to be passed through, stop deferring page table
construction until the assignment is done. Also don't tear down the tables
again when the last device is de-assigned; defer that task until domain
destruction.

This allows the has_iommu_pt() helper and iommu_status enumeration to be
removed. Calls to has_iommu_pt() are simply replaced by calls to
is_iommu_enabled(). Remaining open-coded tests of iommu_hap_pt_share can
also be replaced by calls to iommu_use_hap_pt().
The arch_iommu_populate_page_table() and iommu_construct() functions become
redundant, as does the 'strict mode' dom0 page_list mapping code in
iommu_hwdom_init(), and iommu_teardown() can be made static is its only
remaining caller, iommu_domain_destroy(), is within the same source
module.

All in all, about 220 lines of code are removed from the hypervisor (at
the expense of some additions in the toolstack).

NOTE: This patch will cause a small amount of extra resource to be used
      to accommodate IOMMU page tables that may never be used, since the
      per-domain IOMMU-enable flag is currently set to the value of the
      global iommu_enable flag. A subsequent patch will add an option to
      the toolstack to allow it to be turned off if there is no intention
      to assign passthrough hardware to the domain.
      To account for the extra resource, 'iommu_memkb' has been added to
      domain_build_info. This patch sets it to a value calculated based
      on the domain's maximum memory when the P2M sharing is either not
      supported or globally disabled, or zero otherwise. However, when
      the toolstack option mentioned above is added, it will also be zero
      if the per-domain IOMMU-enable flag is turned off.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Alexandru Isaila <aisaila@bitdefender.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Wei Liu <wl@xen.org>
24 files changed:
tools/libxl/libxl.h
tools/libxl/libxl_mem.c
tools/libxl/libxl_types.idl
tools/libxl/libxl_utils.c
tools/libxl/libxl_utils.h
tools/xl/xl_parse.c
xen/arch/arm/p2m.c
xen/arch/x86/dom0_build.c
xen/arch/x86/hvm/mtrr.c
xen/arch/x86/mm/mem_sharing.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/vtd/iommu.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-arm/iommu.h
xen/include/asm-x86/iommu.h
xen/include/xen/iommu.h
xen/include/xen/sched.h