Re: [PATCH v2 1/5] KVM: x86: Add return value to kvm_cpuid().

From: Paolo Bonzini
Date: Thu Aug 17 2017 - 10:30:45 EST


On 17/08/2017 15:20, Yu Zhang wrote:
>>
>
> OK. And to return 0 for eax/ebx/ecx/edx if check_cpuid_limit() is also
> to be omitted,
> I'd better refactor this patch and move the "out:" before the if
> statement. :-)
>
> best = check_cpuid_limit(vcpu, function, index);
> }
>
> +out:
> if (best) {
> *eax = best->eax;
> *ebx = best->ebx;
> @@ -887,7 +888,6 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32
> *ebx,
> } else
> *eax = *ebx = *ecx = *edx = 0;
>
> -out:
> trace_kvm_cpuid(function, *eax, *ebx, *ecx, *edx, entry_found);
> return entry_found;
> }
>
> And for all get_cpuid() callers which is testing the existence of a
> feature, we do not need to
> check the return value, just checking the flag in the register should be
> fine, correct?

Yes, correct!

Paolo