From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v2] KVM: Refactor and simplify kvm_dev_ioctl_get_supported_cpuid Date: Mon, 28 Nov 2011 12:08:47 +0200 Message-ID: <4ED35DAF.7060401@redhat.com> References: <1322472029-22856-1-git-send-email-levinsasha928@gmail.com> <4ED359DE.6060005@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Marcelo Tosatti To: Sasha Levin Return-path: Received: from mx1.redhat.com ([209.132.183.28]:14046 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752591Ab1K1KIv (ORCPT ); Mon, 28 Nov 2011 05:08:51 -0500 In-Reply-To: <4ED359DE.6060005@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11/28/2011 11:52 AM, Avi Kivity wrote: > On 11/28/2011 11:20 AM, Sasha Levin wrote: > > This patch cleans and simplifies kvm_dev_ioctl_get_supported_cpuid by using a table > > instead of duplicating code as Avi suggested. > > > > This patch also fixes a bug where kvm_dev_ioctl_get_supported_cpuid would return > > -E2BIG when amount of entries passed was just right. > > > > do_cpuid_1_ent(entry, function, index); > > ++*nent; > > > > @@ -275,7 +282,10 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, > > > > entry->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC; > > entry->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT; > > - for (t = 1; t < times && *nent < maxnent; ++t) { > > + for (t = 1; t < times; ++t) { > > + if (*nent >= maxnent) > > + goto out; > > + > > do_cpuid_1_ent(&entry[t], function, 0); > > entry[t].flags |= KVM_CPUID_FLAG_STATEFUL_FUNC; > > ++*nent; > > Please move the check into do_cpuid_1_ent(); it's more consistent. > > Given that do_cpuid_1_ent() doesn't receive nent/maxent, I applied this; thanks. -- error compiling committee.c: too many arguments to function