From: Andrew Cooper Date: Fri, 14 Oct 2016 15:37:02 +0000 (+0100) Subject: Implement write_cs() to match the existing read_cs() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e6444ebd41cefd48fdbab71b0ef99cb11124cc2b;p=xtf.git Implement write_cs() to match the existing read_cs() %cs can't be directly written to, so this is implemented using lret. Signed-off-by: Andrew Cooper --- diff --git a/include/arch/x86/lib.h b/include/arch/x86/lib.h index 3073e91..f8bcb81 100644 --- a/include/arch/x86/lib.h +++ b/include/arch/x86/lib.h @@ -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));