Skip to contentSkip to conversation

KVM: selftests: fix bit test in is_steal_time_supported()

PATCH In review Dan Carpenter 2 participants 2 messages Jul 19, 2022

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

PATCH 1/1 KVM: selftests: fix bit test in is_steal_time_supported()

The KVM_FEATURE_STEAL_TIME (5) define is the BIT() value so we need to do shift for this to work correctly.

Fixes 998016048221 ("KVM: selftests: Convert steal_time away from VCPU_ID")
---
 tools/testing/selftests/kvm/steal_time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/steal_time.c +1 -1
index d122f1e05cdd..b89f0cfa2dc3 100644
@@ -62,7 +62,7 @@ static bool is_steal_time_supported(struct kvm_vcpu *vcpu)
 {
 	struct kvm_cpuid_entry2 *cpuid = kvm_get_supported_cpuid_entry(KVM_CPUID_FEATURES);
 
-	return cpuid && (cpuid->eax & KVM_FEATURE_STEAL_TIME);
+	return cpuid && (cpuid->eax & (1 << KVM_FEATURE_STEAL_TIME));
 }
 
 static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i)
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 14 lines · Dan Carpenter

The KVM_FEATURE_STEAL_TIME (5) define is the BIT() value so we need to do shift for this to work correctly.

Fixes 998016048221 ("KVM: selftests: Convert steal_time away from VCPU_ID")
---
  tools/testing/selftests/kvm/steal_time.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/steal_time.c +0 -0
index d122f1e05cdd..b89f0cfa2dc3 100644

tools/testing/selftests/kvm/steal_time.c static bool is_steal_time_supported(struct kvm_vcpu *vcpu) · line 68

Quoted 8 lines
tools/testing/selftests/kvm/steal_time.c +1 -1
@@ -62,7 +62,7 @@ static bool is_steal_time_supported(struct kvm_vcpu *vcpu)
  {
  	struct kvm_cpuid_entry2 *cpuid = kvm_get_supported_cpuid_entry(KVM_CPUID_FEATURES);
 
-	return cpuid && (cpuid->eax & KVM_FEATURE_STEAL_TIME);
+	return cpuid && (cpuid->eax & (1 << KVM_FEATURE_STEAL_TIME));
  }
 
  static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i)

This is already fixed in kvm/queue, but also actually the Fixes tag would have to date back to commit 94c4b76b88d4 ("KVM: selftests: Introduce steal-time test", 2020-03-16).

Paolo