Skip to content

Commit

Permalink
x86, xen: Disable highmem PTE allocation even when CONFIG_HIGHPTE=y
Browse files Browse the repository at this point in the history
There's a path in the pagefault code where the kernel deliberately
breaks its own locking rules by kmapping a high pte page without
holding the pagetable lock (in at least page_check_address). This
breaks Xen's ability to track the pinned/unpinned state of the
page. There does not appear to be a viable workaround for this
behaviour so simply disable HIGHPTE for all Xen guests.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
LKML-Reference: <1267204562-11844-1-git-send-email-ian.campbell@citrix.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Pasi Kärkkäinen <pasik@iki.fi>
Cc: <stable@kernel.org> # .32.x: 1431559: Allow highmem user page tables to be disabled at boot time
Cc: <stable@kernel.org> # .32.x
Cc: <xen-devel@lists.xensource.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
Ian Campbell authored and H. Peter Anvin committed Feb 27, 2010
1 parent c1fd1b4 commit 817a824
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <asm/traps.h>
#include <asm/setup.h>
#include <asm/desc.h>
#include <asm/pgalloc.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
#include <asm/reboot.h>
Expand Down Expand Up @@ -1094,6 +1095,12 @@ asmlinkage void __init xen_start_kernel(void)

__supported_pte_mask |= _PAGE_IOMAP;

/*
* Prevent page tables from being allocated in highmem, even
* if CONFIG_HIGHPTE is enabled.
*/
__userpte_alloc_gfp &= ~__GFP_HIGHMEM;

/* Work out if we support NX */
x86_configure_nx();

Expand Down
11 changes: 6 additions & 5 deletions arch/x86/xen/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,14 +1432,15 @@ static void *xen_kmap_atomic_pte(struct page *page, enum km_type type)
{
pgprot_t prot = PAGE_KERNEL;

/*
* We disable highmem allocations for page tables so we should never
* see any calls to kmap_atomic_pte on a highmem page.
*/
BUG_ON(PageHighMem(page));

if (PagePinned(page))
prot = PAGE_KERNEL_RO;

if (0 && PageHighMem(page))
printk("mapping highpte %lx type %d prot %s\n",
page_to_pfn(page), type,
(unsigned long)pgprot_val(prot) & _PAGE_RW ? "WRITE" : "READ");

return kmap_atomic_prot(page, type, prot);
}
#endif
Expand Down

0 comments on commit 817a824

Please sign in to comment.