From: Jan Beulich Date: Mon, 6 Oct 2014 09:15:01 +0000 (+0200) Subject: don't allow Dom0 access to IOMMUs' MMIO pages X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~4270 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fdf30377fbc4fa6798bfda7d69e5d448c2b8e834;p=xen.git don't allow Dom0 access to IOMMUs' MMIO pages Just like for LAPIC, IO-APIC, MSI, and HT we shouldn't be granting Dom0 access to these. This implicitly results in these pages also getting marked reserved in the machine memory map Dom0 uses to determine the ranges where PCI devices can have their MMIO ranges placed. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: Kevin Tian --- diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index 0b301b3556..e83bb35e48 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -283,6 +284,7 @@ static int amd_iommu_domain_init(struct domain *d) static void __hwdom_init amd_iommu_hwdom_init(struct domain *d) { unsigned long i; + const struct amd_iommu *iommu; if ( !iommu_passthrough && !need_iommu(d) ) { @@ -304,6 +306,12 @@ static void __hwdom_init amd_iommu_hwdom_init(struct domain *d) } } + for_each_amd_iommu ( iommu ) + if ( iomem_deny_access(d, PFN_DOWN(iommu->mmio_base_phys), + PFN_DOWN(iommu->mmio_base_phys + + IOMMU_MMIO_REGION_LENGTH - 1)) ) + BUG(); + setup_hwdom_pci_devices(d, amd_iommu_setup_hwdom_device); } diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 63038d9394..98fb2950c6 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1258,6 +1259,9 @@ static void __hwdom_init intel_iommu_hwdom_init(struct domain *d) for_each_drhd_unit ( drhd ) { + if ( iomem_deny_access(d, PFN_DOWN(drhd->address), + PFN_DOWN(drhd->address)) ) + BUG(); iommu_enable_translation(drhd); } }