mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 00:39:48 +00:00
KVM: x86: Mask LVTPC when handling a PMI
commita16eb25b09
upstream. Per the SDM, "When the local APIC handles a performance-monitoring counters interrupt, it automatically sets the mask flag in the LVT performance counter register." Add this behavior to KVM's local APIC emulation. Failure to mask the LVTPC entry results in spurious PMIs, e.g. when running Linux as a guest, PMI handlers that do a "late_ack" spew a large number of "dazed and confused" spurious NMI warnings. Fixes:f5132b0138
("KVM: Expose a version 2 architectural PMU to a guests") Cc: stable@vger.kernel.org Signed-off-by: Jim Mattson <jmattson@google.com> Tested-by: Mingwei Zhang <mizhang@google.com> Signed-off-by: Mingwei Zhang <mizhang@google.com> Link: https://lore.kernel.org/r/20230925173448.3518223-3-mizhang@google.com [sean: massage changelog, correct Fixes] Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d11cfd1f30
commit
19ffa9b251
1 changed files with 6 additions and 2 deletions
|
@ -2535,13 +2535,17 @@ int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type)
|
||||||
{
|
{
|
||||||
u32 reg = kvm_lapic_get_reg(apic, lvt_type);
|
u32 reg = kvm_lapic_get_reg(apic, lvt_type);
|
||||||
int vector, mode, trig_mode;
|
int vector, mode, trig_mode;
|
||||||
|
int r;
|
||||||
|
|
||||||
if (kvm_apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) {
|
if (kvm_apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) {
|
||||||
vector = reg & APIC_VECTOR_MASK;
|
vector = reg & APIC_VECTOR_MASK;
|
||||||
mode = reg & APIC_MODE_MASK;
|
mode = reg & APIC_MODE_MASK;
|
||||||
trig_mode = reg & APIC_LVT_LEVEL_TRIGGER;
|
trig_mode = reg & APIC_LVT_LEVEL_TRIGGER;
|
||||||
return __apic_accept_irq(apic, mode, vector, 1, trig_mode,
|
|
||||||
NULL);
|
r = __apic_accept_irq(apic, mode, vector, 1, trig_mode, NULL);
|
||||||
|
if (r && lvt_type == APIC_LVTPC)
|
||||||
|
kvm_lapic_set_reg(apic, APIC_LVTPC, reg | APIC_LVT_MASKED);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue