For get_elf_hwcap, change the return type to abi_ulong
and pass in the cpu.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/loader.h | 5 +--
linux-user/s390x/target_elf.h | 2 ++
linux-user/s390x/target_proc.h | 2 +-
linux-user/elfload.c | 60 +---------------------------------
linux-user/s390x/elfload.c | 57 ++++++++++++++++++++++++++++++++
5 files changed, 62 insertions(+), 64 deletions(-)
diff --git a/linux-user/loader.h b/linux-user/loader.h
index d8a9399807..c14e69f551 100644
--- a/linux-user/loader.h
+++ b/linux-user/loader.h
@@ -104,13 +104,10 @@ const char *get_elf_cpu_model(uint32_t eflags);
#if defined(TARGET_I386) || defined(TARGET_X86_64) || defined(TARGET_ARM) \
|| defined(TARGET_SPARC) || defined(TARGET_PPC) \
|| defined(TARGET_LOONGARCH64) || defined(TARGET_MIPS) \
- || defined(TARGET_SH4)
+ || defined(TARGET_SH4) || defined(TARGET_S390X)
abi_ulong get_elf_hwcap(CPUState *cs);
abi_ulong get_elf_hwcap2(CPUState *cs);
#endif
-#if defined(TARGET_S390X)
-uint32_t get_elf_hwcap(void);
-#endif
const char *elf_hwcap_str(uint32_t bit);
const char *elf_hwcap2_str(uint32_t bit);
diff --git a/linux-user/s390x/target_elf.h b/linux-user/s390x/target_elf.h
index e51b053339..cebace949a 100644
--- a/linux-user/s390x/target_elf.h
+++ b/linux-user/s390x/target_elf.h
@@ -8,4 +8,6 @@
#ifndef S390X_TARGET_ELF_H
#define S390X_TARGET_ELF_H
+#define HAVE_ELF_HWCAP 1
+
#endif
diff --git a/linux-user/s390x/target_proc.h b/linux-user/s390x/target_proc.h
index a4a4821ea5..60cc22d3b4 100644
--- a/linux-user/s390x/target_proc.h
+++ b/linux-user/s390x/target_proc.h
@@ -48,7 +48,7 @@ static void show_cpu_summary(CPUArchState *cpu_env, int fd)
{
S390CPUModel *model = env_archcpu(cpu_env)->model;
int num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
- uint32_t elf_hwcap = get_elf_hwcap();
+ uint32_t elf_hwcap = get_elf_hwcap(env_cpu(cpu_env));
const char *hwcap_str;
int i;
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 7e1c11c39f..ba8593368d 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1039,65 +1039,7 @@ static inline void init_thread(struct target_pt_regs *regs,
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_S390
-#include "elf.h"
-
-#define ELF_HWCAP get_elf_hwcap()
-
-#define GET_FEATURE(_feat, _hwcap) \
- do { if (s390_has_feat(_feat)) { hwcap |= _hwcap; } } while (0)
-
-uint32_t get_elf_hwcap(void)
-{
- /*
- * Let's assume we always have esan3 and zarch.
- * 31-bit processes can use 64-bit registers (high gprs).
- */
- uint32_t hwcap = HWCAP_S390_ESAN3 | HWCAP_S390_ZARCH | HWCAP_S390_HIGH_GPRS;
-
- GET_FEATURE(S390_FEAT_STFLE, HWCAP_S390_STFLE);
- GET_FEATURE(S390_FEAT_MSA, HWCAP_S390_MSA);
- GET_FEATURE(S390_FEAT_LONG_DISPLACEMENT, HWCAP_S390_LDISP);
- GET_FEATURE(S390_FEAT_EXTENDED_IMMEDIATE, HWCAP_S390_EIMM);
- if (s390_has_feat(S390_FEAT_EXTENDED_TRANSLATION_3) &&
- s390_has_feat(S390_FEAT_ETF3_ENH)) {
- hwcap |= HWCAP_S390_ETF3EH;
- }
- GET_FEATURE(S390_FEAT_VECTOR, HWCAP_S390_VXRS);
- GET_FEATURE(S390_FEAT_VECTOR_ENH, HWCAP_S390_VXRS_EXT);
- GET_FEATURE(S390_FEAT_VECTOR_ENH2, HWCAP_S390_VXRS_EXT2);
-
- return hwcap;
-}
-
-const char *elf_hwcap_str(uint32_t bit)
-{
- static const char *hwcap_str[] = {
- [HWCAP_S390_NR_ESAN3] = "esan3",
- [HWCAP_S390_NR_ZARCH] = "zarch",
- [HWCAP_S390_NR_STFLE] = "stfle",
- [HWCAP_S390_NR_MSA] = "msa",
- [HWCAP_S390_NR_LDISP] = "ldisp",
- [HWCAP_S390_NR_EIMM] = "eimm",
- [HWCAP_S390_NR_DFP] = "dfp",
- [HWCAP_S390_NR_HPAGE] = "edat",
- [HWCAP_S390_NR_ETF3EH] = "etf3eh",
- [HWCAP_S390_NR_HIGH_GPRS] = "highgprs",
- [HWCAP_S390_NR_TE] = "te",
- [HWCAP_S390_NR_VXRS] = "vx",
- [HWCAP_S390_NR_VXRS_BCD] = "vxd",
- [HWCAP_S390_NR_VXRS_EXT] = "vxe",
- [HWCAP_S390_NR_GS] = "gs",
- [HWCAP_S390_NR_VXRS_EXT2] = "vxe2",
- [HWCAP_S390_NR_VXRS_PDE] = "vxp",
- [HWCAP_S390_NR_SORT] = "sort",
- [HWCAP_S390_NR_DFLT] = "dflt",
- [HWCAP_S390_NR_NNPA] = "nnpa",
- [HWCAP_S390_NR_PCI_MIO] = "pcimio",
- [HWCAP_S390_NR_SIE] = "sie",
- };
-
- return bit < ARRAY_SIZE(hwcap_str) ? hwcap_str[bit] : NULL;
-}
+#define ELF_HWCAP get_elf_hwcap(thread_cpu)
static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop)
{
diff --git a/linux-user/s390x/elfload.c b/linux-user/s390x/elfload.c
index 989953a247..79ceaba51d 100644
--- a/linux-user/s390x/elfload.c
+++ b/linux-user/s390x/elfload.c
@@ -3,9 +3,66 @@
#include "qemu/osdep.h"
#include "qemu.h"
#include "loader.h"
+#include "elf.h"
const char *get_elf_cpu_model(uint32_t eflags)
{
return "qemu";
}
+
+#define GET_FEATURE(_feat, _hwcap) \
+ do { if (s390_has_feat(_feat)) { hwcap |= _hwcap; } } while (0)
+
+abi_ulong get_elf_hwcap(CPUState *cs)
+{
+ /*
+ * Let's assume we always have esan3 and zarch.
+ * 31-bit processes can use 64-bit registers (high gprs).
+ */
+ uint32_t hwcap = HWCAP_S390_ESAN3 | HWCAP_S390_ZARCH | HWCAP_S390_HIGH_GPRS;
+
+ GET_FEATURE(S390_FEAT_STFLE, HWCAP_S390_STFLE);
+ GET_FEATURE(S390_FEAT_MSA, HWCAP_S390_MSA);
+ GET_FEATURE(S390_FEAT_LONG_DISPLACEMENT, HWCAP_S390_LDISP);
+ GET_FEATURE(S390_FEAT_EXTENDED_IMMEDIATE, HWCAP_S390_EIMM);
+ if (s390_has_feat(S390_FEAT_EXTENDED_TRANSLATION_3) &&
+ s390_has_feat(S390_FEAT_ETF3_ENH)) {
+ hwcap |= HWCAP_S390_ETF3EH;
+ }
+ GET_FEATURE(S390_FEAT_VECTOR, HWCAP_S390_VXRS);
+ GET_FEATURE(S390_FEAT_VECTOR_ENH, HWCAP_S390_VXRS_EXT);
+ GET_FEATURE(S390_FEAT_VECTOR_ENH2, HWCAP_S390_VXRS_EXT2);
+
+ return hwcap;
+}
+
+const char *elf_hwcap_str(uint32_t bit)
+{
+ static const char *hwcap_str[] = {
+ [HWCAP_S390_NR_ESAN3] = "esan3",
+ [HWCAP_S390_NR_ZARCH] = "zarch",
+ [HWCAP_S390_NR_STFLE] = "stfle",
+ [HWCAP_S390_NR_MSA] = "msa",
+ [HWCAP_S390_NR_LDISP] = "ldisp",
+ [HWCAP_S390_NR_EIMM] = "eimm",
+ [HWCAP_S390_NR_DFP] = "dfp",
+ [HWCAP_S390_NR_HPAGE] = "edat",
+ [HWCAP_S390_NR_ETF3EH] = "etf3eh",
+ [HWCAP_S390_NR_HIGH_GPRS] = "highgprs",
+ [HWCAP_S390_NR_TE] = "te",
+ [HWCAP_S390_NR_VXRS] = "vx",
+ [HWCAP_S390_NR_VXRS_BCD] = "vxd",
+ [HWCAP_S390_NR_VXRS_EXT] = "vxe",
+ [HWCAP_S390_NR_GS] = "gs",
+ [HWCAP_S390_NR_VXRS_EXT2] = "vxe2",
+ [HWCAP_S390_NR_VXRS_PDE] = "vxp",
+ [HWCAP_S390_NR_SORT] = "sort",
+ [HWCAP_S390_NR_DFLT] = "dflt",
+ [HWCAP_S390_NR_NNPA] = "nnpa",
+ [HWCAP_S390_NR_PCI_MIO] = "pcimio",
+ [HWCAP_S390_NR_SIE] = "sie",
+ };
+
+ return bit < ARRAY_SIZE(hwcap_str) ? hwcap_str[bit] : NULL;
+}
--
2.43.0