]> xenbits.xensource.com Git - xtf.git/commitdiff
Implement write_cs() to match the existing read_cs()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 14 Oct 2016 15:37:02 +0000 (16:37 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 17 Oct 2016 09:26:06 +0000 (10:26 +0100)
%cs can't be directly written to, so this is implemented using lret.

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

index 3073e91cc673b7d464938a802d098c1488d49fa9..f8bcb81270372355f2ca618abaf306c49933de2e 100644 (file)
@@ -189,6 +189,17 @@ static inline unsigned int read_ss(void)
     return ss;
 }
 
+static inline void write_cs(unsigned int cs)
+{
+    asm volatile ("push %0;"
+                  "push $1f;"
+#if __x86_64__
+                  "rex64 "
+#endif
+                  "lret; 1:"
+                  :: "qI" (cs));
+}
+
 static inline void write_ds(unsigned int ds)
 {
     asm volatile ("mov %0, %%ds" :: "r" (ds));