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@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
v3:
* Rename to __{rd,wr}gs_shadow()
---
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..557703842691 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 __rdgs_shadow(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 __wrgs_shadow(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 __rdgs_shadow();
+
+ 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) );
- }
+ __wrgs_shadow(base);
else
wrmsrl(MSR_SHADOW_GS_BASE, base);
}
--
2.39.5