xen/p2m: Allocate p2m tracking pages on override
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 24 Mar 2011 12:10:07 +0000 (08:10 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 24 Mar 2011 14:36:01 +0000 (10:36 -0400)
It is possible to add a p2m override on pages that are currently mapped
to INVALID_P2M_ENTRY; in particular, this will happen when using
ballooned pages in gntdev. This means that set_phys_to_machine must be
used instead of __set_phys_to_machine.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/p2m.c

index 215a3ce6106820d029c38d0216c7ea4384f20a0b..2a44edd606e5f52c430509372cd44eddb6838a17 100644 (file)
@@ -671,7 +671,9 @@ int m2p_add_override(unsigned long mfn, struct page *page)
        page->private = mfn;
        page->index = pfn_to_mfn(pfn);
 
-       __set_phys_to_machine(pfn, FOREIGN_FRAME(mfn));
+       if (unlikely(!set_phys_to_machine(pfn, FOREIGN_FRAME(mfn))))
+               return -ENOMEM;
+
        if (!PageHighMem(page))
                /* Just zap old mapping for now */
                pte_clear(&init_mm, address, ptep);
@@ -709,7 +711,7 @@ int m2p_remove_override(struct page *page)
        spin_lock_irqsave(&m2p_override_lock, flags);
        list_del(&page->lru);
        spin_unlock_irqrestore(&m2p_override_lock, flags);
-       __set_phys_to_machine(pfn, page->index);
+       set_phys_to_machine(pfn, page->index);
 
        if (!PageHighMem(page))
                set_pte_at(&init_mm, address, ptep,