Skip to content

Commit d029bff

Browse files
amlutoKAGA-KOKO
authored andcommitted
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. Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/f07c08f178fe9711915862b656722a207cd52c28.1593192140.git.luto@kernel.org
1 parent 40c4590 commit d029bff

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

arch/x86/kernel/process_64.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,15 @@ static noinstr unsigned long __rdgsbase_inactive(void)
163163

164164
lockdep_assert_irqs_disabled();
165165

166-
native_swapgs();
167-
gsbase = rdgsbase();
168-
native_swapgs();
166+
if (!static_cpu_has(X86_FEATURE_XENPV)) {
167+
native_swapgs();
168+
gsbase = rdgsbase();
169+
native_swapgs();
170+
} else {
171+
instrumentation_begin();
172+
rdmsrl(MSR_KERNEL_GS_BASE, gsbase);
173+
instrumentation_end();
174+
}
169175

170176
return gsbase;
171177
}
@@ -182,9 +188,15 @@ static noinstr void __wrgsbase_inactive(unsigned long gsbase)
182188
{
183189
lockdep_assert_irqs_disabled();
184190

185-
native_swapgs();
186-
wrgsbase(gsbase);
187-
native_swapgs();
191+
if (!static_cpu_has(X86_FEATURE_XENPV)) {
192+
native_swapgs();
193+
wrgsbase(gsbase);
194+
native_swapgs();
195+
} else {
196+
instrumentation_begin();
197+
wrmsrl(MSR_KERNEL_GS_BASE, gsbase);
198+
instrumentation_end();
199+
}
188200
}
189201

190202
/*

0 commit comments

Comments
 (0)