• Paolo Bonzini's avatar
    KVM: x86: avoid simultaneous queueing of both IRQ and SMI · eea340c2
    Paolo Bonzini authored
    commit c43203ca upstream.
    
    If the processor exits to KVM while delivering an interrupt,
    the hypervisor then requeues the interrupt for the next vmentry.
    Trying to enter SMM in this same window causes to enter non-root
    mode in emulated SMM (i.e. with IF=0) and with a request to
    inject an IRQ (i.e. with a valid VM-entry interrupt info field).
    This is invalid guest state (SDM 26.3.1.4 "Check on Guest RIP
    and RFLAGS") and the processor fails vmentry.
    
    The fix is to defer the injection from KVM_REQ_SMI to KVM_REQ_EVENT,
    like we already do for e.g. NMIs.  This patch doesn't change the
    name of the process_smi function so that it can be applied to
    stable releases.  The next patch will modify the names so that
    process_nmi and process_smi handle respectively KVM_REQ_NMI and
    KVM_REQ_SMI.
    
    This is especially common with Windows, probably due to the
    self-IPI trick that it uses to deliver deferred procedure
    calls (DPCs).
    Reported-by: default avatarLaszlo Ersek <lersek@redhat.com>
    Reported-by: default avatarMichał Zegan <webczat_200@poczta.onet.pl>
    Fixes: 64d60670Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    eea340c2
x86.c 216 KB