From: Paolo Bonzini Subject: Re: [PATCH v2 1/5] KVM: x86: Add return value to kvm_cpuid(). Date: Thu, 17 Aug 2017 16:29:38 +0200 Message-ID: References: <1502999558-2517-1-git-send-email-yu.c.zhang@linux.intel.com> <1502999558-2517-2-git-send-email-yu.c.zhang@linux.intel.com> <9deed5e8-52e9-8634-611f-553840a43f1a@redhat.com> <1493b2f0-0e6e-2dac-5ae3-1aed3595faed@linux.intel.com> <61c178fa-826f-8f30-d34d-23fe6ac74c13@redhat.com> <78090cb4-9a7b-dea0-c2b2-d266f242e6d6@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, xiaoguangrong@tencent.com, joro@8bytes.org To: Yu Zhang , kvm@vger.kernel.org Return-path: In-Reply-To: <78090cb4-9a7b-dea0-c2b2-d266f242e6d6@linux.intel.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 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