x86/mm: Drop is_guest_l3_slot() and simplify callers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Aug 2017 14:45:07 +0000 (14:45 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 28 Aug 2017 15:46:05 +0000 (16:46 +0100)
With a 64bit hypervisor there are no conditional l3 slots, and this is
unlikely to change moving forwards.

No functional change (as confirmed by diffing the disassembly.  GCC obviously
already optimised this code away.)

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

index bdba94a2683e9445042ffd4bc724082856aa7315..b6d6ae347404ef8dc9789957517bb222ea5eed44 100644 (file)
@@ -1557,8 +1557,7 @@ static int alloc_l3_table(struct page_info *page)
                     l3e_get_mfn(pl3e[i]),
                     PGT_l2_page_table | PGT_pae_xen_l2, d, partial, 1);
         }
-        else if ( !is_guest_l3_slot(i) ||
-                  (rc = get_page_from_l3e(pl3e[i], pfn, d, partial)) > 0 )
+        else if ( (rc = get_page_from_l3e(pl3e[i], pfn, d, partial)) > 0 )
             continue;
 
         if ( rc == -ERESTART )
@@ -1590,11 +1589,7 @@ static int alloc_l3_table(struct page_info *page)
             current->arch.old_guest_table = page;
         }
         while ( i-- > 0 )
-        {
-            if ( !is_guest_l3_slot(i) )
-                continue;
             unadjust_guest_l3e(pl3e[i], d);
-        }
     }
 
     unmap_domain_page(pl3e);
@@ -1759,16 +1754,13 @@ static int free_l3_table(struct page_info *page)
     pl3e = map_domain_page(_mfn(pfn));
 
     do {
-        if ( is_guest_l3_slot(i) )
-        {
-            rc = put_page_from_l3e(pl3e[i], pfn, partial, 0);
-            if ( rc < 0 )
-                break;
-            partial = 0;
-            if ( rc > 0 )
-                continue;
-            unadjust_guest_l3e(pl3e[i], d);
-        }
+        rc = put_page_from_l3e(pl3e[i], pfn, partial, 0);
+        if ( rc < 0 )
+            break;
+        partial = 0;
+        if ( rc > 0 )
+            continue;
+        unadjust_guest_l3e(pl3e[i], d);
     } while ( i-- );
 
     unmap_domain_page(pl3e);
@@ -2072,13 +2064,6 @@ static int mod_l3_entry(l3_pgentry_t *pl3e,
     struct domain *d = vcpu->domain;
     int rc = 0;
 
-    if ( unlikely(!is_guest_l3_slot(pgentry_ptr_to_slot(pl3e))) )
-    {
-        gdprintk(XENLOG_WARNING, "L3 update in Xen-private area, slot %#lx\n",
-                 pgentry_ptr_to_slot(pl3e));
-        return -EINVAL;
-    }
-
     /*
      * Disallow updates to final L3 slot. It contains Xen mappings, and it
      * would be a pain to ensure they remain continuously valid throughout.
index a9ba6f0a563f34e362759dd01c123f2638f55013..1151ce924ee793208ca74f15011bcdef30ee5cf0 100644 (file)
@@ -101,7 +101,6 @@ typedef l4_pgentry_t root_pgentry_t;
     ( !is_pv_32bit_domain(_d) ||                       \
       !((_t) & PGT_pae_xen_l2) ||                      \
       ((_s) < COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_d)) )
-#define is_guest_l3_slot(_s) (1)
 #define is_guest_l4_slot(_d, _s)                    \
     ( is_pv_32bit_domain(_d)                        \
       ? ((_s) == 0)                                 \