]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.11.2/kvm-x86-fix-user-triggerable-warning-in-kvm_apic_accept_events.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.11.2 / kvm-x86-fix-user-triggerable-warning-in-kvm_apic_accept_events.patch
CommitLineData
b889272d
GKH
1From 28bf28887976d8881a3a59491896c718fade7355 Mon Sep 17 00:00:00 2001
2From: David Hildenbrand <david@redhat.com>
3Date: Thu, 23 Mar 2017 11:46:03 +0100
4Subject: KVM: x86: fix user triggerable warning in kvm_apic_accept_events()
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: David Hildenbrand <david@redhat.com>
10
11commit 28bf28887976d8881a3a59491896c718fade7355 upstream.
12
13If we already entered/are about to enter SMM, don't allow switching to
14INIT/SIPI_RECEIVED, otherwise the next call to kvm_apic_accept_events()
15will report a warning.
16
17Same applies if we are already in MP state INIT_RECEIVED and SMM is
18requested to be turned on. Refuse to set the VCPU events in this case.
19
20Fixes: cd7764fe9f73 ("KVM: x86: latch INITs while in system management mode")
21Reported-by: Dmitry Vyukov <dvyukov@google.com>
22Signed-off-by: David Hildenbrand <david@redhat.com>
23Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
24Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26---
27 arch/x86/kvm/x86.c | 12 ++++++++++++
28 1 file changed, 12 insertions(+)
29
30--- a/arch/x86/kvm/x86.c
31+++ b/arch/x86/kvm/x86.c
32@@ -3127,6 +3127,12 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_e
33 (events->exception.nr > 31 || events->exception.nr == NMI_VECTOR))
34 return -EINVAL;
35
36+ /* INITs are latched while in SMM */
37+ if (events->flags & KVM_VCPUEVENT_VALID_SMM &&
38+ (events->smi.smm || events->smi.pending) &&
39+ vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED)
40+ return -EINVAL;
41+
42 process_nmi(vcpu);
43 vcpu->arch.exception.pending = events->exception.injected;
44 vcpu->arch.exception.nr = events->exception.nr;
45@@ -7355,6 +7361,12 @@ int kvm_arch_vcpu_ioctl_set_mpstate(stru
46 mp_state->mp_state != KVM_MP_STATE_RUNNABLE)
47 return -EINVAL;
48
49+ /* INITs are latched while in SMM */
50+ if ((is_smm(vcpu) || vcpu->arch.smi_pending) &&
51+ (mp_state->mp_state == KVM_MP_STATE_SIPI_RECEIVED ||
52+ mp_state->mp_state == KVM_MP_STATE_INIT_RECEIVED))
53+ return -EINVAL;
54+
55 if (mp_state->mp_state == KVM_MP_STATE_SIPI_RECEIVED) {
56 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
57 set_bit(KVM_APIC_SIPI, &vcpu->arch.apic->pending_events);