[PATCH v3 1/3] KVM: nVMX: Fill VM-Exit instruction length before saving pending event
From: Mahmoud Abumandour
Date: Mon Nov 16 2026 - 17:30:54 EST
Fill vmcs12's VM-Exit instruction length before calling
vmcs12_save_pending_event(), so that the length it saves for a software
exception isn't overwritten. Commit c3634d25fbee ("KVM: nVMX: Leave most
VM-Exit info fields unmodified on failed VM-Entry") moved the assignment
after the call.
L1 sees no difference since both lengths are read from vmcs02's VM-Exit
instruction length.
Link: https://lore.kernel.org/all/sashiko-outbox-179791@xxxxxxxxxx
Signed-off-by: Mahmoud Abumandour <ma.mandourr@xxxxxxxxx>
---
arch/x86/kvm/vmx/nested.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 1a98f28651..e8cc0fb308 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4741,6 +4741,9 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
* instead of reading the real value. */
vmcs12->vm_entry_intr_info_field &= ~INTR_INFO_VALID_MASK;
+ /* vmcs12_save_pending_event() may override this. */
+ vmcs12->vm_exit_instruction_len = exit_insn_len;
+
/*
* Transfer the event that L0 or L1 may wanted to inject into
* L2 to IDT_VECTORING_INFO_FIELD.
@@ -4749,7 +4752,6 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
vm_exit_reason, exit_intr_info);
vmcs12->vm_exit_intr_info = exit_intr_info;
- vmcs12->vm_exit_instruction_len = exit_insn_len;
vmcs12->vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
/*
--
2.25.1