diff options
author | Alex Nixon <alex.nixon@citrix.com> | 2010-02-19 13:31:06 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2010-06-07 14:33:13 -0400 |
commit | 7347b4082e55ac4a673f06a0a0ce25c37273c9ec (patch) | |
tree | b39ef6d8aaf3081b97a12fa06ca86ffb668d1b68 /arch/x86/xen | |
parent | c0011dbfce69467b23b08fb4a64c39a409a935fb (diff) |
xen: Allow unprivileged Xen domains to create iomap pages
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>
Diffstat (limited to 'arch/x86/xen')
-rw-r--r-- | arch/x86/xen/enlighten.c | 4 | ||||
-rw-r--r-- | arch/x86/xen/mmu.c | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 65d8d79b46a8..3254e8bc4cd7 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -1145,6 +1145,10 @@ asmlinkage void __init xen_start_kernel(void) | |||
1145 | 1145 | ||
1146 | pgd = (pgd_t *)xen_start_info->pt_base; | 1146 | pgd = (pgd_t *)xen_start_info->pt_base; |
1147 | 1147 | ||
1148 | if (!xen_initial_domain()) | ||
1149 | __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); | ||
1150 | |||
1151 | __supported_pte_mask |= _PAGE_IOMAP; | ||
1148 | /* Don't do the full vcpu_info placement stuff until we have a | 1152 | /* Don't do the full vcpu_info placement stuff until we have a |
1149 | possible map and a non-dummy shared_info. */ | 1153 | possible map and a non-dummy shared_info. */ |
1150 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; | 1154 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; |
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index a4dea9df0cc0..a5577f59416a 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <asm/mmu_context.h> | 51 | #include <asm/mmu_context.h> |
52 | #include <asm/setup.h> | 52 | #include <asm/setup.h> |
53 | #include <asm/paravirt.h> | 53 | #include <asm/paravirt.h> |
54 | #include <asm/e820.h> | ||
54 | #include <asm/linkage.h> | 55 | #include <asm/linkage.h> |
55 | 56 | ||
56 | #include <asm/xen/hypercall.h> | 57 | #include <asm/xen/hypercall.h> |
@@ -381,7 +382,7 @@ static bool xen_page_pinned(void *ptr) | |||
381 | 382 | ||
382 | static bool xen_iomap_pte(pte_t pte) | 383 | static bool xen_iomap_pte(pte_t pte) |
383 | { | 384 | { |
384 | return xen_initial_domain() && (pte_flags(pte) & _PAGE_IOMAP); | 385 | return pte_flags(pte) & _PAGE_IOMAP; |
385 | } | 386 | } |
386 | 387 | ||
387 | static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval) | 388 | static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval) |
@@ -583,10 +584,21 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val); | |||
583 | 584 | ||
584 | pte_t xen_make_pte(pteval_t pte) | 585 | pte_t xen_make_pte(pteval_t pte) |
585 | { | 586 | { |
586 | if (unlikely(xen_initial_domain() && (pte & _PAGE_IOMAP))) | 587 | phys_addr_t addr = (pte & PTE_PFN_MASK); |
588 | |||
589 | /* | ||
590 | * Unprivileged domains are allowed to do IOMAPpings for | ||
591 | * PCI passthrough, but not map ISA space. The ISA | ||
592 | * mappings are just dummy local mappings to keep other | ||
593 | * parts of the kernel happy. | ||
594 | */ | ||
595 | if (unlikely(pte & _PAGE_IOMAP) && | ||
596 | (xen_initial_domain() || addr >= ISA_END_ADDRESS)) { | ||
587 | pte = iomap_pte(pte); | 597 | pte = iomap_pte(pte); |
588 | else | 598 | } else { |
599 | pte &= ~_PAGE_IOMAP; | ||
589 | pte = pte_pfn_to_mfn(pte); | 600 | pte = pte_pfn_to_mfn(pte); |
601 | } | ||
590 | 602 | ||
591 | return native_make_pte(pte); | 603 | return native_make_pte(pte); |
592 | } | 604 | } |