Skip to content

Commit c8e612b

Browse files
committed
KVM: nSVM: Pass next RIP, not current RIP, for nested VM-Exit on emulation
Set "next_rip" in the emulation interception info passed to vendor code using the emulator context's "_eip", not "eip". "eip" holds RIP from the start of emulation, i.e. the RIP of the instruction that's being emulated, whereas _eip tracks the context's current position in decoding the code stream, which at the time of the intercept checks is effectively the RIP of the next instruction. Passing the current RIP as next_rip causes SVM to stuff the wrong value value into vmcb12->control.next_rip if a nested VM-Exit is generated, i.e. if L1 wants to intercept the instruction, and could result in L1 putting L2 into an infinite loop due to restarting L2 with the same RIP over and over. Fixes: 8a76d7f ("KVM: x86: Add x86 callback for intercept check") Link: https://lore.kernel.org/r/20250201015518.689704-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent f002a97 commit c8e612b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/emulate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static int emulator_check_intercept(struct x86_emulate_ctxt *ctxt,
478478
.src_bytes = ctxt->src.bytes,
479479
.dst_bytes = ctxt->dst.bytes,
480480
.ad_bytes = ctxt->ad_bytes,
481-
.next_rip = ctxt->eip,
481+
.next_rip = ctxt->_eip,
482482
};
483483

484484
return ctxt->ops->intercept(ctxt, &info, stage);

0 commit comments

Comments
 (0)