Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752569AbdHQOaL (ORCPT ); Thu, 17 Aug 2017 10:30:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40892 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbdHQOaK (ORCPT ); Thu, 17 Aug 2017 10:30:10 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 10C297DCFA Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH v2 1/5] KVM: x86: Add return value to kvm_cpuid(). To: Yu Zhang , kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, xiaoguangrong@tencent.com, joro@8bytes.org 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> From: Paolo Bonzini Message-ID: Date: Thu, 17 Aug 2017 16:29:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <78090cb4-9a7b-dea0-c2b2-d266f242e6d6@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 17 Aug 2017 14:30:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 888 Lines: 33 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