]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: fix EPT PoD locking to match the normal p2m case.
authorTim Deegan <Tim.Deegan@citrix.com>
Thu, 13 Jan 2011 15:46:13 +0000 (15:46 +0000)
committerTim Deegan <Tim.Deegan@citrix.com>
Thu, 13 Jan 2011 15:46:13 +0000 (15:46 +0000)
This recursive-locking bug was fixed in the main p2m code in
20269:fd3d5d66c446 (in October 2009) but has lurked unseen in
the EPT side since then.  Copy the fix across.

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

index 7eebb3253ecdea4d78739a5472cf5ced09917b42..fe1d5cd1682818e8e867d0aa38554bcc9948eea8 100644 (file)
@@ -45,19 +45,26 @@ static int ept_pod_check_and_populate(struct p2m_domain *p2m, unsigned long gfn,
                                       ept_entry_t *entry, int order,
                                       p2m_query_t q)
 {
+    /* Only take the lock if we don't already have it.  Otherwise it
+     * wouldn't be safe to do p2m lookups with the p2m lock held */
+    int do_locking = !p2m_locked_by_me(p2m);
     int r;
-    p2m_lock(p2m);
+
+    if ( do_locking )
+        p2m_lock(p2m);
 
     /* Check to make sure this is still PoD */
     if ( entry->sa_p2mt != p2m_populate_on_demand )
     {
-        p2m_unlock(p2m);
+        if ( do_locking )
+            p2m_unlock(p2m);
         return 0;
     }
 
     r = p2m_pod_demand_populate(p2m, gfn, order, q);
 
-    p2m_unlock(p2m);
+    if ( do_locking )
+        p2m_unlock(p2m);
 
     return r;
 }