]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86: Ensure guest's FPU state is loaded when accessing for emulation
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 17 Jan 2020 19:30:50 +0000 (11:30 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:35:41 +0000 (04:35 -0800)
commit58e1e7514f06ac71a71d6e1059f4ee7813be3c37
tree1132d8b67be4a220f830a94842400f80d7afbe80
parenta6ff6e0546d0c579d68edf2e009240ed031c6ebc
KVM: x86: Ensure guest's FPU state is loaded when accessing for emulation

commit a7baead7e312f5a05381d68585fb6dc68e19e90f upstream.

Lock the FPU regs and reload the current thread's FPU state, which holds
the guest's FPU state, to the CPU registers if necessary prior to
accessing guest FPU state as part of emulation.  kernel_fpu_begin() can
be called from softirq context, therefore KVM must ensure softirqs are
disabled (locking the FPU regs disables softirqs) when touching CPU FPU
state.

Note, for all intents and purposes this reverts commit 6ab0b9feb82a7
("x86,kvm: remove KVM emulator get_fpu / put_fpu"), but at the time it
was applied, removing get/put_fpu() was correct.  The re-introduction
of {get,put}_fpu() is necessitated by the deferring of FPU state load.

Fixes: 5f409e20b7945 ("x86/fpu: Defer FPU state load until return to userspace")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/emulate.c