kvm: vmx: Fix entry nubmer check for add_atomic_switch_msr()
PATCH 1/1 kvm: vmx: Fix entry nubmer check for add_atomic_switch_msr()
Commit ca83b4a7f2d068da79a0 ("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.
--- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +2 -1
@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,if (!entry_only) j =find_msr (&m->host, msr); -if (i ==NR_AUTOLOAD_MSRS || j ==NR_AUTOLOAD_MSRS ) { +if ((i <0 && m->guest.nr ==NR_AUTOLOAD_MSRS ) || + (j <0 && m->host.nr ==NR_AUTOLOAD_MSRS )) {printk_once (KERN_WARNING "Not enough msr switch entries. " "Can't add msr %x\n" , msr);return ;
Signature · 1 line
2.19.1
Quoted 17 lines · Xiaoyao Li
Commit
ca83b4a7f2d068da79a0("x86/KVM/VMX: Addfind_msr()helper function") introduces the helper functionfind_msr(), which returns-ENOENTwhen not find the msr in vmx->msr_autoload.guest/host. Correct checking contion of no more available entry invmx->msr_autoload.Fixes ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function")Signed-off-by Xiaoyao Li <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +0
-0
arch/x86/kvm/vmx/vmx.c static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr, · line 870
Quoted 9 lines
arch/x86/kvm/vmx/vmx.c +2
-1@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,if (!entry_only) j =find_msr (&m->host, msr); -if (i ==NR_AUTOLOAD_MSRS || j ==NR_AUTOLOAD_MSRS ) { +if ((i <0 && m->guest.nr ==NR_AUTOLOAD_MSRS ) || + (j <0 && m->host.nr ==NR_AUTOLOAD_MSRS )) {printk_once (KERN_WARNING "Not enough msr switch entries. " "Can't add msr %x\n" , msr);return ;
Queued, thanks.
Paolo
Quoted 3 lines · Xiaoyao Li
Commit
ca83b4a7f2d068da79a0("x86/KVM/VMX: Addfind_msr()helper function") introduces the helper functionfind_msr(), which returns-ENOENTwhen not find the msr in vmx->msr_autoload.guest/host. Correct checking contion
s/not find/cannot find/
s/contion/condition/ ?
Quoted 25 lines
of no more available entry in
vmx->msr_autoload.Fixes ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function")Signed-off-by Xiaoyao Li <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +2
-1@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,if (!entry_only) j =find_msr (&m->host, msr); -if (i ==NR_AUTOLOAD_MSRS || j ==NR_AUTOLOAD_MSRS ) { +if ((i <0 && m->guest.nr ==NR_AUTOLOAD_MSRS ) || + (j <0 && m->host.nr ==NR_AUTOLOAD_MSRS )) {printk_once (KERN_WARNING "Not enough msr switch entries. " "Can't add msr %x\n" , msr);return ;Signature · 1 line
2.19.1
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Xiaoyao Li
Commit
ca83b4a7f2d068da79a0("x86/KVM/VMX: Addfind_msr()helper function") introduces the helper functionfind_msr(), which returns-ENOENTwhen not find the msr in vmx->msr_autoload.guest/host. Correct checking contions/not find/cannot find/
s/contion/condition/ ?
Hi Paolo,
Could you correct these typos in KVM tree or when sending a PR?
Quoted 26 lines
Quoted 26 lines
of no more available entry in
vmx->msr_autoload.Fixes ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function")Signed-off-by Xiaoyao Li <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +2
-1@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx,unsigned msr, if (!entry_only) j =find_msr (&m->host, msr); -if (i ==NR_AUTOLOAD_MSRS || j ==NR_AUTOLOAD_MSRS ) { +if ((i <0 && m->guest.nr ==NR_AUTOLOAD_MSRS ) || + (j <0 && m->host.nr ==NR_AUTOLOAD_MSRS )) {printk_once (KERN_WARNING "Not enough msr switch entries. " "Can't add msr %x\n" , msr);return;
Signature · 1 line
2.19.1
Quoted 7 lines · linux.intel.com
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Xiaoyao Li
Commit
ca83b4a7f2d068da79a0("x86/KVM/VMX: Addfind_msr()helper function")
introduces the helper functionfind_msr(), which returns-ENOENTwhen not find the msr in vmx->msr_autoload.guest/host. Correct checking contion
Quoted 7 lines
Quoted 3 lines
s/not find/cannot find/
s/contion/condition/ ?Hi Paolo,
Could you correct these typos in KVM tree or when sending a PR?
Please disregard this. I just noticed tha this patch had been merged into mainline.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
of no more available entry in
vmx->msr_autoload.Fixes ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function")Signed-off-by Xiaoyao Li <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +2
-1@@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr, if (!entry_only) j = find_msr(&m->host, msr); -if (i ==NR_AUTOLOAD_MSRS || j ==NR_AUTOLOAD_MSRS ) { +if ((i <0 && m->guest.nr ==NR_AUTOLOAD_MSRS ) || + (j <0 && m->host.nr ==NR_AUTOLOAD_MSRS )) { printk_once(KERN_WARNING "Not enough msr switch entries. "arch/x86/kvm/vmx/vmx.c +0
-0"Can't add msr %x\n", msr);return ;Signature · 1 line
2.19.1