xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mem_sharing_nominate_page: p2mt should never change before p2m_change_type()
@ 2013-08-04 13:31 Nai Xia
  0 siblings, 0 replies; only message in thread
From: Nai Xia @ 2013-08-04 13:31 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan

The p2mt change check for p2m_change_type() was first introduced when this code path was not protected by p2m_lock().
Now this code path is protected by p2m_lock. So p2mt should never change before p2m_change_type().

---
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 0364bb0..b3940cb 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -900,20 +900,8 @@ int mem_sharing_nominate_page(struct domain *d,
         goto out;
     }

-    /* Change the p2m type */
-    if ( p2m_change_type(d, gfn, p2mt, p2m_ram_shared) != p2mt )
-    {
-        /* This is unlikely, as the type must have changed since we've checked
-         * it a few lines above.
-         * The mfn needs to revert back to rw type. This should never fail,
-         * since no-one knew that the mfn was temporarily sharable */
-        mem_sharing_gfn_destroy(page, d, gfn_info);
-        xfree(page->sharing);
-        page->sharing = NULL;
-        /* NOTE: We haven't yet added this to the audit list. */
-        BUG_ON(page_make_private(d, page) != 0);
-        goto out;
-    }
+    /* Change the p2m type, should never fail with p2m locked. */
+    BUG_ON(p2m_change_type(d, gfn, p2mt, p2m_ram_shared) != p2mt);

     /* Account for this page. */
     atomic_inc(&nr_shared_mfns);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-08-04 13:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-04 13:31 [PATCH] mem_sharing_nominate_page: p2mt should never change before p2m_change_type() Nai Xia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).