From patchwork Tue Apr 19 11:06:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 717841 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3JB6DNW008226 for ; Tue, 19 Apr 2011 11:06:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754686Ab1DSLGK (ORCPT ); Tue, 19 Apr 2011 07:06:10 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:47833 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754616Ab1DSLGJ (ORCPT ); Tue, 19 Apr 2011 07:06:09 -0400 Received: from smtp07.web.de ( [172.20.5.215]) by fmmailgate01.web.de (Postfix) with ESMTP id 6E40718C32DB2; Tue, 19 Apr 2011 13:06:08 +0200 (CEST) Received: from [88.66.126.216] (helo=mchn199C.mchp.siemens.de) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1QC8ky-0000hw-00; Tue, 19 Apr 2011 13:06:08 +0200 Message-ID: <4DAD6C9E.3090304@siemens.com> Date: Tue, 19 Apr 2011 13:06:06 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Marcelo Tosatti , Glauber Costa CC: Anthony Liguori , qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity Subject: [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature References: <8f53372986d7726c02fe0147e45be504a5208edc.1302991808.git.mtosatti@redhat.com> <4DAAC8B9.7020708@web.de> In-Reply-To: <4DAAC8B9.7020708@web.de> X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX18Pgwjj4FVxHYT4SEjJPB6tOE9kSo3dk4Gjm8Eq 62V8o65R4n/5whUHJm+dVRSuPF9UGRYH4ZjiQ2g56x0yE8dFLO YBA+8xMok= Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 19 Apr 2011 11:06:18 +0000 (UTC) kvmclock is represented by two feature bits. Therefore, lookup_feature needs to continue its search even after the first match. Enhance it accordingly and switch to a bool return type at this chance. Signed-off-by: Jan Kiszka --- target-i386/cpuid.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) Glauber, could you check/ack this? Marcelo, please respin the series afterward. I'd like to see all bits upstream and merged back into qemu-kvm to proceed with switching the latter to upstream's kvm infrastructure. diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index 814d13e..0ac592f 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -182,20 +182,22 @@ static int altcmp(const char *s, const char *e, const char *altstr) } /* search featureset for flag *[s..e), if found set corresponding bit in - * *pval and return success, otherwise return zero + * *pval and return true, otherwise return false */ -static int lookup_feature(uint32_t *pval, const char *s, const char *e, - const char **featureset) +static bool lookup_feature(uint32_t *pval, const char *s, const char *e, + const char **featureset) { uint32_t mask; const char **ppc; + bool found = false; - for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) + for (mask = 1, ppc = featureset; mask; mask <<= 1, ++ppc) { if (*ppc && !altcmp(s, e, *ppc)) { *pval |= mask; - break; + found = true; } - return (mask ? 1 : 0); + } + return found; } static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,