Skip to content

Commit a16eb25

Browse files
jsmattsonjrsean-jc
authored andcommitted
KVM: x86: Mask LVTPC when handling a PMI
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: f5132b0 ("KVM: Expose a version 2 architectural PMU to a guests") Cc: [email protected] Signed-off-by: Jim Mattson <[email protected]> Tested-by: Mingwei Zhang <[email protected]> Signed-off-by: Mingwei Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: massage changelog, correct Fixes] Signed-off-by: Sean Christopherson <[email protected]>
1 parent b29a2ac commit a16eb25

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kvm/lapic.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,13 +2759,17 @@ int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type)
27592759
{
27602760
u32 reg = kvm_lapic_get_reg(apic, lvt_type);
27612761
int vector, mode, trig_mode;
2762+
int r;
27622763

27632764
if (kvm_apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) {
27642765
vector = reg & APIC_VECTOR_MASK;
27652766
mode = reg & APIC_MODE_MASK;
27662767
trig_mode = reg & APIC_LVT_LEVEL_TRIGGER;
2767-
return __apic_accept_irq(apic, mode, vector, 1, trig_mode,
2768-
NULL);
2768+
2769+
r = __apic_accept_irq(apic, mode, vector, 1, trig_mode, NULL);
2770+
if (r && lvt_type == APIC_LVTPC)
2771+
kvm_lapic_set_reg(apic, APIC_LVTPC, reg | APIC_LVT_MASKED);
2772+
return r;
27692773
}
27702774
return 0;
27712775
}

0 commit comments

Comments
 (0)