• Maxim Levitsky's avatar
    KVM: SVM: fix race between interrupt delivery and AVIC inhibition · 66fa226c
    Maxim Levitsky authored
    If svm_deliver_avic_intr is called just after the target vcpu's AVIC got
    inhibited, it might read a stale value of vcpu->arch.apicv_active
    which can lead to the target vCPU not noticing the interrupt.
    
    To fix this use load-acquire/store-release so that, if the target vCPU
    is IN_GUEST_MODE, we're guaranteed to see a previous disabling of the
    AVIC.  If AVIC has been disabled in the meanwhile, proceed with the
    KVM_REQ_EVENT-based delivery.
    
    Incomplete IPI vmexit has the same races as svm_deliver_avic_intr, and
    in fact it can be handled in exactly the same way; the only difference
    lies in who has set IRR, whether svm_deliver_interrupt or the processor.
    Therefore, svm_complete_interrupt_delivery can be used to fix incomplete
    IPI vmexits as well.
    Co-developed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    66fa226c
svm.c 132 KB