• Sean Christopherson's avatar
    KVM: VMX: raise internal error for exception during invalid protected mode state · add5ff7a
    Sean Christopherson authored
    Exit to userspace with KVM_INTERNAL_ERROR_EMULATION if we encounter
    an exception in Protected Mode while emulating guest due to invalid
    guest state.  Unlike Big RM, KVM doesn't support emulating exceptions
    in PM, i.e. PM exceptions are always injected via the VMCS.  Because
    we will never do VMRESUME due to emulation_required, the exception is
    never realized and we'll keep emulating the faulting instruction over
    and over until we receive a signal.
    
    Exit to userspace iff there is a pending exception, i.e. don't exit
    simply on a requested event. The purpose of this check and exit is to
    aid in debugging a guest that is in all likelihood already doomed.
    Invalid guest state in PM is extremely limited in normal operation,
    e.g. it generally only occurs for a few instructions early in BIOS,
    and any exception at this time is all but guaranteed to be fatal.
    Non-vectored interrupts, e.g. INIT, SIPI and SMI, can be cleanly
    handled/emulated, while checking for vectored interrupts, e.g. INTR
    and NMI, without hitting false positives would add a fair amount of
    complexity for almost no benefit (getting hit by lightning seems
    more likely than encountering this specific scenario).
    
    Add a WARN_ON_ONCE to vmx_queue_exception() if we try to inject an
    exception via the VMCS and emulation_required is true.
    Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
    add5ff7a
vmx.c 362 KB