Commit f57ad63a authored by Maxim Levitsky's avatar Maxim Levitsky Committed by Paolo Bonzini

KVM: x86: ignore SIPIs that are received while not in wait-for-sipi state

In the commit 1c96dcce
("KVM: x86: fix apic_accept_events vs check_nested_events"),

we accidently started latching SIPIs that are received while the cpu is not
waiting for them.

This causes vCPUs to never enter a halted state.

Fixes: 1c96dcce ("KVM: x86: fix apic_accept_events vs check_nested_events")
Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20201203143319.159394-2-mlevitsk@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent dee734a7
...@@ -2892,14 +2892,15 @@ void kvm_apic_accept_events(struct kvm_vcpu *vcpu) ...@@ -2892,14 +2892,15 @@ void kvm_apic_accept_events(struct kvm_vcpu *vcpu)
else else
vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
} }
if (test_bit(KVM_APIC_SIPI, &pe) && if (test_bit(KVM_APIC_SIPI, &pe)) {
vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
clear_bit(KVM_APIC_SIPI, &apic->pending_events); clear_bit(KVM_APIC_SIPI, &apic->pending_events);
/* evaluate pending_events before reading the vector */ if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
smp_rmb(); /* evaluate pending_events before reading the vector */
sipi_vector = apic->sipi_vector; smp_rmb();
kvm_vcpu_deliver_sipi_vector(vcpu, sipi_vector); sipi_vector = apic->sipi_vector;
vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; kvm_vcpu_deliver_sipi_vector(vcpu, sipi_vector);
vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment