[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 14/16] x86/fsgsbase: Split out __{rd,wr}gskern() helpers
Right now they're inline in {read,write}_gs_shadow(), but we're going to need to use these elsewhere to support FRED. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/include/asm/fsgsbase.h | 36 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/include/asm/fsgsbase.h b/xen/arch/x86/include/asm/fsgsbase.h index 03e6a85d31ce..90d116f3bb54 100644 --- a/xen/arch/x86/include/asm/fsgsbase.h +++ b/xen/arch/x86/include/asm/fsgsbase.h @@ -32,6 +32,17 @@ static inline unsigned long __rdgsbase(void) return base; } +static inline unsigned long __rdgskern(void) +{ + unsigned long base; + + asm_inline volatile ( "swapgs\n\t" + "rdgsbase %0\n\t" + "swapgs" : "=r" (base) ); + + return base; +} + static inline void __wrfsbase(unsigned long base) { asm volatile ( "wrfsbase %0" :: "r" (base) ); @@ -42,6 +53,14 @@ static inline void __wrgsbase(unsigned long base) asm volatile ( "wrgsbase %0" :: "r" (base) ); } +static inline void __wrgskern(unsigned long base) +{ + asm_inline volatile ( "swapgs\n\t" + "wrgsbase %0\n\t" + "swapgs" + :: "r" (base) ); +} + static inline unsigned long read_fs_base(void) { unsigned long base; @@ -71,13 +90,9 @@ static inline unsigned long read_gs_shadow(void) unsigned long base; if ( read_cr4() & X86_CR4_FSGSBASE ) - { - asm volatile ( "swapgs" ); - base = __rdgsbase(); - asm volatile ( "swapgs" ); - } - else - rdmsrl(MSR_SHADOW_GS_BASE, base); + return __rdgskern(); + + rdmsrl(MSR_SHADOW_GS_BASE, base); return base; } @@ -101,12 +116,7 @@ static inline void write_gs_base(unsigned long base) static inline void write_gs_shadow(unsigned long base) { if ( read_cr4() & X86_CR4_FSGSBASE ) - { - asm volatile ( "swapgs\n\t" - "wrgsbase %0\n\t" - "swapgs" - :: "r" (base) ); - } + __wrgskern(base); else wrmsrl(MSR_SHADOW_GS_BASE, base); } -- 2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |