]> xenbits.xensource.com Git - xtf.git/commitdiff
Misc extra instruction wrappers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 4 Dec 2019 18:19:25 +0000 (18:19 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 4 Dec 2019 18:32:06 +0000 (18:32 +0000)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/lib.h
arch/x86/include/arch/x86-gate.h

index e9857fa231a88dbc392a981780f7a21971a797db..0259c2ed7525c348c11fc735ae951e99d41573be 100644 (file)
@@ -211,6 +211,20 @@ static inline void write_ss(unsigned int ss)
     asm volatile ("mov %0, %%ss" :: "rm" (ss));
 }
 
+static inline unsigned int read_flags(void)
+{
+    unsigned int flags;
+
+    asm volatile ("pushf; pop %0" : "=rm" (flags));
+
+    return flags;
+}
+
+static inline void write_flags(unsigned int flags)
+{
+    asm volatile ("push %0; popf" :: "irm" (flags));
+}
+
 static inline unsigned long read_cr0(void)
 {
     unsigned long cr0;
@@ -374,6 +388,11 @@ static inline void write_xcr0(uint64_t xcr0)
     xsetbv(0, xcr0);
 }
 
+static inline void clflush(const void *ptr)
+{
+    asm volatile ("clflush %0" :: "m" (*(const char *)ptr));
+}
+
 #endif /* XTF_X86_LIB_H */
 
 /*
index c02cccf38078b759341b77f8a3c70fb79d8d3622..34376e2125c0a96d49b1d1ea044c34a863ef9e7f 100644 (file)
@@ -121,6 +121,13 @@ static inline void pack_intr_gate(
     pack_gate(g, 14, sel, offset, dpl, other);
 }
 
+static inline void pack_trap_gate(
+    env_gate *g, unsigned int sel, unsigned long offset,
+    unsigned int dpl, unsigned int other)
+{
+    pack_gate(g, 15, sel, offset, dpl, other);
+}
+
 #endif /* XTF_X86_GATE_H */
 
 /*