]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user/s390x: Expand target_elf_gregset_t
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 28 Aug 2025 02:31:49 +0000 (12:31 +1000)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 29 Aug 2025 21:04:04 +0000 (07:04 +1000)
Make use of the fact that target_elf_gregset_t is a proper structure.
This lets us drop the ugly cast to uint32_t* in the middle.

Drop ELF_NREG, target_elf_greg_t, and tswapreg.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
linux-user/s390x/elfload.c
linux-user/s390x/target_elf.h

index 4113273b724533d6a88928fe3884c6576425ac4e..27109279e28cbdf4b92608f5617ed26b4f6b6169 100644 (file)
@@ -68,29 +68,15 @@ const char *elf_hwcap_str(uint32_t bit)
     return bit < ARRAY_SIZE(hwcap_str) ? hwcap_str[bit] : NULL;
 }
 
-#define tswapreg(ptr)   tswapal(ptr)
-
-enum {
-    TARGET_REG_PSWM = 0,
-    TARGET_REG_PSWA = 1,
-    TARGET_REG_GPRS = 2,
-    TARGET_REG_ARS = 18,
-    TARGET_REG_ORIG_R2 = 26,
-};
-
 void elf_core_copy_regs(target_elf_gregset_t *r, const CPUS390XState *env)
 {
-    int i;
-    uint32_t *aregs;
-
-    r->regs[TARGET_REG_PSWM] = tswapreg(env->psw.mask);
-    r->regs[TARGET_REG_PSWA] = tswapreg(env->psw.addr);
-    for (i = 0; i < 16; i++) {
-        r->regs[TARGET_REG_GPRS + i] = tswapreg(env->regs[i]);
+    r->pt.psw.mask = tswapal(env->psw.mask);
+    r->pt.psw.addr = tswapal(env->psw.addr);
+    for (int i = 0; i < 16; i++) {
+        r->pt.gprs[i] = tswapal(env->regs[i]);
     }
-    aregs = (uint32_t *)&(r->regs[TARGET_REG_ARS]);
-    for (i = 0; i < 16; i++) {
-        aregs[i] = tswap32(env->aregs[i]);
+    for (int i = 0; i < 16; i++) {
+        r->pt.acrs[i] = tswap32(env->aregs[i]);
     }
-    r->regs[TARGET_REG_ORIG_R2] = 0;
+    r->pt.orig_gpr2 = 0;
 }
index b7d863ee6661d17cecac55113649e89cedab4af6..670c7b3eed7ed02014643b1c859c118b99bb4edc 100644 (file)
@@ -8,15 +8,17 @@
 #ifndef S390X_TARGET_ELF_H
 #define S390X_TARGET_ELF_H
 
+#include "target_ptrace.h"
+
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_CORE_DUMP      1
 
-typedef abi_ulong target_elf_greg_t;
-
-/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs).  */
-#define ELF_NREG                27
+/*
+ * See linux kernel: arch/s390/include/asm/elf.h, where
+ * elf_gregset_t is typedef'd to struct s390_regs.
+ */
 typedef struct target_elf_gregset_t {
-    target_elf_greg_t regs[ELF_NREG];
+    struct target_s390_regs pt;
 } target_elf_gregset_t;
 
 #endif