Patch "KVM: nVMX: Prioritize TSS T-flag #DBs over Monitor Trap Flag" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    KVM: nVMX: Prioritize TSS T-flag #DBs over Monitor Trap Flag

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-nvmx-prioritize-tss-t-flag-dbs-over-monitor-trap.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c09b39bc2c9bfd8e2bdf4966c48c353b4e4a5127
Author: Sean Christopherson <seanjc@xxxxxxxxxx>
Date:   Tue Aug 30 23:15:54 2022 +0000

    KVM: nVMX: Prioritize TSS T-flag #DBs over Monitor Trap Flag
    
    [ Upstream commit b9d44f9091ac6c325fc2f7b7671b462fb36abbed ]
    
    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@xxxxxxxxxx>
    Cc: Peter Shier <pshier@xxxxxxxxxx>
    Fixes: 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing instruction emulation")
    Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Reviewed-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220830231614.3580124-8-seanjc@xxxxxxxxxx
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index cdbe827ec960..f28085b89f47 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -3938,15 +3938,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))



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux