Skip to content

Commit 98ae70c

Browse files
Xiaoyao Libonzini
authored andcommitted
kvm: vmx: Fix entry number check for add_atomic_switch_msr()
Commit ca83b4a ("x86/KVM/VMX: Add find_msr() helper function") introduces the helper function find_msr(), which returns -ENOENT when not find the msr in vmx->msr_autoload.guest/host. Correct checking contion of no more available entry in vmx->msr_autoload. Fixes: ca83b4a ("x86/KVM/VMX: Add find_msr() helper function") Cc: stable@vger.kernel.org Signed-off-by: Xiaoyao Li <xiaoyao.li@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent c112b5f commit 98ae70c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
863863
if (!entry_only)
864864
j = find_msr(&m->host, msr);
865865

866-
if (i == NR_AUTOLOAD_MSRS || j == NR_AUTOLOAD_MSRS) {
866+
if ((i < 0 && m->guest.nr == NR_AUTOLOAD_MSRS) ||
867+
(j < 0 && m->host.nr == NR_AUTOLOAD_MSRS)) {
867868
printk_once(KERN_WARNING "Not enough msr switch entries. "
868869
"Can't add msr %x\n", msr);
869870
return;

0 commit comments

Comments
 (0)