]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Provide _PAGE_AD as shorthand, and simplify the invlpg test
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 17 May 2016 18:37:54 +0000 (19:37 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 17 May 2016 18:40:30 +0000 (19:40 +0100)
Pass _PAGE_AD as parameter to the asm block, to reduce the use of magic
constants.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/arch/x86/page.h
tests/invlpg/main.c

index 7080ade520afdf1ac2ad99960755c323f07973f8..f472cf671a7f371afba7c3477ab3a6cbab2c94a7 100644 (file)
@@ -23,6 +23,7 @@
 #define _PAGE_USER              0x004
 #define _PAGE_ACCESSED          0x020
 #define _PAGE_DIRTY             0x040
+#define _PAGE_AD                (_PAGE_ACCESSED | _PAGE_DIRTY)
 #define _PAGE_PSE               0x080
 
 #if CONFIG_PAGING_LEVELS == 2 /* PSE Paging */
index b23928820edefb9093e709b1222e575ef732b473..3c5ffc9afdcf508418af5ef7339b6cadfc492e7b 100644 (file)
@@ -119,15 +119,15 @@ static bool __used ex_fail(struct cpu_regs *regs,
 /** Are both the Accessed and Dirty bits are set in a pagetable entry? */
 static bool test_ad(uint64_t pte)
 {
-    return (pte & (_PAGE_ACCESSED|_PAGE_DIRTY)) == (_PAGE_ACCESSED|_PAGE_DIRTY);
+    return (pte & _PAGE_AD) == _PAGE_AD;
 }
 
 static unsigned int invlpg_refill(void)
 {
     asm volatile ("mov %[zero], 0x1000;\n\t"   /* Force TLB fill. */
                   "mov %[zero], 0x2000;\n\t"
-                  "andb $0x9f, %[pte1];\n\t"   /* Clear A/D bits. */
-                  "andb $0x9f, %[pte2];\n\t"
+                  "andb $~%c[ad], %[pte1];\n\t" /* Clear A/D bits. */
+                  "andb $~%c[ad], %[pte2];\n\t"
                   _ASM_MAYBE_XEN_FEP
                   "1: invlpg (0x1000); 2:\n\t" /* Invalidate one page only. */
                   _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail)
@@ -135,6 +135,7 @@ static unsigned int invlpg_refill(void)
                   "mov %[zero], 0x2000;\n\t"   /* Expect no refill. */
                   :
                   : [zero] "q" (0),
+                    [ad]   "i" (_PAGE_AD),
                     [pte1] "m" (pae_l1_identmap[1]),
                     [pte2] "m" (pae_l1_identmap[2])
                   : "memory");
@@ -147,8 +148,8 @@ static unsigned int invlpg_fs_refill(void)
 {
     asm volatile ("mov %[zero], 0x1000;\n\t"  /* Force TLB fill. */
                   "mov %[zero], 0x2000;\n\t"
-                  "andb $0x9f, %[pte1];\n\t"  /* Clear A/D bits. */
-                  "andb $0x9f, %[pte2];\n\t"
+                  "andb $~%c[ad], %[pte1];\n\t" /* Clear A/D bits. */
+                  "andb $~%c[ad], %[pte2];\n\t"
                   _ASM_MAYBE_XEN_FEP
                   "1: invlpg %%fs:(0x1000); 2:\n\t" /* Invalidate one page only. */
                   _ASM_EXTABLE_HANDLER(1b, 2b, ex_fail)
@@ -156,6 +157,7 @@ static unsigned int invlpg_fs_refill(void)
                   "mov %[zero], 0x2000;\n\t"  /* depending on %fs base.*/
                   :
                   : [zero] "q" (0),
+                    [ad]   "i" (_PAGE_AD),
                     [pte1] "m" (pae_l1_identmap[1]),
                     [pte2] "m" (pae_l1_identmap[2])
                   : "memory");