summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Christopherson <sean.j.christopherson@intel.com>2019-12-09 12:05:17 -0800
committerPaolo Bonzini <pbonzini@redhat.com>2020-01-08 18:16:02 +0100
commit95145c25a78cc0a9d3cbc75708abde432310c5a1 (patch)
tree5bdfd34337bfb6a0ef955f78d8d667cead2d4061
parentf958bd2314d117f8c29f4821401bc1925bc2e5ef (diff)
KVM: x86: Add a WARN on TIF_NEED_FPU_LOAD in kvm_load_guest_fpu()
WARN once in kvm_load_guest_fpu() if TIF_NEED_FPU_LOAD is observed, as that would mean that KVM is corrupting userspace's FPU by saving unknown register state into arch.user_fpu. Add a comment to explain why KVM WARNs on TIF_NEED_FPU_LOAD instead of implementing logic similar to fpu__copy(). Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/x86.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0af5cb637bea..25aac4c81b12 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8476,6 +8476,13 @@ static void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
{
fpregs_lock();
+ /*
+ * Reloading userspace's FPU is handled by kvm_arch_vcpu_load(), both
+ * for direct calls from userspace (via vcpu_load()) and if this task
+ * is preempted (via kvm_sched_in()) between vcpu_load() and now.
+ */
+ WARN_ON_ONCE(test_thread_flag(TIF_NEED_FPU_LOAD));
+
copy_fpregs_to_fpstate(vcpu->arch.user_fpu);
/* PKRU is separately restored in kvm_x86_ops->run. */
__copy_kernel_to_fpregs(&vcpu->arch.guest_fpu->state,