x86/p2m: also clear defer_nested_flush on error
authorJan Beulich <JBeulich@suse.com>
Tue, 15 Apr 2014 14:10:07 +0000 (15:10 +0100)
committerTim Deegan <tim@xen.org>
Thu, 24 Apr 2014 11:33:17 +0000 (12:33 +0100)
While presumably benign (domain creation ought to fail when P2M setup
fails) let's be on the safe side and clear the flag as intended. And
actually, the code can be streamlined quite a bit by recognizing that
the only difference between the success and error cases is the message
printed in each case. With that, a stray spin_unlock() also goes away.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Christoph Egger <chegger@amazon.de>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/p2m.c

index 712c134eee7f45d0adf83d0a3102a1bc5c59ad8e..1d0528b6cd7516a6039d5339d1cf75da0dae0572 100644 (file)
@@ -435,18 +435,12 @@ int p2m_alloc_table(struct p2m_domain *p2m)
     p2m->defer_nested_flush = 1;
     rc = p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K,
                        p2m_invalid, p2m->default_access);
-    if ( rc )
-        goto error;
     p2m->defer_nested_flush = 0;
-
-    P2M_PRINTK("p2m table initialised for slot zero\n");
-    p2m_unlock(p2m);
-    return 0;
-
-    spin_unlock(&p2m->domain->page_alloc_lock);
- error:
-    P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", rc);
     p2m_unlock(p2m);
+    if ( !rc )
+        P2M_PRINTK("p2m table initialised for slot zero\n");
+    else
+        P2M_PRINTK("failed to initialise p2m table for slot zero (%d)\n", rc);
     return rc;
 }