]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/gnttab: Simplify gnttab_map_frame()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 23 Oct 2018 18:49:34 +0000 (19:49 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 22 Nov 2018 17:58:46 +0000 (17:58 +0000)
 * Reflow some lines to remove unnecessary line breaks.
 * Factor out the gnttab_get_frame_gfn() calculation.  Neither x86 nor ARM
   builds seem to be able to fold the two calls, and the resulting code is far
   easier to follow.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/grant_table.c

index 9ddfee1da937800ab54489c4b4ca25e22cf9b360..b67ae9e3f5c270921b0afbeef00f5186311a323c 100644 (file)
@@ -3869,8 +3869,7 @@ static int gnttab_get_shared_frame_mfn(struct domain *d,
     return 0;
 }
 
-int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
-                     mfn_t *mfn)
+int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn, mfn_t *mfn)
 {
     int rc = 0;
     struct grant_table *gt = d->grant_table;
@@ -3878,8 +3877,7 @@ int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
 
     grant_write_lock(gt);
 
-    if ( gt->gt_version == 2 &&
-         (idx & XENMAPIDX_grant_table_status) )
+    if ( gt->gt_version == 2 && (idx & XENMAPIDX_grant_table_status) )
     {
         idx &= ~XENMAPIDX_grant_table_status;
         status = true;
@@ -3889,10 +3887,13 @@ int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
     else
         rc = gnttab_get_shared_frame_mfn(d, idx, mfn);
 
-    if ( !rc && paging_mode_translate(d) &&
-         !gfn_eq(gnttab_get_frame_gfn(gt, status, idx), INVALID_GFN) )
-        rc = guest_physmap_remove_page(d, gnttab_get_frame_gfn(gt, status, idx),
-                                       *mfn, 0);
+    if ( !rc && paging_mode_translate(d) )
+    {
+        gfn_t gfn = gnttab_get_frame_gfn(gt, status, idx);
+
+        if ( !gfn_eq(gfn, INVALID_GFN) )
+            rc = guest_physmap_remove_page(d, gfn, *mfn, 0);
+    }
 
     if ( !rc )
         gnttab_set_frame_gfn(gt, status, idx, gfn);