Skip to contentSkip to conversation

util: fix build with musl libc on ppc64le

PATCH Applied Natanael Copa 3 participants 3 messages Dec 19, 2023 – Jan 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util: fix build with musl libc on ppc64le

Use PPC_FEATURE2_ISEL and PPC_FEATURE2_VEC_CRYPTO from linux headers instead of the GNU specific PPC_FEATURE2_HAS_ISEL and PPC_FEATURE2_HAS_VEC_CRYPTO. This fixes build with musl libc.

Fixes 623d7e3551a6 (util: Add cpuinfo-ppc.c)

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1861

---
 util/cpuinfo-ppc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
util/cpuinfo-ppc.c +3 -3
index 1ea3db0ac8..b2d8893a06 100644
@@ -6,10 +6,10 @@
 #include "qemu/osdep.h"
 #include "host/cpuinfo.h"
 
+#include <asm/cputable.h>
 #ifdef CONFIG_GETAUXVAL
 # include <sys/auxv.h>
 #else
-# include <asm/cputable.h>
 # include "elf.h"
 #endif
 
@@ -40,7 +40,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
         info |= CPUINFO_V2_06;
     }
 
-    if (hwcap2 & PPC_FEATURE2_HAS_ISEL) {
+    if (hwcap2 & PPC_FEATURE2_ISEL) {
         info |= CPUINFO_ISEL;
     }
     if (hwcap & PPC_FEATURE_HAS_ALTIVEC) {
@@ -53,7 +53,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
              * always have both anyway, since VSX came with Power7
              * and crypto came with Power8.
              */
-            if (hwcap2 & PPC_FEATURE2_HAS_VEC_CRYPTO) {
+            if (hwcap2 & PPC_FEATURE2_VEC_CRYPTO) {
                 info |= CPUINFO_CRYPTO;
             }
         }
Signature · 1 line
2.43.0
#1 lore raw

Hi Natanael,

Quoted 5 lines · Natanael Copa

Use PPC_FEATURE2_ISEL and PPC_FEATURE2_VEC_CRYPTO from linux headers instead of the GNU specific PPC_FEATURE2_HAS_ISEL and PPC_FEATURE2_HAS_VEC_CRYPTO. This fixes build with musl libc.

Fixes 623d7e3551a6 (util: Add cpuinfo-ppc.c)

Hmm this commit barely moved the code. Maybe it revealed the issue from the following commits?

Fixes 63922f467a ("tcg/ppc: Replace HAVE_ISEL macro with a variable")
Fixes 68f340d4cd ("tcg/ppc: Enable Altivec detection")

Anyhow, changes LGTM.

Quoted 41 lines

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1861

---
  util/cpuinfo-ppc.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
util/cpuinfo-ppc.c +3 -3
index 1ea3db0ac8..b2d8893a06 100644
@@ -6,10 +6,10 @@
  #include "qemu/osdep.h"
  #include "host/cpuinfo.h"
 
+#include <asm/cputable.h>
  #ifdef CONFIG_GETAUXVAL
  # include <sys/auxv.h>
  #else
-# include <asm/cputable.h>
  # include "elf.h"
  #endif
 
@@ -40,7 +40,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
          info |= CPUINFO_V2_06;
      }
 
-    if (hwcap2 & PPC_FEATURE2_HAS_ISEL) {
+    if (hwcap2 & PPC_FEATURE2_ISEL) {
          info |= CPUINFO_ISEL;
      }
      if (hwcap & PPC_FEATURE_HAS_ALTIVEC) {
@@ -53,7 +53,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void)
               * always have both anyway, since VSX came with Power7
               * and crypto came with Power8.
               */
-            if (hwcap2 & PPC_FEATURE2_HAS_VEC_CRYPTO) {
+            if (hwcap2 & PPC_FEATURE2_VEC_CRYPTO) {
                  info |= CPUINFO_CRYPTO;
              }
          }
#2 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé

Hi Natanael,

Quoted 5 lines · Natanael Copa

Use PPC_FEATURE2_ISEL and PPC_FEATURE2_VEC_CRYPTO from linux headers instead of the GNU specific PPC_FEATURE2_HAS_ISEL and PPC_FEATURE2_HAS_VEC_CRYPTO. This fixes build with musl libc.

Fixes 623d7e3551a6 (util: Add cpuinfo-ppc.c)
Quoted 7 lines

Hmm this commit barely moved the code. Maybe it revealed the issue from the following commits?

Fixes 63922f467a ("tcg/ppc: Replace HAVE_ISEL macro with a variable")
Fixes 68f340d4cd ("tcg/ppc: Enable Altivec detection")

Anyhow, changes LGTM.

Queued, thanks.

r~