]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
tools/libxc: Construct 32bit PV guests with L3 A/D bits set
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 14 Jan 2020 12:17:45 +0000 (12:17 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Jan 2020 19:26:09 +0000 (19:26 +0000)
With the 32 PAE build of Xen gone, 32bit PV guests' top level pagetables no
longer behave exactly like PAE in hardware.

They should have A/D bits set, for the same performance reasons as apply to
other levels.  This brings the domain builder in line with how Xen constructs
a 32bit dom0.

As a purely code improvement, make use of range notation to initialise
identical values in adjacent array elements.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wl@xen.org>
tools/libxc/xc_dom_x86.c

index 1897decedb686a51e90a018e3639ee04143c0b5e..155ef690379311a23629a9cf8b6431a3189c0539 100644 (file)
@@ -277,8 +277,12 @@ static int alloc_pgtables_x86_32_pae(struct xc_dom_image *dom)
         .levels = PGTBL_LEVELS_I386,
         .vaddr_mask = bits_to_mask(VIRT_BITS_I386),
         .lvl_prot[0] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED,
-        .lvl_prot[1] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-        .lvl_prot[2] = _PAGE_PRESENT,
+        /*
+         * 64bit Xen runs 32bit PV guests with the PAE entries in an L3
+         * pagetable.  They don't behave exactly like native PAE paging.
+         */
+        .lvl_prot[1 ... 2] =
+            _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
     };
     struct xc_dom_image_x86 *domx86 = dom->arch_private;
 
@@ -488,9 +492,8 @@ static int alloc_pgtables_x86_64(struct xc_dom_image *dom)
         .levels = PGTBL_LEVELS_X86_64,
         .vaddr_mask = bits_to_mask(VIRT_BITS_X86_64),
         .lvl_prot[0] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED,
-        .lvl_prot[1] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-        .lvl_prot[2] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
-        .lvl_prot[3] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
+        .lvl_prot[1 ... 3] =
+            _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER,
     };
     struct xc_dom_image_x86 *domx86 = dom->arch_private;