Skip to contentSkip to conversation

KVM: clean up the unused argument

PATCH Applied [email protected] 3 participants 4 messages Mar 13, 2021 – Mar 26, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: clean up the unused argument

From: Haiwei Li <[email protected]>

kvm_msr_ignored_check function never uses vcpu argument. Clean up the function and invokers.

---
 arch/x86/kvm/x86.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/x86/kvm/x86.c +4 -5
index 012d5df..27e9ee8 100644
@@ -271,8 +271,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
  * When called, it means the previous get/set msr reached an invalid msr.
  * Return true if we want to ignore/silent this failed msr access.
  */
-static bool kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,
-				  u64 data, bool write)
+static bool kvm_msr_ignored_check(u32 msr, u64 data, bool write)
 {
 	const char *op = write ? "wrmsr" : "rdmsr";
 
@@ -1447,7 +1446,7 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
 	if (r == KVM_MSR_RET_INVALID) {
 		/* Unconditionally clear the output for simplicity */
 		*data = 0;
-		if (kvm_msr_ignored_check(vcpu, index, 0, false))
+		if (kvm_msr_ignored_check(index, 0, false))
 			r = 0;
 	}
 
@@ -1613,7 +1612,7 @@ static int kvm_set_msr_ignored_check(struct kvm_vcpu *vcpu,
 	int ret = __kvm_set_msr(vcpu, index, data, host_initiated);
 
 	if (ret == KVM_MSR_RET_INVALID)
-		if (kvm_msr_ignored_check(vcpu, index, data, true))
+		if (kvm_msr_ignored_check(index, data, true))
 			ret = 0;
 
 	return ret;
@@ -1651,7 +1650,7 @@ static int kvm_get_msr_ignored_check(struct kvm_vcpu *vcpu,
 	if (ret == KVM_MSR_RET_INVALID) {
 		/* Unconditionally clear *data for simplicity */
 		*data = 0;
-		if (kvm_msr_ignored_check(vcpu, index, 0, false))
+		if (kvm_msr_ignored_check(index, 0, false))
 			ret = 0;
 	}
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

This looks OK. The use of vcpu argument is removed in commit d383b3146d80 (KVM: x86: Fix NULL dereference at kvm_msr_ignored_check())

Quoted 52 lines · On 2021/3/13 13:10, [email protected] wrote:

From: Haiwei Li <[email protected]>

kvm_msr_ignored_check function never uses vcpu argument. Clean up the function and invokers.

---
 arch/x86/kvm/x86.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/x86/kvm/x86.c +4 -5
index 012d5df..27e9ee8 100644
@@ -271,8 +271,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
  * When called, it means the previous get/set msr reached an invalid msr.
  * Return true if we want to ignore/silent this failed msr access.
  */
-static bool kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,
-				  u64 data, bool write)
+static bool kvm_msr_ignored_check(u32 msr, u64 data, bool write)
 {
 	const char *op = write ? "wrmsr" : "rdmsr";
 
@@ -1447,7 +1446,7 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
 	if (r == KVM_MSR_RET_INVALID) {
 		/* Unconditionally clear the output for simplicity */
 		*data = 0;
-		if (kvm_msr_ignored_check(vcpu, index, 0, false))
+		if (kvm_msr_ignored_check(index, 0, false))
 			r = 0;
 	}
 
@@ -1613,7 +1612,7 @@ static int kvm_set_msr_ignored_check(struct kvm_vcpu *vcpu,
 	int ret = __kvm_set_msr(vcpu, index, data, host_initiated);
 
 	if (ret == KVM_MSR_RET_INVALID)
-		if (kvm_msr_ignored_check(vcpu, index, data, true))
+		if (kvm_msr_ignored_check(index, data, true))
 			ret = 0;
 
 	return ret;
@@ -1651,7 +1650,7 @@ static int kvm_get_msr_ignored_check(struct kvm_vcpu *vcpu,
 	if (ret == KVM_MSR_RET_INVALID) {
 		/* Unconditionally clear *data for simplicity */
 		*data = 0;
-		if (kvm_msr_ignored_check(vcpu, index, 0, false))
+		if (kvm_msr_ignored_check(index, 0, false))
 			ret = 0;
 	}
 
author
#2 lore raw

Kindly ping. :)

Quoted 59 lines · Keqian Zhu

This looks OK. The use of vcpu argument is removed in commit d383b3146d80 (KVM: x86: Fix NULL dereference at kvm_msr_ignored_check())

Quoted 52 lines · On 2021/3/13 13:10, [email protected] wrote:

From: Haiwei Li <[email protected]>

kvm_msr_ignored_check function never uses vcpu argument. Clean up the function and invokers.

---
 arch/x86/kvm/x86.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
arch/x86/kvm/x86.c +4 -5
index 012d5df..27e9ee8 100644
@@ -271,8 +271,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
  * When called, it means the previous get/set msr reached an invalid msr.
  * Return true if we want to ignore/silent this failed msr access.
  */
-static bool kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,
-                               u64 data, bool write)
+static bool kvm_msr_ignored_check(u32 msr, u64 data, bool write)
 {
      const char *op = write ? "wrmsr" : "rdmsr";
 
@@ -1447,7 +1446,7 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
      if (r == KVM_MSR_RET_INVALID) {
              /* Unconditionally clear the output for simplicity */
              *data = 0;
-             if (kvm_msr_ignored_check(vcpu, index, 0, false))
+             if (kvm_msr_ignored_check(index, 0, false))
                      r = 0;
      }
 
@@ -1613,7 +1612,7 @@ static int kvm_set_msr_ignored_check(struct kvm_vcpu *vcpu,
      int ret = __kvm_set_msr(vcpu, index, data, host_initiated);
 
      if (ret == KVM_MSR_RET_INVALID)
-             if (kvm_msr_ignored_check(vcpu, index, data, true))
+             if (kvm_msr_ignored_check(index, data, true))
                      ret = 0;
 
      return ret;
@@ -1651,7 +1650,7 @@ static int kvm_get_msr_ignored_check(struct kvm_vcpu *vcpu,
      if (ret == KVM_MSR_RET_INVALID) {
              /* Unconditionally clear *data for simplicity */
              *data = 0;
-             if (kvm_msr_ignored_check(vcpu, index, 0, false))
+             if (kvm_msr_ignored_check(index, 0, false))
                      ret = 0;
      }
 
maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 9 lines · On 13/03/21 06:10, [email protected] wrote:

From: Haiwei Li <[email protected]>

kvm_msr_ignored_check function never uses vcpu argument. Clean up the function and invokers.

---
  arch/x86/kvm/x86.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)

Queued, thanks.

Paolo

Quoted 42 lines
arch/x86/kvm/x86.c +4 -5
index 012d5df..27e9ee8 100644
@@ -271,8 +271,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
   * When called, it means the previous get/set msr reached an invalid msr.
   * Return true if we want to ignore/silent this failed msr access.
   */
-static bool kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,
-				  u64 data, bool write)
+static bool kvm_msr_ignored_check(u32 msr, u64 data, bool write)
  {
  	const char *op = write ? "wrmsr" : "rdmsr";
 
@@ -1447,7 +1446,7 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
  	if (r == KVM_MSR_RET_INVALID) {
  		/* Unconditionally clear the output for simplicity */
  		*data = 0;
-		if (kvm_msr_ignored_check(vcpu, index, 0, false))
+		if (kvm_msr_ignored_check(index, 0, false))
  			r = 0;
  	}
 
@@ -1613,7 +1612,7 @@ static int kvm_set_msr_ignored_check(struct kvm_vcpu *vcpu,
  	int ret = __kvm_set_msr(vcpu, index, data, host_initiated);
 
  	if (ret == KVM_MSR_RET_INVALID)
-		if (kvm_msr_ignored_check(vcpu, index, data, true))
+		if (kvm_msr_ignored_check(index, data, true))
  			ret = 0;
 
  	return ret;
@@ -1651,7 +1650,7 @@ static int kvm_get_msr_ignored_check(struct kvm_vcpu *vcpu,
  	if (ret == KVM_MSR_RET_INVALID) {
  		/* Unconditionally clear *data for simplicity */
  		*data = 0;
-		if (kvm_msr_ignored_check(vcpu, index, 0, false))
+		if (kvm_msr_ignored_check(index, 0, false))
  			ret = 0;
  	}