diff options
author | Radim Krčmář <rkrcmar@redhat.com> | 2015-07-01 09:31:49 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-10 12:49:37 -0400 |
commit | 8ed8b759437fadfd18202be9bb65a7f80c3c6d63 (patch) | |
tree | 8bf1fb02936940f659bdfe109ec3ae0275bbeb66 | |
parent | 58382447b9a9989da551a7b17e72756f6e238bb8 (diff) |
KVM: x86: make vapics_in_nmi_mode atomic
commit 42720138b06301cc8a7ee8a495a6d021c4b6a9bc upstream.
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]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 2 | ||||
-rw-r--r-- | arch/x86/kvm/i8254.c | 2 | ||||
-rw-r--r-- | arch/x86/kvm/lapic.c | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index f4a555beef19..41b06fca39f7 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -591,7 +591,7 @@ struct kvm_arch { | |||
591 | struct kvm_pic *vpic; | 591 | struct kvm_pic *vpic; |
592 | struct kvm_ioapic *vioapic; | 592 | struct kvm_ioapic *vioapic; |
593 | struct kvm_pit *vpit; | 593 | struct kvm_pit *vpit; |
594 | int vapics_in_nmi_mode; | 594 | atomic_t vapics_in_nmi_mode; |
595 | struct mutex apic_map_lock; | 595 | struct mutex apic_map_lock; |
596 | struct kvm_apic_map *apic_map; | 596 | struct kvm_apic_map *apic_map; |
597 | 597 | ||
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 4dce6f8b6129..f90952f64e79 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) | |||
305 | * LVT0 to NMI delivery. Other PIC interrupts are just sent to | 305 | * LVT0 to NMI delivery. Other PIC interrupts are just sent to |
306 | * VCPU0, and only if its LVT0 is in EXTINT mode. | 306 | * VCPU0, and only if its LVT0 is in EXTINT mode. |
307 | */ | 307 | */ |
308 | if (kvm->arch.vapics_in_nmi_mode > 0) | 308 | if (atomic_read(&kvm->arch.vapics_in_nmi_mode) > 0) |
309 | kvm_for_each_vcpu(i, vcpu, kvm) | 309 | kvm_for_each_vcpu(i, vcpu, kvm) |
310 | kvm_apic_nmi_wd_deliver(vcpu); | 310 | kvm_apic_nmi_wd_deliver(vcpu); |
311 | } | 311 | } |
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 556397ee4809..67d07e051436 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -1250,10 +1250,10 @@ static void apic_manage_nmi_watchdog(struct kvm_lapic *apic, u32 lvt0_val) | |||
1250 | if (!nmi_wd_enabled) { | 1250 | if (!nmi_wd_enabled) { |
1251 | apic_debug("Receive NMI setting on APIC_LVT0 " | 1251 | apic_debug("Receive NMI setting on APIC_LVT0 " |
1252 | "for cpu %d\n", apic->vcpu->vcpu_id); | 1252 | "for cpu %d\n", apic->vcpu->vcpu_id); |
1253 | apic->vcpu->kvm->arch.vapics_in_nmi_mode++; | 1253 | atomic_inc(&apic->vcpu->kvm->arch.vapics_in_nmi_mode); |
1254 | } | 1254 | } |
1255 | } else if (nmi_wd_enabled) | 1255 | } else if (nmi_wd_enabled) |
1256 | apic->vcpu->kvm->arch.vapics_in_nmi_mode--; | 1256 | atomic_dec(&apic->vcpu->kvm->arch.vapics_in_nmi_mode); |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) | 1259 | static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) |