All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] linux-user: ppc64: fix ARCH_206 bit in AT_HWCAP
@ 2016-09-21  9:57 Michael Walle
  2016-09-21 10:15 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Walle @ 2016-09-21  9:57 UTC (permalink / raw)
  To: Riku Voipio
  Cc: Alexander Graf, qemu-ppc, qemu-devel, Tom Musta, David Gibson,
	Michael Walle

Only the POWER[789] CPUs should have the ARCH_206 bit set. This is what the
linux kernel does. I guess this was also the intention of commit 0e019746.
We have to make sure all *206 bits are set.

Before this patch, the flags check in the GET_FEATURES2 macro returned true
if _any_ bit was set. This worked well as long as there was only one bit
set in the 'flag' parameter. But as explained before, we have to make sure
all bits in the 'flag' parameter are set.

Signed-off-by: Michael Walle <michael@walle.cc>
---
v2:
  - rename flag to flags
  - use normal indent style in macro (also makes checkpatch.pl happy ;)
  - add explanation in commit message

 linux-user/elfload.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index f807baf..515ba6c 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -741,8 +741,12 @@ static uint32_t get_elf_hwcap(void)
        Altivec/FP/SPE support.  Anything else is just a bonus.  */
 #define GET_FEATURE(flag, feature)                                      \
     do { if (cpu->env.insns_flags & flag) { features |= feature; } } while (0)
-#define GET_FEATURE2(flag, feature)                                      \
-    do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)
+#define GET_FEATURE2(flags, feature) \
+    do { \
+        if ((cpu->env.insns_flags2 & flags) == flags) { \
+            features |= feature; \
+        } \
+    } while (0)
     GET_FEATURE(PPC_64B, QEMU_PPC_FEATURE_64);
     GET_FEATURE(PPC_FLOAT, QEMU_PPC_FEATURE_HAS_FPU);
     GET_FEATURE(PPC_ALTIVEC, QEMU_PPC_FEATURE_HAS_ALTIVEC);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v2] linux-user: ppc64: fix ARCH_206 bit in AT_HWCAP
  2016-09-21  9:57 [Qemu-devel] [PATCH v2] linux-user: ppc64: fix ARCH_206 bit in AT_HWCAP Michael Walle
@ 2016-09-21 10:15 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2016-09-21 10:15 UTC (permalink / raw)
  To: Michael Walle
  Cc: Riku Voipio, Alexander Graf, qemu-ppc, qemu-devel, Tom Musta

[-- Attachment #1: Type: text/plain, Size: 2070 bytes --]

On Wed, Sep 21, 2016 at 11:57:05AM +0200, Michael Walle wrote:
> Only the POWER[789] CPUs should have the ARCH_206 bit set. This is what the
> linux kernel does. I guess this was also the intention of commit 0e019746.
> We have to make sure all *206 bits are set.
> 
> Before this patch, the flags check in the GET_FEATURES2 macro returned true
> if _any_ bit was set. This worked well as long as there was only one bit
> set in the 'flag' parameter. But as explained before, we have to make sure
> all bits in the 'flag' parameter are set.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>

Applied to ppc-for-2.8, thanks.

> ---
> v2:
>   - rename flag to flags
>   - use normal indent style in macro (also makes checkpatch.pl happy ;)
>   - add explanation in commit message
> 
>  linux-user/elfload.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index f807baf..515ba6c 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -741,8 +741,12 @@ static uint32_t get_elf_hwcap(void)
>         Altivec/FP/SPE support.  Anything else is just a bonus.  */
>  #define GET_FEATURE(flag, feature)                                      \
>      do { if (cpu->env.insns_flags & flag) { features |= feature; } } while (0)
> -#define GET_FEATURE2(flag, feature)                                      \
> -    do { if (cpu->env.insns_flags2 & flag) { features |= feature; } } while (0)
> +#define GET_FEATURE2(flags, feature) \
> +    do { \
> +        if ((cpu->env.insns_flags2 & flags) == flags) { \
> +            features |= feature; \
> +        } \
> +    } while (0)
>      GET_FEATURE(PPC_64B, QEMU_PPC_FEATURE_64);
>      GET_FEATURE(PPC_FLOAT, QEMU_PPC_FEATURE_HAS_FPU);
>      GET_FEATURE(PPC_ALTIVEC, QEMU_PPC_FEATURE_HAS_ALTIVEC);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-21 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21  9:57 [Qemu-devel] [PATCH v2] linux-user: ppc64: fix ARCH_206 bit in AT_HWCAP Michael Walle
2016-09-21 10:15 ` David Gibson

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.