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

[Xen-devel] [PATCH] x86/mm: PV GDT handling cleanup



These are a few bits of cleanup noticed when double checking the PV GDT
handling for migration v2.

 * Drop write-only 'mfn' variable in set_gdt()
 * Hoist page_get_owner() call in alloc_segdesc_page() and unify exit paths

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Tim Deegan <tim@xxxxxxx>
---
 xen/arch/x86/mm.c |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 5fe08df..74e146d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -545,21 +545,17 @@ static void invalidate_shadow_ldt(struct vcpu *v, int 
flush)
 
 static int alloc_segdesc_page(struct page_info *page)
 {
-    struct desc_struct *descs;
-    int i;
-
-    descs = __map_domain_page(page);
+    const struct domain *owner = page_get_owner(page);
+    struct desc_struct *descs = __map_domain_page(page);
+    unsigned i;
 
     for ( i = 0; i < 512; i++ )
-        if ( unlikely(!check_descriptor(page_get_owner(page), &descs[i])) )
-            goto fail;
+        if ( unlikely(!check_descriptor(owner, &descs[i])) )
+            break;
 
     unmap_domain_page(descs);
-    return 0;
 
- fail:
-    unmap_domain_page(descs);
-    return -EINVAL;
+    return i == 512 ? 0 : -EINVAL;
 }
 
 
@@ -4382,7 +4378,7 @@ long set_gdt(struct vcpu *v,
     l1_pgentry_t *pl1e;
     /* NB. There are 512 8-byte entries per GDT page. */
     int i, nr_pages = (entries + 511) / 512;
-    unsigned long mfn, *pfns;
+    unsigned long *pfns;
 
     if ( entries > FIRST_RESERVED_GDT_ENTRY )
         return -EINVAL;
@@ -4404,7 +4400,7 @@ long set_gdt(struct vcpu *v,
             put_page(page);
             goto fail;
         }
-        mfn = frames[i] = page_to_mfn(page);
+        frames[i] = page_to_mfn(page);
     }
 
     /* Tear down the old GDT. */
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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