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

[Xen-changelog] [xen master] x86: miscellaneous mm.c cleanup



commit f2ddd529337792bcb61fad259da8982be570df4d
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu May 2 17:05:05 2013 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu May 2 17:05:05 2013 +0200

    x86: miscellaneous mm.c cleanup
    
    This simply streamlines code in a few places, where room for
    improvement was noticed during the earlier here and the patches in
    the XSA-45 series.
    
    This also drops the bogus use of the domain lock in the CR3 write
    emulation (which protected against nothing).
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Tim Deegan <tim@xxxxxxx>
---
 xen/arch/x86/mm.c            |   52 ++++++++++++++---------------------------
 xen/arch/x86/traps.c         |    4 +-
 xen/include/asm-x86/config.h |    2 -
 3 files changed, 20 insertions(+), 38 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index dd89079..5123860 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2077,19 +2077,17 @@ static int alloc_page_type(struct page_info *page, 
unsigned long type,
 
     /* No need for atomic update of type_info here: noone else updates it. */
     wmb();
-    if ( rc == -EAGAIN )
-    {
-        get_page_light(page);
-        page->u.inuse.type_info |= PGT_partial;
-    }
-    else if ( rc == -EINTR )
+    switch ( rc )
     {
+    case 0:
+        page->u.inuse.type_info |= PGT_validated;
+        break;
+    case -EINTR:
         ASSERT((page->u.inuse.type_info &
                 (PGT_count_mask|PGT_validated|PGT_partial)) == 1);
         page->u.inuse.type_info &= ~PGT_count_mask;
-    }
-    else if ( rc )
-    {
+        break;
+    default:
         ASSERT(rc < 0);
         MEM_LOG("Error while validating mfn %lx (pfn %lx) for type %"
                 PRtype_info ": caf=%08lx taf=%" PRtype_info,
@@ -2101,13 +2099,11 @@ static int alloc_page_type(struct page_info *page, 
unsigned long type,
         {
             ASSERT((page->u.inuse.type_info &
                     (PGT_count_mask | PGT_validated)) == 1);
+    case -EAGAIN:
             get_page_light(page);
             page->u.inuse.type_info |= PGT_partial;
         }
-    }
-    else
-    {
-        page->u.inuse.type_info |= PGT_validated;
+        break;
     }
 
     return rc;
@@ -2886,7 +2882,7 @@ long do_mmuext_op(
 {
     struct mmuext_op op;
     unsigned long type;
-    unsigned int i = 0, done = 0;
+    unsigned int i, done = 0;
     struct vcpu *curr = current;
     struct domain *d = curr->domain;
     struct domain *pg_owner;
@@ -2919,22 +2915,16 @@ long do_mmuext_op(
         perfc_incr(calls_to_mmuext_op);
 
     if ( unlikely(!guest_handle_okay(uops, count)) )
-    {
-        rc = -EFAULT;
-        goto out;
-    }
+        return -EFAULT;
 
     if ( (pg_owner = get_pg_owner(foreigndom)) == NULL )
-    {
-        rc = -ESRCH;
-        goto out;
-    }
+        return -ESRCH;
 
     rc = xsm_mmuext_op(XSM_TARGET, d, pg_owner);
     if ( rc )
     {
-        rcu_unlock_domain(pg_owner);
-        goto out;
+        put_pg_owner(pg_owner);
+        return rc;
     }
 
     for ( i = 0; i < count; i++ )
@@ -3406,7 +3396,6 @@ long do_mmuext_op(
 
     perfc_add(num_mmuext_ops, i);
 
- out:
     /* Add incremental work we have done to the @done output parameter. */
     if ( unlikely(!guest_handle_is_null(pdone)) )
     {
@@ -3462,22 +3451,17 @@ long do_mmu_update(
         perfc_incr(calls_to_mmu_update);
 
     if ( unlikely(!guest_handle_okay(ureqs, count)) )
-    {
-        rc = -EFAULT;
-        goto out;
-    }
+        return -EFAULT;
 
     if ( (pt_dom = foreigndom >> 16) != 0 )
     {
         /* Pagetables belong to a foreign domain (PFD). */
         if ( (pt_owner = rcu_lock_domain_by_id(pt_dom - 1)) == NULL )
-        {
-            rc = -EINVAL;
-            goto out;
-        }
+            return -EINVAL;
+
         if ( pt_owner == d )
             rcu_unlock_domain(pt_owner);
-        if ( (v = pt_owner->vcpu ? pt_owner->vcpu[0] : NULL) == NULL )
+        else if ( !pt_owner->vcpu || (v = pt_owner->vcpu[0]) == NULL )
         {
             rc = -EINVAL;
             goto out;
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 4de9313..fbbe31d 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -2318,7 +2318,7 @@ static int emulate_privileged_op(struct cpu_user_regs 
*regs)
         case 3: {/* Write CR3 */
             unsigned long gfn;
             struct page_info *page;
-            domain_lock(v->domain);
+
             gfn = !is_pv_32on64_vcpu(v)
                 ? xen_cr3_to_pfn(*reg) : compat_cr3_to_pfn(*reg);
             page = get_page_from_gfn(v->domain, gfn, NULL, P2M_ALLOC);
@@ -2329,7 +2329,7 @@ static int emulate_privileged_op(struct cpu_user_regs 
*regs)
             }
             else
                 rc = -EINVAL;
-            domain_unlock(v->domain);
+
             switch ( rc )
             {
             case 0:
diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h
index cf93bd5..bd8f61c 100644
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -273,8 +273,6 @@ extern unsigned char boot_edid_info[128];
 
 #endif
 
-#define PGT_base_page_table     PGT_l4_page_table
-
 #define __HYPERVISOR_CS64 0xe008
 #define __HYPERVISOR_CS32 0xe038
 #define __HYPERVISOR_CS   __HYPERVISOR_CS64
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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