diff options
author | Radim Krčmář <rkrcmar@redhat.com> | 2015-07-01 15:31:49 +0200 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2015-07-13 08:50:07 -0400 |
commit | 26f6fb3b8eaaca7f35a7b8d86ed5e6eb7592b306 (patch) | |
tree | 564762318b1d1ad8a5081f567196046da2dbb8b2 /arch/x86/kvm | |
parent | 7464fcc6df1189e2088cb846fc73838edd70af87 (diff) | |
download | linux-stable-26f6fb3b8eaaca7f35a7b8d86ed5e6eb7592b306.tar.gz linux-stable-26f6fb3b8eaaca7f35a7b8d86ed5e6eb7592b306.tar.bz2 linux-stable-26f6fb3b8eaaca7f35a7b8d86ed5e6eb7592b306.zip |
KVM: x86: make vapics_in_nmi_mode atomic
[ Upstream commit 42720138b06301cc8a7ee8a495a6d021c4b6a9bc ]
Writes were a bit racy, but hard to turn into a bug at the same time.
(Particularly because modern Linux doesn't use this feature anymore.)
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
[Actually the next patch makes it much, much easier to trigger the race
so I'm including this one for stable@ as well. - Paolo]
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/i8254.c | 2 | ||||
-rw-r--r-- | arch/x86/kvm/lapic.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 298781d4cfb4..1406ffde3e35 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -305,7 +305,7 @@ static void pit_do_work(struct kthread_work *work) * LVT0 to NMI delivery. Other PIC interrupts are just sent to * VCPU0, and only if its LVT0 is in EXTINT mode. */ - if (kvm->arch.vapics_in_nmi_mode > 0) + if (atomic_read(&kvm->arch.vapics_in_nmi_mode) > 0) kvm_for_each_vcpu(i, vcpu, kvm) kvm_apic_nmi_wd_deliver(vcpu); } diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index b8345dd41b25..fe637cab8e9c 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1112,10 +1112,10 @@ static void apic_manage_nmi_watchdog(struct kvm_lapic *apic, u32 lvt0_val) if (!nmi_wd_enabled) { apic_debug("Receive NMI setting on APIC_LVT0 " "for cpu %d\n", apic->vcpu->vcpu_id); - apic->vcpu->kvm->arch.vapics_in_nmi_mode++; + atomic_inc(&apic->vcpu->kvm->arch.vapics_in_nmi_mode); } } else if (nmi_wd_enabled) - apic->vcpu->kvm->arch.vapics_in_nmi_mode--; + atomic_dec(&apic->vcpu->kvm->arch.vapics_in_nmi_mode); } static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) |