xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V1] Avoid premature update of M2P in set_typed_p2m_entry
@ 2014-06-06 21:45 Mukesh Rathor
  2014-06-10  8:47 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Mukesh Rathor @ 2014-06-06 21:45 UTC (permalink / raw)
  To: xen-devel; +Cc: tim, JBeulich

Update M2P for ram type after p2m_set_entry call has been made, and it
succeeds.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
---
 xen/arch/x86/mm/p2m.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index b50747a..bd2e03f 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -818,20 +818,20 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
         domain_crash(d);
         return -ENOENT;
     }
-    else if ( p2m_is_ram(ot) )
-    {
-        ASSERT(mfn_valid(omfn));
-        set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
-    }
 
     P2M_DEBUG("set %d %lx %lx\n", gfn_p2mt, gfn, mfn_x(mfn));
     rc = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, gfn_p2mt,
                        p2m->default_access);
-    gfn_unlock(p2m, gfn, 0);
-    if ( rc )
+    if ( unlikely(rc) )
         gdprintk(XENLOG_ERR,
                  "p2m_set_entry failed! mfn=%08lx rc:%d\n",
                  mfn_x(get_gfn_query_unlocked(p2m->domain, gfn, &ot)), rc);
+    else if ( p2m_is_ram(ot) )
+    {
+        ASSERT(mfn_valid(omfn));
+        set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY);
+    }
+    gfn_unlock(p2m, gfn, 0);
     return rc;
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-10  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-06 21:45 [PATCH V1] Avoid premature update of M2P in set_typed_p2m_entry Mukesh Rathor
2014-06-10  8:47 ` Jan Beulich

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).