Skip to contentSkip to conversation

FAILED: patch "[PATCH] KVM: nVMX: Make an event request when pending an MTF nested" failed to apply to 6.0-stable tree

PATCH [email protected] 1 participant 1 message Oct 16, 2022

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.0-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Possible dependencies:

2ea89c7f7f7b ("KVM: nVMX: Make an event request when pending an MTF nested VM-Exit") 7709aba8f716 ("KVM: x86: Morph pending exceptions to pending VM-Exits at queue time") 28360f887068 ("KVM: x86: Evaluate ability to inject SMI/NMI/IRQ after potential VM-Exit") 6c593b5276e6 ("KVM: x86: Hoist nested event checks above event injection logic") 72c14e00bdc4 ("KVM: x86: Formalize blocking of nested pending exceptions") d4963e319f1f ("KVM: x86: Make kvm_queued_exception a properly named, visible struct") 593a5c2e3c12 ("KVM: nVMX: Unconditionally clear mtf_pending on nested VM-Exit") 5623f751bd9c ("KVM: x86: Treat #DBs from the emulator as fault-like (code and DR7.GD=1)") b9d44f9091ac ("KVM: nVMX: Prioritize TSS T-flag #DBs over Monitor Trap Flag") 8d178f460772 ("KVM: nVMX: Treat General Detect #DB (DR7.GD=1) as fault-like") eba9799b5a6e ("KVM: VMX: Drop bits 31:16 when shoving exception error code into VMCS")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 2ea89c7f7f7b192e32d1842dafc2e972cd14329b Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Wed, 21 Sep 2022 00:31:51 +0000
Subject: [PATCH] KVM: nVMX: Make an event request when pending an MTF nested
VM-Exit

Set KVM_REQ_EVENT when MTF becomes pending to ensure that KVM will run through inject_pending_event() and thus vmx_check_nested_events() prior to re-entering the guest.

MTF currently works by virtue of KVM's hack that calls kvm_check_nested_events() from kvm_vcpu_running(), but that hack will be removed in the near future. Until that call is removed, the patch introduces no real functional change.

Fixes 5ef8acbdd687 ("KVM: nVMX: Emulate MTF when performing instruction emulation")

Message-Id: <[email protected]>

arch/x86/kvm/vmx/nested.c +3 -0
index 85318d803f4f..3a080051a4ec 100644
@@ -6632,6 +6632,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
 	if (ret)
 		goto error_guest_mode;
 
+	if (vmx->nested.mtf_pending)
+		kvm_make_request(KVM_REQ_EVENT, vcpu);
+
 	return 0;
 
 error_guest_mode:
arch/x86/kvm/vmx/vmx.c +4 -2
index 94c314dc2393..9dba04b6b019 100644
@@ -1665,10 +1665,12 @@ static void vmx_update_emulated_instruction(struct kvm_vcpu *vcpu)
 	    (!vcpu->arch.exception.pending ||
 	     vcpu->arch.exception.vector == DB_VECTOR) &&
 	    (!vcpu->arch.exception_vmexit.pending ||
-	     vcpu->arch.exception_vmexit.vector == DB_VECTOR))
+	     vcpu->arch.exception_vmexit.vector == DB_VECTOR)) {
 		vmx->nested.mtf_pending = true;
-	else
+		kvm_make_request(KVM_REQ_EVENT, vcpu);
+	} else {
 		vmx->nested.mtf_pending = false;
+	}
 }
 
 static int vmx_skip_emulated_instruction(struct kvm_vcpu *vcpu)