• Maxim Levitsky's avatar
    KVM: x86: SVM: fix avic_kick_target_vcpus_fast · 603ccef4
    Maxim Levitsky authored
    There are two issues in avic_kick_target_vcpus_fast
    
    1. It is legal to issue an IPI request with APIC_DEST_NOSHORT
       and a physical destination of 0xFF (or 0xFFFFFFFF in case of x2apic),
       which must be treated as a broadcast destination.
    
       Fix this by explicitly checking for it.
       Also donâ€t use ‘index†in this case as it gives no new information.
    
    2. It is legal to issue a logical IPI request to more than one target.
       Index field only provides index in physical id table of first
       such target and therefore can't be used before we are sure
       that only a single target was addressed.
    
       Instead, parse the ICRL/ICRH, double check that a unicast interrupt
       was requested, and use that info to figure out the physical id
       of the target vCPU.
       At that point there is no need to use the index field as well.
    
    In addition to fixing the above	issues,	also skip the call to
    kvm_apic_match_dest.
    
    It is possible to do this now, because now as long as AVIC is not
    inhibited, it is guaranteed that none of the vCPUs changed their
    apic id from its default value.
    
    This fixes boot of windows guest with AVIC enabled because it uses
    IPI with 0xFF destination and no destination shorthand.
    
    Fixes: 7223fd2d ("KVM: SVM: Use target APIC ID to complete AVIC IRQs when possible")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
    Message-Id: <20220606180829.102503-5-mlevitsk@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    603ccef4
avic.c 27.5 KB