[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 1/4] x86/dom0: prevent access to MMCFG areas for PVH Dom0



They are emulated by Xen, so they must not be mapped into Dom0 p2m.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/dom0_build.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index 3996d9dd12..481a899afe 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -18,6 +18,8 @@
 #include <asm/p2m.h>
 #include <asm/setup.h>
 
+#include "x86_64/mmconfig.h"
+
 static long __initdata dom0_nrpages;
 static long __initdata dom0_min_nrpages;
 static long __initdata dom0_max_nrpages = LONG_MAX;
@@ -452,6 +454,22 @@ int __init dom0_setup_permissions(struct domain *d)
             rc |= rangeset_add_singleton(mmio_ro_ranges, mfn);
     }
 
+    /* For PVH prevent access to the MMCFG areas. */
+    if ( dom0_pvh && pci_mmcfg_config_num )
+    {
+        unsigned int i;
+
+        for ( i = 0; i < pci_mmcfg_config_num; i++ )
+        {
+            paddr_t addr = pci_mmcfg_config[i].address +
+                           (pci_mmcfg_config[i].start_bus_number << 20);
+            size_t size = (pci_mmcfg_config[i].end_bus_number -
+                           pci_mmcfg_config[i].start_bus_number + 1) << 20;
+
+            rc |= iomem_deny_access(d, PFN_DOWN(addr), PFN_UP(addr + size));
+        }
+    }
+
     return rc;
 }
 
-- 
2.11.0 (Apple Git-81)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.