]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: nSVM: Always use vmcb01 in VMLOAD/VMSAVE emulation
authorYosry Ahmed <yosry.ahmed@linux.dev>
Sat, 10 Jan 2026 00:48:18 +0000 (00:48 +0000)
committerSean Christopherson <seanjc@google.com>
Wed, 14 Jan 2026 21:39:33 +0000 (13:39 -0800)
Commit cc3ed80ae69f ("KVM: nSVM: always use vmcb01 to for vmsave/vmload
of guest state") made KVM always use vmcb01 for the fields controlled by
VMSAVE/VMLOAD, but it missed updating the VMLOAD/VMSAVE emulation code
to always use vmcb01.

As a result, if VMSAVE/VMLOAD is executed by an L2 guest and is not
intercepted by L1, KVM will mistakenly use vmcb02. Always use vmcb01
instead of the current VMCB.

Fixes: cc3ed80ae69f ("KVM: nSVM: always use vmcb01 to for vmsave/vmload of guest state")
Cc: Maxim Levitsky <mlevitsk@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20260110004821.3411245-2-yosry.ahmed@linux.dev
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c

index e454ae095cf7c7f8bb6c56c6133734ceaf5b90b6..f1a5b61bdb5bc56e8c86b0674195ca59a30b13ad 100644 (file)
@@ -2122,12 +2122,13 @@ static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload)
 
        ret = kvm_skip_emulated_instruction(vcpu);
 
+       /* KVM always performs VMLOAD/VMSAVE on VMCB01 (see __svm_vcpu_run()) */
        if (vmload) {
-               svm_copy_vmloadsave_state(svm->vmcb, vmcb12);
+               svm_copy_vmloadsave_state(svm->vmcb01.ptr, vmcb12);
                svm->sysenter_eip_hi = 0;
                svm->sysenter_esp_hi = 0;
        } else {
-               svm_copy_vmloadsave_state(vmcb12, svm->vmcb);
+               svm_copy_vmloadsave_state(vmcb12, svm->vmcb01.ptr);
        }
 
        kvm_vcpu_unmap(vcpu, &map);