]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: fix invalid unlinking of nested p2m tables
authorMatthew Daley <mattjd@gmail.com>
Thu, 28 Feb 2013 05:16:04 +0000 (18:16 +1300)
committerTim Deegan <tim@xen.org>
Thu, 28 Feb 2013 10:56:32 +0000 (10:56 +0000)
Commit 90805dc (c/s 26387:4056e5a3d815) ("EPT: Make ept data stucture or
operations neutral") makes nested p2m tables be unlinked from the host
p2m table before their destruction (in p2m_teardown_nestedp2m).
However, by this time the host p2m table has already been torn down,
leading to a possible race condition where another allocation between
the two kinds of table being torn down can lead to a linked list
assertion with debug=y builds or memory corruption on debug=n ones.

Fix by swapping the order the two kinds of table are torn down in. While
at it, remove the condition in p2m_final_teardown, as it is already
checked identically in p2m_teardown_hostp2m itself.

Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/p2m.c

index b70716d14057d4f3edf3cfb90124ac3bee5df330..4837de3e1a951dc33e038e508f1fcdc8d522939a 100644 (file)
@@ -488,15 +488,13 @@ void p2m_teardown(struct p2m_domain *p2m)
 
 void p2m_final_teardown(struct domain *d)
 {
-    /* Iterate over all p2m tables per domain */
-    struct p2m_domain *p2m = p2m_get_hostp2m(d);
-    if ( p2m )
-        p2m_teardown_hostp2m(d);
-
     /* We must teardown unconditionally because
      * we initialise them unconditionally.
      */
     p2m_teardown_nestedp2m(d);
+
+    /* Iterate over all p2m tables per domain */
+    p2m_teardown_hostp2m(d);
 }