All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Marcelo Tosatti <mtosatti@redhat.com>,
	Glauber Costa <glommer@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Avi Kivity <avi@redhat.com>
Subject: [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature
Date: Tue, 19 Apr 2011 13:06:06 +0200	[thread overview]
Message-ID: <4DAD6C9E.3090304@siemens.com> (raw)
In-Reply-To: <4DAAC8B9.7020708@web.de>

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 <jan.kiszka@siemens.com>
---
 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,
-- 
1.7.1

WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Marcelo Tosatti <mtosatti@redhat.com>,
	Glauber Costa <glommer@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature
Date: Tue, 19 Apr 2011 13:06:06 +0200	[thread overview]
Message-ID: <4DAD6C9E.3090304@siemens.com> (raw)
In-Reply-To: <4DAAC8B9.7020708@web.de>

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 <jan.kiszka@siemens.com>
---
 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,
-- 
1.7.1

  reply	other threads:[~2011-04-19 11:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-16 22:10 [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2011-04-16 22:10 ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 1/6] kvm: use kernel-provided para_features instead of statically coming up with new capabilities Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 2/6] kvm: add kvmclock to its second bit Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-17 11:02   ` Jan Kiszka
2011-04-17 11:02     ` [Qemu-devel] " Jan Kiszka
2011-04-19 11:06     ` Jan Kiszka [this message]
2011-04-19 11:06       ` [Qemu-devel] [PATCH v2 2a/6] x86: Allow multiple cpu feature matches of lookup_feature Jan Kiszka
2011-04-27 18:38       ` Glauber Costa
2011-04-27 18:38         ` [Qemu-devel] " Glauber Costa
2011-04-19 11:06     ` [PATCH v2 2b/6] kvm: add kvmclock to its second bit Jan Kiszka
2011-04-19 11:06       ` [Qemu-devel] " Jan Kiszka
2011-04-16 22:10 ` [PATCH 3/6] kvm: create kvmclock when one of the flags are present Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 4/6] Break up user and system cpu_interrupt implementations Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 5/6] Redirect cpu_interrupt to callback handler Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 22:10 ` [PATCH 6/6] kvm: Install specialized interrupt handler Marcelo Tosatti
2011-04-16 22:10   ` [Qemu-devel] " Marcelo Tosatti
2011-04-16 23:57 ` [PATCH 0/6] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
2011-04-16 23:57   ` [Qemu-devel] " Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DAD6C9E.3090304@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=glommer@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.