]> xenbits.xensource.com Git - xen.git/commit
x86/iommu: account for IOMEM caps when populating dom0 IOMMU page-tables
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 20 Mar 2025 11:49:30 +0000 (12:49 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 20 Mar 2025 11:49:30 +0000 (12:49 +0100)
commita1a5bd40b5e1238fe51df79419471fb6b160cc5b
tree2bcb73a3085079ba4f00dd0f3ac80932adda21cb
parent1d8d5753b75c07a527abcfe3665f54582e6c2bd0
x86/iommu: account for IOMEM caps when populating dom0 IOMMU page-tables

The current code in arch_iommu_hwdom_init() kind of open-codes the same
MMIO permission ranges that are added to the hardware domain ->iomem_caps.
Avoid this duplication and use ->iomem_caps in arch_iommu_hwdom_init() to
filter which memory regions should be added to the dom0 IOMMU page-tables.

Note the IO-APIC and MCFG page(s) must be set as not accessible for a PVH
dom0, otherwise the internal Xen emulation for those ranges won't work.
This requires adjustments in dom0_setup_permissions().

The call to pvh_setup_mmcfg() in dom0_construct_pvh() must now strictly be
done ahead of setting up dom0 permissions, so take the opportunity to also
put it inside the existing is_hardware_domain() region.

Also the special casing of E820_UNUSABLE regions no longer needs to be done
in arch_iommu_hwdom_init(), as those regions are already blocked in
->iomem_caps and thus would be removed from the rangeset as part of
->iomem_caps processing in arch_iommu_hwdom_init().  The E820_UNUSABLE
regions below 1Mb are not removed from ->iomem_caps, that's a slight
difference for the IOMMU created page-tables, but the aim is to allow
access to the same memory either from the CPU or the IOMMU page-tables.

Since ->iomem_caps already takes into account the domain max paddr, there's
no need to remove any regions past the last address addressable by the
domain, as applying ->iomem_caps would have already taken care of that.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 62f3fc5296c452285e81adb50976bde2d68d3181
master date: 2025-03-05 10:26:46 +0100
xen/arch/x86/dom0_build.c
xen/arch/x86/hvm/dom0_build.c
xen/arch/x86/hvm/io.c
xen/arch/x86/include/asm/hvm/io.h
xen/drivers/passthrough/x86/iommu.c