lkml.org 
[lkml]   [2022]   [Jul]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v4 05/24] KVM: nVMX: Prioritize TSS T-flag #DBs over Monitor Trap Flag
    From
    Service TSS T-flag #DBs prior to pending MTFs, as such #DBs are higher
    priority than MTF. KVM itself doesn't emulate TSS #DBs, and any such
    exceptions injected from L1 will be handled by hardware (or morphed to
    a fault-like exception if injection fails), but theoretically userspace
    could pend a TSS T-flag #DB in conjunction with a pending MTF.

    Note, there's no known use case this fixes, it's purely to be technically
    correct with respect to Intel's SDM.

    Cc: Oliver Upton <oupton@google.com>
    Cc: Peter Shier <pshier@google.com>
    Fixes: 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing instruction emulation")
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
    ---
    arch/x86/kvm/vmx/nested.c | 8 +++++---
    1 file changed, 5 insertions(+), 3 deletions(-)

    diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
    index 456449778598..6b4368d96d9e 100644
    --- a/arch/x86/kvm/vmx/nested.c
    +++ b/arch/x86/kvm/vmx/nested.c
    @@ -3939,15 +3939,17 @@ static int vmx_check_nested_events(struct kvm_vcpu *vcpu)
    }

    /*
    - * Process any exceptions that are not debug traps before MTF.
    + * Process exceptions that are higher priority than Monitor Trap Flag:
    + * fault-like exceptions, TSS T flag #DB (not emulated by KVM, but
    + * could theoretically come in from userspace), and ICEBP (INT1).
    *
    * Note that only a pending nested run can block a pending exception.
    * Otherwise an injected NMI/interrupt should either be
    * lost or delivered to the nested hypervisor in the IDT_VECTORING_INFO,
    * while delivering the pending exception.
    */
    -
    - if (vcpu->arch.exception.pending && !vmx_get_pending_dbg_trap(vcpu)) {
    + if (vcpu->arch.exception.pending &&
    + !(vmx_get_pending_dbg_trap(vcpu) & ~DR6_BT)) {
    if (vmx->nested.nested_run_pending)
    return -EBUSY;
    if (!nested_vmx_check_exception(vcpu, &exit_qual))
    --
    2.37.1.359.gd136c6c3e2-goog
    \
     
     \ /
      Last update: 2022-07-23 02:52    [W:4.880 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site