linux/arch/x86/kvm/svm
Thomas Gleixner c3f08ed150 x86/kvm/svm: Use uninstrumented wrmsrl() to restore GS
On guest exit MSR_GS_BASE contains whatever the guest wrote to it and the
first action after returning from the ASM code is to set it to the host
kernel value. This uses wrmsrl() which is interesting at least.

wrmsrl() is either using native_write_msr() or the paravirt variant. The
XEN_PV code is uninteresting as nested SVM in a XEN_PV guest does not work.

But native_write_msr() can be placed out of line by the compiler especially
when paravirtualization is enabled in the kernel configuration. The
function is marked notrace, but still can be probed if
CONFIG_KPROBE_EVENTS_ON_NOTRACE is enabled.

That would be a fatal problem as kprobe events use per-CPU variables which
are GS based and would be accessed with the guest GS. Depending on the GS
value this would either explode in colorful ways or lead to completely
undebugable data corruption.

Aside of that native_write_msr() contains a tracepoint which objtool
complains about as it is invoked from the noinstr section.

As this cannot run inside a XEN_PV guest there is no point in using
wrmsrl(). Use native_wrmsrl() instead which is just a plain native WRMSR
without tracing or anything else attached.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Juergen Gross <jgross@suse.com>
Message-Id: <20200708195322.244847377@linutronix.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-07-09 07:08:41 -04:00
..
avic.c KVM: SVM: Add vmcb_ prefix to mark_*() functions 2020-07-08 16:21:48 -04:00
nested.c KVM: nSVM: Check that MBZ bits in CR3 and CR4 are not set on vmrun of nested guests 2020-07-08 16:21:59 -04:00
pmu.c KVM: x86/pmu: Tweak kvm_pmu_get_msr to pass 'struct msr_data' in 2020-06-01 04:26:08 -04:00
sev.c KVM: SVM: Add vmcb_ prefix to mark_*() functions 2020-07-08 16:21:48 -04:00
svm.c x86/kvm/svm: Use uninstrumented wrmsrl() to restore GS 2020-07-09 07:08:41 -04:00
svm.h KVM: nSVM: Check that MBZ bits in CR3 and CR4 are not set on vmrun of nested guests 2020-07-08 16:21:59 -04:00
vmenter.S x86/kvm/svm: Move guest enter/exit into .noinstr.text 2020-07-09 07:08:41 -04:00