]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: nSVM: Always use NextRIP as vmcb02's NextRIP after first L2 VMRUN
authorYosry Ahmed <yosry@kernel.org>
Wed, 25 Feb 2026 00:59:47 +0000 (00:59 +0000)
committerSean Christopherson <seanjc@google.com>
Wed, 4 Mar 2026 18:38:38 +0000 (10:38 -0800)
commit8d397582f6b5e9fbcf09781c7c934b4910e94a50
tree0f045dcd0f871661862359a4abb2425809a7c7f5
parente5cdd34b5f74c4a0c72fe43092192f347d999e77
KVM: nSVM: Always use NextRIP as vmcb02's NextRIP after first L2 VMRUN

For guests with NRIPS disabled, L1 does not provide NextRIP when running
an L2 with an injected soft interrupt, instead it advances the current RIP
before running it. KVM uses the current RIP as the NextRIP in vmcb02 to
emulate a CPU without NRIPS.

However, after L2 runs the first time, NextRIP will be updated by the CPU
and/or KVM, and the current RIP is no longer the correct value to use in
vmcb02.  Hence, after save/restore, use the current RIP if and only if a
nested run is pending, otherwise use NextRIP.  Give soft_int_next_rip the
same treatment, as it's the same logic, just for a narrower use case.

Fixes: cc440cdad5b7 ("KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE")
CC: stable@vger.kernel.org
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260225005950.3739782-6-yosry@kernel.org
[sean: give soft_int_next_rip the same treatment]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c