Skip to content

Commit 127ccae

Browse files
yosrym93sean-jc
authored andcommitted
KVM: nSVM: Always use vmcb01 in VMLOAD/VMSAVE emulation
Commit cc3ed80 ("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: cc3ed80 ("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>
1 parent f00ccde commit 127ccae

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

arch/x86/kvm/svm/svm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,12 +2122,13 @@ static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload)
21222122

21232123
ret = kvm_skip_emulated_instruction(vcpu);
21242124

2125+
/* KVM always performs VMLOAD/VMSAVE on VMCB01 (see __svm_vcpu_run()) */
21252126
if (vmload) {
2126-
svm_copy_vmloadsave_state(svm->vmcb, vmcb12);
2127+
svm_copy_vmloadsave_state(svm->vmcb01.ptr, vmcb12);
21272128
svm->sysenter_eip_hi = 0;
21282129
svm->sysenter_esp_hi = 0;
21292130
} else {
2130-
svm_copy_vmloadsave_state(vmcb12, svm->vmcb);
2131+
svm_copy_vmloadsave_state(vmcb12, svm->vmcb01.ptr);
21312132
}
21322133

21332134
kvm_vcpu_unmap(vcpu, &map);

0 commit comments

Comments
 (0)