Commit 85374e1d authored by Xiaoyao Li's avatar Xiaoyao Li Committed by Greg Kroah-Hartman

kvm: vmx: Fix entry number check for add_atomic_switch_msr()

commit 98ae70cc upstream.

Commit ca83b4a7 ("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: ca83b4a7 ("x86/KVM/VMX: Add find_msr() helper function")
Signed-off-by: default avatarXiaoyao Li <>
Signed-off-by: default avatarPaolo Bonzini <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent dbb8a5c2
......@@ -2779,7 +2779,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
if (!entry_only)
j = find_msr(&m->host, msr);
if ((i < 0 && m-> == NR_AUTOLOAD_MSRS) ||
(j < 0 && m-> == NR_AUTOLOAD_MSRS)) {
printk_once(KERN_WARNING "Not enough msr switch entries. "
"Can't add msr %x\n", msr);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment