xen: Allow unprivileged Xen domains to create iomap pages
authorAlex Nixon <alex.nixon@citrix.com>
Fri, 19 Feb 2010 18:31:06 +0000 (13:31 -0500)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 7 Jun 2010 18:33:13 +0000 (14:33 -0400)
PV DomU domains are allowed to map hardware MFNs for PCI passthrough,
but are not generally allowed to map raw machine pages.  In particular,
various pieces of code try to map DMI and ACPI tables in the ISA ROM
range.  We disallow _PAGE_IOMAP for those mappings, so that they are
redirected to a set of local zeroed pages we reserve for that purpose.

[ Impact: prevent passthrough of ISA space, as we only allow PCI ]

Signed-off-by: Alex Nixon <alex.nixon@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/enlighten.c
arch/x86/xen/mmu.c

index 65d8d79b46a8467cbc11c4495a160d7b416a0b32..3254e8bc4cd7718507025526da9e65535bc80699 100644 (file)
@@ -1145,6 +1145,10 @@ asmlinkage void __init xen_start_kernel(void)
 
        pgd = (pgd_t *)xen_start_info->pt_base;
 
+       if (!xen_initial_domain())
+               __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
+
+       __supported_pte_mask |= _PAGE_IOMAP;
        /* Don't do the full vcpu_info placement stuff until we have a
           possible map and a non-dummy shared_info. */
        per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
index a4dea9df0cc0ad5f5619d5e5b7c0a872146d8252..a5577f59416a473ccd511970d439469a092b5c16 100644 (file)
@@ -51,6 +51,7 @@
 #include <asm/mmu_context.h>
 #include <asm/setup.h>
 #include <asm/paravirt.h>
+#include <asm/e820.h>
 #include <asm/linkage.h>
 
 #include <asm/xen/hypercall.h>
@@ -381,7 +382,7 @@ static bool xen_page_pinned(void *ptr)
 
 static bool xen_iomap_pte(pte_t pte)
 {
-       return xen_initial_domain() && (pte_flags(pte) & _PAGE_IOMAP);
+       return pte_flags(pte) & _PAGE_IOMAP;
 }
 
 static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval)
@@ -583,10 +584,21 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val);
 
 pte_t xen_make_pte(pteval_t pte)
 {
-       if (unlikely(xen_initial_domain() && (pte & _PAGE_IOMAP)))
+       phys_addr_t addr = (pte & PTE_PFN_MASK);
+
+       /*
+        * Unprivileged domains are allowed to do IOMAPpings for
+        * PCI passthrough, but not map ISA space.  The ISA
+        * mappings are just dummy local mappings to keep other
+        * parts of the kernel happy.
+        */
+       if (unlikely(pte & _PAGE_IOMAP) &&
+           (xen_initial_domain() || addr >= ISA_END_ADDRESS)) {
                pte = iomap_pte(pte);
-       else
+       } else {
+               pte &= ~_PAGE_IOMAP;
                pte = pte_pfn_to_mfn(pte);
+       }
 
        return native_make_pte(pte);
 }