]> Pileus Git - ~andy/linux/commitdiff
xen/mm: zero PTEs for non-present MFNs in the initial page table
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 9 Jul 2012 10:39:06 +0000 (11:39 +0100)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 19 Jul 2012 19:51:44 +0000 (15:51 -0400)
When constructing the initial page tables, if the MFN for a usable PFN
is missing in the p2m then that frame is initially ballooned out.  In
this case, zero the PTE (as in decrease_reservation() in
drivers/xen/balloon.c).

This is obviously safe instead of having an valid PTE with an MFN of
INVALID_P2M_ENTRY (~0).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/mmu.c

index 3f1783a79a3caad992448baec69b095869934725..27336dfcda8ef41e2d8874f20634d105a4084c97 100644 (file)
@@ -1432,6 +1432,10 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)
  * Init-time set_pte while constructing initial pagetables, which
  * doesn't allow RO page table pages to be remapped RW.
  *
+ * If there is no MFN for this PFN then this page is initially
+ * ballooned out so clear the PTE (as in decrease_reservation() in
+ * drivers/xen/balloon.c).
+ *
  * Many of these PTE updates are done on unpinned and writable pages
  * and doing a hypercall for these is unnecessary and expensive.  At
  * this point it is not possible to tell if a page is pinned or not,
@@ -1440,7 +1444,10 @@ static pte_t __init mask_rw_pte(pte_t *ptep, pte_t pte)
  */
 static void __init xen_set_pte_init(pte_t *ptep, pte_t pte)
 {
-       pte = mask_rw_pte(ptep, pte);
+       if (pte_mfn(pte) != INVALID_P2M_ENTRY)
+               pte = mask_rw_pte(ptep, pte);
+       else
+               pte = __pte_ma(0);
 
        native_set_pte(ptep, pte);
 }