From patchwork Mon May 2 18:32:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 93698 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C93DAB6F64 for ; Tue, 3 May 2011 04:35:59 +1000 (EST) Received: from localhost ([::1]:38015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGxyP-0002wM-1u for incoming@patchwork.ozlabs.org; Mon, 02 May 2011 14:35:57 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGxwW-0000Fs-Ul for qemu-devel@nongnu.org; Mon, 02 May 2011 14:34:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QGxwQ-00057u-UN for qemu-devel@nongnu.org; Mon, 02 May 2011 14:34:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGxwQ-00057N-Jw for qemu-devel@nongnu.org; Mon, 02 May 2011 14:33:54 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p42IXqrA028783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 2 May 2011 14:33:52 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p42IXpiT009193; Mon, 2 May 2011 14:33:51 -0400 Received: from amt.cnet (vpn-10-54.rdu.redhat.com [10.11.10.54]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p42IXoXE031480; Mon, 2 May 2011 14:33:51 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id C2D6868A0E2; Mon, 2 May 2011 15:32:55 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p42IWr9k003539; Mon, 2 May 2011 15:32:53 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Mon, 2 May 2011 15:32:38 -0300 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/9] x86: Allow multiple cpu feature matches of lookup_feature X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka 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 Signed-off-by: Marcelo Tosatti --- target-i386/cpuid.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) 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,