diff mbox

[v2,2a/6] x86: Allow multiple cpu feature matches of lookup_feature

Message ID 4DAD6C9E.3090304@siemens.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka April 19, 2011, 11:06 a.m. 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 <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.

Comments

Glauber Costa April 27, 2011, 6:38 p.m. UTC | #1
On Tue, 2011-04-19 at 13:06 +0200, Jan Kiszka wrote:
> 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.

Yes, this patch is okay.

Actually, I did sent out something like this, maybe Marcelo applied only
part of the series?

Anyway, Jan's version is handy, please apply it.

> 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,


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,