Skip to content

Commit 755c2bf

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: lapic: don't touch irr_pending in kvm_apic_update_apicv when inhibiting it
kvm_apic_update_apicv is called when AVIC is still active, thus IRR bits can be set by the CPU after it is called, and don't cause the irr_pending to be set to true. Also logic in avic_kick_target_vcpu doesn't expect a race with this function so to make it simple, just keep irr_pending set to true and let the next interrupt injection to the guest clear it. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20220207155447.840194-9-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 2b0eccc commit 755c2bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/x86/kvm/lapic.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,12 @@ void kvm_apic_update_apicv(struct kvm_vcpu *vcpu)
23062306
apic->irr_pending = true;
23072307
apic->isr_count = 1;
23082308
} else {
2309-
apic->irr_pending = (apic_search_irr(apic) != -1);
2309+
/*
2310+
* Don't clear irr_pending, searching the IRR can race with
2311+
* updates from the CPU as APICv is still active from hardware's
2312+
* perspective. The flag will be cleared as appropriate when
2313+
* KVM injects the interrupt.
2314+
*/
23102315
apic->isr_count = count_vectors(apic->regs + APIC_ISR);
23112316
}
23122317
}

0 commit comments

Comments
 (0)