Skip to contentSkip to conversation

KVM: x86: Check .flags in kvm_cpuid_check_equal() too

PATCH Applied Vitaly Kuznetsov 2 participants 2 messages Jan 26, 2022

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

PATCH 1/1 KVM: x86: Check .flags in kvm_cpuid_check_equal() too

kvm_cpuid_check_equal() checks for the (full) equality of the supplied CPUID data so .flags need to be checked too.

Fixes c6617c61e8fe ("KVM: x86: Partially allow KVM_SET_CPUID{,2} after KVM_RUN")
---
 arch/x86/kvm/cpuid.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kvm/cpuid.c +1 -0
index 89d7822a8f5b..ddfd97f62ba8 100644
@@ -133,6 +133,7 @@ static int kvm_cpuid_check_equal(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2
 		orig = &vcpu->arch.cpuid_entries[i];
 		if (e2[i].function != orig->function ||
 		    e2[i].index != orig->index ||
+		    e2[i].flags != orig->flags ||
 		    e2[i].eax != orig->eax || e2[i].ebx != orig->ebx ||
 		    e2[i].ecx != orig->ecx || e2[i].edx != orig->edx)
 			return -EINVAL;
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 15 lines · Vitaly Kuznetsov

kvm_cpuid_check_equal() checks for the (full) equality of the supplied CPUID data so .flags need to be checked too.

Fixes c6617c61e8fe ("KVM: x86: Partially allow KVM_SET_CPUID{,2} after KVM_RUN")
---
  arch/x86/kvm/cpuid.c | 1 +
  1 file changed, 1 insertion(+)
arch/x86/kvm/cpuid.c +0 -0
index 89d7822a8f5b..ddfd97f62ba8 100644

arch/x86/kvm/cpuid.c static int kvm_cpuid_check_equal(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 · line 139

Quoted 7 lines
arch/x86/kvm/cpuid.c +1 -0
@@ -133,6 +133,7 @@ static int kvm_cpuid_check_equal(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2
  		orig = &vcpu->arch.cpuid_entries[i];
  		if (e2[i].function != orig->function ||
  		    e2[i].index != orig->index ||
+		    e2[i].flags != orig->flags ||
  		    e2[i].eax != orig->eax || e2[i].ebx != orig->ebx ||
  		    e2[i].ecx != orig->ecx || e2[i].edx != orig->edx)
  			return -EINVAL;

Queued, with Cc to stable.

Paolo