mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: nSVM: Set NMI_VECTOR in synthesized NMI exit_int_info
@ 2026-10-28 13:26 Jim Mattson
  2026-10-28 13:26 ` [PATCH 2/2] KVM: SVM: Set NMI_VECTOR in event_inj in svm_inject_nmi() Jim Mattson
  2026-10-28 17:11 ` [PATCH 1/2] KVM: nSVM: Set NMI_VECTOR in synthesized NMI exit_int_info Sean Christopherson
  0 siblings, 2 replies; 3+ messages in thread
From: Jim Mattson @ 2026-10-28 13:26 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: Jim Mattson, Yosry Ahmed, kvm, linux-kernel

Include NMI_VECTOR (2) in the vector field when synthesizing exit_int_info
for a pending injected NMI in nested_save_pending_event_to_vmcb12(),
matching nested VMX's idt_vectoring_info_field synthesis and the APM.

Per AMD's APM (Vol. 2, "Intercepts During IDT Interrupt Delivery", Figure
"EXITINTINFO" and Table "Guest Exception or Interrupt Types", and "Event
Injection"), bits 7:0 of EXITINTINFO hold the 8-bit IDT vector of the
interrupt or exception, and injected events are recorded in EXITINTINFO as
though they had occurred normally in the guest.  Although hardware ignores
EVENTINJ.VECTOR on VMRUN when TYPE is NMI, EXITINTINFO records vector 2
(#NMI) if a #VMEXIT occurs during NMI delivery.

Commit 36e2e98363e6 ("KVM: nSVM: synthesize correct EXITINTINFO on vmexit")
replaced the raw copy of vmcb02->control.exit_int_info (where hardware
populates vector 2) with nested_vmcb_save_pending_event(), now
nested_save_pending_event_to_vmcb12(), which sets only SVM_EVTINJ_VALID |
SVM_EVTINJ_TYPE_NMI and leaves the vector field as 0.  As a result, L1
hypervisors that check EXITINTINFO.VECTOR == 2 for NMIs (e.g. FreeBSD's
bhyve) or inspect the vector field of exit_int_info observe an invalid
vector 0 on nested #VMEXIT.

Fixes: 36e2e98363e6 ("KVM: nSVM: synthesize correct EXITINTINFO on vmexit")
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/svm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index af0ef678433d..9b62113f0cf6 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -673,7 +673,7 @@ static void nested_save_pending_event_to_vmcb12(struct vcpu_svm *svm,
 		}
 
 	} else if (vcpu->arch.nmi_injected) {
-		exit_int_info = SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_NMI;
+		exit_int_info = SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_NMI | NMI_VECTOR;
 
 	} else if (vcpu->arch.interrupt.injected) {
 		nr = vcpu->arch.interrupt.nr;

base-commit: dea4f6380f4ec96e8f3b0aaf2343764bd0d25ef4
-- 
2.56.0.307.g5fe7bd680c-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-28 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 13:26 [PATCH 1/2] KVM: nSVM: Set NMI_VECTOR in synthesized NMI exit_int_info Jim Mattson
2026-10-28 13:26 ` [PATCH 2/2] KVM: SVM: Set NMI_VECTOR in event_inj in svm_inject_nmi() Jim Mattson
2026-10-28 17:11 ` [PATCH 1/2] KVM: nSVM: Set NMI_VECTOR in synthesized NMI exit_int_info Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®