xen-devel
[Xen-devel] [PATCH 02/10] xen: Allow unprivileged Xen domains to create
To: |
Ingo Molnar <mingo@xxxxxxx> |
Subject: |
[Xen-devel] [PATCH 02/10] xen: Allow unprivileged Xen domains to create iomap pages |
From: |
Jeremy Fitzhardinge <jeremy@xxxxxxxx> |
Date: |
Wed, 27 May 2009 00:24:34 -0700 |
Cc: |
Chris Wright <chrisw@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Matthew Wilcox <matthew@xxxxxx>, Ky Srinivasan <ksrinivasan@xxxxxxxxxx>, kurt.hackel@xxxxxxxxxx, the arch/x86 maintainers <x86@xxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Alex Nixon <alex.nixon@xxxxxxxxxx>, Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>, Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>, Jens Axboe <jens.axboe@xxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Greg KH <gregkh@xxxxxxx> |
Delivery-date: |
Wed, 27 May 2009 00:35:48 -0700 |
Envelope-to: |
www-data@xxxxxxxxxxxxxxxxxxx |
In-reply-to: |
<1243409082-21349-1-git-send-email-jeremy@xxxxxxxx> |
List-help: |
<mailto:xen-devel-request@lists.xensource.com?subject=help> |
List-id: |
Xen developer discussion <xen-devel.lists.xensource.com> |
List-post: |
<mailto:xen-devel@lists.xensource.com> |
List-subscribe: |
<http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
List-unsubscribe: |
<http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
References: |
<1243409082-21349-1-git-send-email-jeremy@xxxxxxxx> |
Sender: |
xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
From: Alex Nixon <alex.nixon@xxxxxxxxxx>
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@xxxxxxxxxx>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
arch/x86/xen/enlighten.c | 6 +++---
arch/x86/xen/mmu.c | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 12e4d9c..adb4fe0 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1051,11 +1051,11 @@ asmlinkage void __init xen_start_kernel(void)
/* Prevent unwanted bits from being set in PTEs. */
__supported_pte_mask &= ~_PAGE_GLOBAL;
- if (xen_initial_domain())
- __supported_pte_mask |= _PAGE_IOMAP;
- else
+ if (!xen_initial_domain())
__supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
+ __supported_pte_mask |= _PAGE_IOMAP;
+
#ifdef CONFIG_X86_64
/* Work out if we support NX */
check_efer();
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 331e52d..370e1b8 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -49,6 +49,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>
@@ -378,7 +379,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)
@@ -580,10 +581,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);
}
--
1.6.0.6
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [GIT PULL REPOST] xen/dom0/pci - Xen dom0 PCI access, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 01/10] xen: Don't disable the I/O space, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 03/10] Xen: Rename the balloon lock, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 02/10] xen: Allow unprivileged Xen domains to create iomap pages,
Jeremy Fitzhardinge <=
- [Xen-devel] [PATCH 04/10] xen: Add xen_create_contiguous_region, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 10/10] xen: define BIOVEC_PHYS_MERGEABLE(), Jeremy Fitzhardinge
- [Xen-devel] [PATCH 09/10] xen/pci: clean up Kconfig a bit, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 08/10] x86/pci: make sure _PAGE_IOMAP it set on pci mappings, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 05/10] x86/PCI: Clean up pci_cache_line_size, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 06/10] x86/PCI: Enable scanning of all pci functions, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 07/10] Xen/x86/PCI: Add support for the Xen PCI subsystem, Jeremy Fitzhardinge
|
|
|