From: "Jan Beulich" Subject: [PATCH] don't allow Dom0 access to IOMMUs' MMIO pages Date: Thu, 02 Oct 2014 14:34:56 +0100 Message-ID: <542D70A0020000780003BFE3@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartD5E0A190.2__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZgX4-00057N-JB for xen-devel@lists.xenproject.org; Thu, 02 Oct 2014 13:34:58 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Yang Z Zhang , Kevin Tian , Aravind Gopalakrishnan , suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartD5E0A190.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -19,6 +19,7 @@ */ =20 #include +#include #include #include #include @@ -283,6 +284,7 @@ static int amd_iommu_domain_init(struct=20 static void __hwdom_init amd_iommu_hwdom_init(struct domain *d) { unsigned long i;=20 + const struct amd_iommu *iommu; =20 if ( !iommu_passthrough && !need_iommu(d) ) { @@ -304,6 +306,12 @@ static void __hwdom_init amd_iommu_hwdom } } =20 + 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); } =20 --- 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_hwd =20 for_each_drhd_unit ( drhd ) { + if ( iomem_deny_access(d, PFN_DOWN(drhd->address), + PFN_DOWN(drhd->address)) ) + BUG(); iommu_enable_translation(drhd); } } --=__PartD5E0A190.2__= Content-Type: text/plain; name="IOMMU-hide-MMIO-from-Dom0.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="IOMMU-hide-MMIO-from-Dom0.patch" don't allow Dom0 access to IOMMUs' MMIO pages=0A=0AJust like for LAPIC, = IO-APIC, MSI, and HT we shouldn't be granting Dom0=0Aaccess to these. This = implicitly results in these pages also getting=0Amarked reserved in the = machine memory map Dom0 uses to determine the=0Aranges where PCI devices = can have their MMIO ranges placed.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c= =0A+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c=0A@@ -19,6 +19,7 = @@=0A */=0A =0A #include =0A+#include =0A = #include =0A #include =0A #include =0A@@ -283,6 +284,7 @@ static int amd_iommu_domain_init(struct =0A static = void __hwdom_init amd_iommu_hwdom_init(struct domain *d)=0A {=0A = unsigned long i; =0A+ const struct amd_iommu *iommu;=0A =0A if ( = !iommu_passthrough && !need_iommu(d) )=0A {=0A@@ -304,6 +306,12 @@ = static void __hwdom_init amd_iommu_hwdom=0A }=0A }=0A =0A+ = for_each_amd_iommu ( iommu )=0A+ if ( iomem_deny_access(d, = PFN_DOWN(iommu->mmio_base_phys),=0A+ = PFN_DOWN(iommu->mmio_base_phys +=0A+ = IOMMU_MMIO_REGION_LENGTH - 1)) )=0A+ BUG();=0A+=0A = setup_hwdom_pci_devices(d, amd_iommu_setup_hwdom_device);=0A }=0A =0A--- = a/xen/drivers/passthrough/vtd/iommu.c=0A+++ b/xen/drivers/passthrough/vtd/i= ommu.c=0A@@ -23,6 +23,7 @@=0A #include =0A #include =0A #include =0A+#include =0A = #include =0A #include =0A #include =0A@@ -1258,6 +1259,9 @@ static void __hwdom_init intel_iommu_hwd=0A =0A = for_each_drhd_unit ( drhd )=0A {=0A+ if ( iomem_deny_access(= d, PFN_DOWN(drhd->address),=0A+ PFN_DOWN(drhd= ->address)) )=0A+ BUG();=0A iommu_enable_translation(drh= d);=0A }=0A }=0A --=__PartD5E0A190.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartD5E0A190.2__=--