]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Provide all {read,write}_cr[02348]() stub functions
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 5 May 2016 15:12:17 +0000 (16:12 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 5 May 2016 15:22:28 +0000 (16:22 +0100)
Both GCC and Clang correctly encode %cr8 accesses using the lock
instruction prefix in 32bit mode.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/arch/x86/lib.h

index b1b2bf19a67ec0aba9b619232a942bd706040354..a99cd15e765bf2b439938a3079649fbebf5ff6aa 100644 (file)
@@ -195,6 +195,15 @@ static inline unsigned long read_dr7(void)
     return val;
 }
 
+static inline unsigned long read_cr0(void)
+{
+    unsigned long cr0;
+
+    asm volatile ("mov %%cr0, %0" : "=r" (cr0));
+
+    return cr0;
+}
+
 static inline unsigned long read_cr2(void)
 {
     unsigned long cr2;
@@ -213,6 +222,49 @@ static inline unsigned long read_cr3(void)
     return cr3;
 }
 
+static inline unsigned long read_cr4(void)
+{
+    unsigned long cr4;
+
+    asm volatile ("mov %%cr4, %0" : "=r" (cr4));
+
+    return cr4;
+}
+
+static inline unsigned long read_cr8(void)
+{
+    unsigned long cr8;
+
+    asm volatile ("mov %%cr8, %0" : "=r" (cr8));
+
+    return cr8;
+}
+
+static inline void write_cr0(unsigned long cr0)
+{
+    asm volatile ("mov %0, %%cr0" :: "r" (cr0));
+}
+
+static inline void write_cr2(unsigned long cr2)
+{
+    asm volatile ("mov %0, %%cr2" :: "r" (cr2));
+}
+
+static inline void write_cr3(unsigned long cr3)
+{
+    asm volatile ("mov %0, %%cr3" :: "r" (cr3));
+}
+
+static inline void write_cr4(unsigned long cr4)
+{
+    asm volatile ("mov %0, %%cr4" :: "r" (cr4));
+}
+
+static inline void write_cr8(unsigned long cr8)
+{
+    asm volatile ("mov %0, %%cr8" :: "r" (cr8));
+}
+
 #endif /* XTF_X86_LIB_H */
 
 /*