Skip to contentSkip to conversation

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

PATCH Applied Xiaoyao Li 3 participants 5 messages Feb 14, 2019 – Feb 18, 2019

Subsystems (3)
lore
Share & tools
lore

Xiaoyao Li

author
#0 lore raw

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.

Fixes ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function")
---
 arch/x86/kvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +2 -1
index 95d618045001..1aaef2d536bd 100644
@@ -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
maintainer Applied
#1 lore raw
Quoted 17 lines · Xiaoyao Li

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.

Fixes ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function")
---
 arch/x86/kvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +0 -0
index 95d618045001..1aaef2d536bd 100644

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

#2 lore raw
In reply to Xiaoyao Li
Quoted 3 lines · Xiaoyao Li

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

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")
---
 arch/x86/kvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +2 -1
index 95d618045001..1aaef2d536bd 100644
@@ -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
#3 lore raw
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Xiaoyao Li

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

s/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")
---
 arch/x86/kvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +2 -1
index 95d618045001..1aaef2d536bd 100644
@@ -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
author
#4 lore raw
Quoted 7 lines · linux.intel.com
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Xiaoyao Li

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

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")
---
 arch/x86/kvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +2 -1
index 95d618045001..1aaef2d536bd 100644
@@ -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