[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH fsgsbase v2 4/4] x86/fsgsbase: Fix Xen PV support



On Xen PV, SWAPGS doesn't work.  Teach __rdfsbase_inactive() and
__wrgsbase_inactive() to use rdmsrl()/wrmsrl() on Xen PV.  The Xen
pvop code will understand this and issue the correct hypercalls.

Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
---
 arch/x86/kernel/process_64.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index cb8e37d3acaa..457d02aa10d8 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -163,9 +163,13 @@ static noinstr unsigned long __rdgsbase_inactive(void)
 
        lockdep_assert_irqs_disabled();
 
-       native_swapgs();
-       gsbase = rdgsbase();
-       native_swapgs();
+       if (!static_cpu_has(X86_FEATURE_XENPV)) {
+               native_swapgs();
+               gsbase = rdgsbase();
+               native_swapgs();
+       } else {
+               rdmsrl(MSR_KERNEL_GS_BASE, gsbase);
+       }
 
        return gsbase;
 }
@@ -182,9 +186,13 @@ static noinstr void __wrgsbase_inactive(unsigned long 
gsbase)
 {
        lockdep_assert_irqs_disabled();
 
-       native_swapgs();
-       wrgsbase(gsbase);
-       native_swapgs();
+       if (!static_cpu_has(X86_FEATURE_XENPV)) {
+               native_swapgs();
+               wrgsbase(gsbase);
+               native_swapgs();
+       } else {
+               wrmsrl(MSR_KERNEL_GS_BASE, gsbase);
+       }
 }
 
 /*
-- 
2.25.4




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.