]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: Misc cleanup to {create,replace}_grant_host_mapping()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 1 Aug 2017 15:39:59 +0000 (16:39 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 13 Sep 2017 10:22:22 +0000 (11:22 +0100)
The purpose of this patch is solely to simplify the resulting diff of later
changes.

 * Factor out curr and currd at the start of the functions.
 * Rename pte to nl1e.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm.c

index d5aba96b255d715a6e743bb239a3a184076eda82..a848d7dc14d010c28096db4965260e3e9bc22f66 100644 (file)
@@ -4125,19 +4125,21 @@ static int destroy_grant_va_mapping(
 int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
                             unsigned int flags, unsigned int cache_flags)
 {
-    l1_pgentry_t pte;
+    struct vcpu *curr = current;
+    l1_pgentry_t nl1e;
 
-    pte = l1e_from_pfn(frame, grant_to_pte_flags(flags, cache_flags));
+    nl1e = l1e_from_pfn(frame, grant_to_pte_flags(flags, cache_flags));
 
     if ( flags & GNTMAP_contains_pte )
-        return create_grant_pte_mapping(addr, pte, current);
-    return create_grant_va_mapping(addr, pte, current);
+        return create_grant_pte_mapping(addr, nl1e, curr);
+    return create_grant_va_mapping(addr, nl1e, curr);
 }
 
 int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
                              uint64_t new_addr, unsigned int flags)
 {
     struct vcpu *curr = current;
+    struct domain *currd = curr->domain;
     l1_pgentry_t *pl1e, ol1e;
     mfn_t gl1mfn;
     struct page_info *l1pg;
@@ -4149,7 +4151,7 @@ int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
      * also open-code relevant parts of adjust_guest_l1e(). Don't mirror
      * available and cachability flags, though.
      */
-    if ( !is_pv_32bit_domain(curr->domain) )
+    if ( !is_pv_32bit_domain(currd) )
         grant_pte_flags |= (grant_pte_flags & _PAGE_USER)
                            ? _PAGE_GLOBAL
                            : _PAGE_GUEST_KERNEL | _PAGE_USER;
@@ -4158,7 +4160,7 @@ int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
     {
         if ( !new_addr )
             return destroy_grant_pte_mapping(addr, frame, grant_pte_flags,
-                                             curr->domain);
+                                             currd);
 
         return GNTST_general_error;
     }
@@ -4174,7 +4176,7 @@ int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
         return GNTST_general_error;
     }
 
-    if ( !get_page_from_mfn(gl1mfn, current->domain) )
+    if ( !get_page_from_mfn(gl1mfn, currd) )
     {
         unmap_domain_page(pl1e);
         return GNTST_general_error;
@@ -4214,7 +4216,7 @@ int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
 
     rc = replace_grant_va_mapping(addr, frame, grant_pte_flags, ol1e, curr);
     if ( rc )
-        put_page_from_l1e(ol1e, curr->domain);
+        put_page_from_l1e(ol1e, currd);
 
     return rc;
 }