[PATCH] x86/svm: mandatory update VMCB nextrip for soft interrupts

Chunjie Zhu <[email protected]> Thu, 6 Aug 2026 03:17:24 +0000
Newsgroups gmane.comp.emulators.xen.devel
Message-ID <[email protected]>
Signed-off-by: Chunjie Zhu <[email protected]>
---
 xen/arch/x86/hvm/svm/nestedsvm.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index b06124c2c9ed..815713b8b506 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -449,7 +449,14 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
     n2vmcb->virt_ext.bytes =
         n1vmcb->virt_ext.bytes | ns_vmcb->virt_ext.bytes;
 
-    /* NextRIP - only evaluated on #VMEXIT. */
+    /* next_rip is consumed on VMRUN as the return address pushed on the
+     * stack·for·injected·soft·exceptions/interrupts. This assignment
+     * statement must be enforced, otherwise, it might cause vcpu wedge.
+     *
+     * APM Vol.2 Event Injection does not specifies what happens if NEXTRIP
+     * holds an invalid/garbage value.
+     */
+    n2vmcb->nextrip = ns_vmcb->nextrip;
 
     /*
      * VMCB Save State Area
-- 
2.34.1