[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/PV: fold exit paths of ptwr_do_page_fault()



One less aspect to keep an eye on for things to stay in sync.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
FAOD I did consider (and even try) reducing the scope of ptwr_ctxt at
the same occasion - this results in worse code with gcc 10 at least, as
the compiler then indeed defers populating of the struct, and hence
needs to retain the respective function arguments across prior calls.

--- a/xen/arch/x86/pv/ro-page-fault.c
+++ b/xen/arch/x86/pv/ro-page-fault.c
@@ -262,29 +262,23 @@ static int ptwr_do_page_fault(struct x86
         .pte = pte,
     };
     struct page_info *page;
-    int rc;
+    int rc = X86EMUL_UNHANDLEABLE;
 
     page = get_page_from_mfn(l1e_get_mfn(pte), current->domain);
     if ( !page )
         return X86EMUL_UNHANDLEABLE;
 
-    if ( !page_lock(page) )
+    if ( page_lock(page) )
     {
-        put_page(page);
-        return X86EMUL_UNHANDLEABLE;
-    }
+        if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l1_page_table )
+        {
+            ctxt->data = &ptwr_ctxt;
+            rc = x86_emulate(ctxt, &ptwr_emulate_ops);
+        }
 
-    if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table )
-    {
         page_unlock(page);
-        put_page(page);
-        return X86EMUL_UNHANDLEABLE;
     }
 
-    ctxt->data = &ptwr_ctxt;
-    rc = x86_emulate(ctxt, &ptwr_emulate_ops);
-
-    page_unlock(page);
     put_page(page);
 
     return rc;



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.