From: Andrew Cooper Date: Wed, 4 Dec 2019 18:19:25 +0000 (+0000) Subject: Misc extra instruction wrappers X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7cfab7dbc351fc33a84f7bb010176df7d9b1a023;p=xtf.git Misc extra instruction wrappers Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/include/arch/lib.h b/arch/x86/include/arch/lib.h index e9857fa..0259c2e 100644 --- a/arch/x86/include/arch/lib.h +++ b/arch/x86/include/arch/lib.h @@ -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 */ /* diff --git a/arch/x86/include/arch/x86-gate.h b/arch/x86/include/arch/x86-gate.h index c02cccf..34376e2 100644 --- a/arch/x86/include/arch/x86-gate.h +++ b/arch/x86/include/arch/x86-gate.h @@ -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 */ /*