x86/mm/p2m: Fix locking discipline around p2m updates.
authorTim Deegan <Tim.Deegan@citrix.com>
Thu, 2 Jun 2011 12:16:52 +0000 (13:16 +0100)
committerTim Deegan <Tim.Deegan@citrix.com>
Thu, 2 Jun 2011 12:16:52 +0000 (13:16 +0100)
Direct callers of the p2m setting functions must hold the p2m lock.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
xen/arch/x86/mm/hap/nested_hap.c
xen/arch/x86/mm/p2m.c

index bddc51f2288d8700f8d2f7267ebf03bc683c4126..e23cf33c0f012659f9b6b4bcf7533febfe830f2a 100644 (file)
@@ -103,9 +103,12 @@ nestedhap_fix_p2m(struct p2m_domain *p2m, paddr_t L2_gpa, paddr_t L0_gpa,
     ASSERT(p2m);
     ASSERT(p2m->set_entry);
 
-    rv = p2m->set_entry(p2m, L2_gpa >> PAGE_SHIFT,
+    p2m_lock(p2m);
+    rv = set_p2m_entry(p2m, L2_gpa >> PAGE_SHIFT,
                          page_to_mfn(maddr_to_page(L0_gpa)),
                          0 /*4K*/, p2mt, p2ma);
+    p2m_unlock(p2m);
+
     if (rv == 0) {
         gdprintk(XENLOG_ERR,
                "failed to set entry for 0x%"PRIx64" -> 0x%"PRIx64"\n",
index 6608cad3f78ce016a491c8eef7acf571c6f9e761..460fbab9dcca27493ec6685ba0a29fe7b0ab65ac 100644 (file)
@@ -140,6 +140,8 @@ int set_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
     unsigned int order;
     int rc = 1;
 
+    ASSERT(p2m_locked_by_me(p2m));
+
     while ( todo )
     {
         if ( hap_enabled(d) )