]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user/loongarch64: Expand target_elf_gregset_t
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 28 Aug 2025 01:37:08 +0000 (11:37 +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.
Note that the kernel's uses an array, and then it has a bunch of defines
to create symbolic offsets.  Modulo some reserved fields, which we do
not implement here, this is the same layout as struct user_pt_regs.

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/loongarch64/elfload.c
linux-user/loongarch64/target_elf.h

index 832890de1002b084b147fdfe98f113d78b1ef08a..ce3bd0c6079c903b902bdb3a1beb0f2bd4e755ea 100644 (file)
@@ -65,20 +65,14 @@ const char *get_elf_platform(CPUState *cs)
 
 #define tswapreg(ptr)   tswapal(ptr)
 
-enum {
-    TARGET_EF_R0 = 0,
-    TARGET_EF_CSR_ERA = TARGET_EF_R0 + 33,
-    TARGET_EF_CSR_BADV = TARGET_EF_R0 + 34,
-};
-
 void elf_core_copy_regs(target_elf_gregset_t *r, const CPULoongArchState *env)
 {
-    r->regs[TARGET_EF_R0] = 0;
+    r->pt.regs[0] = 0;
 
     for (int i = 1; i < ARRAY_SIZE(env->gpr); i++) {
-        r->regs[TARGET_EF_R0 + i] = tswapreg(env->gpr[i]);
+        r->pt.regs[i] = tswapreg(env->gpr[i]);
     }
 
-    r->regs[TARGET_EF_CSR_ERA] = tswapreg(env->pc);
-    r->regs[TARGET_EF_CSR_BADV] = tswapreg(env->CSR_BADV);
+    r->pt.csr_era = tswapreg(env->pc);
+    r->pt.csr_badv = tswapreg(env->CSR_BADV);
 }
index 90bca4499d2a3a2b373d608d5aea6bd40de8b73c..1f40419af2485a91c3e9e7e6718eb7c23ef78af5 100644 (file)
@@ -6,16 +6,15 @@
 #ifndef LOONGARCH_TARGET_ELF_H
 #define LOONGARCH_TARGET_ELF_H
 
+#include "target_ptrace.h"
+
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_PLATFORM       1
 #define HAVE_ELF_CORE_DUMP      1
 
-typedef abi_ulong target_elf_greg_t;
-
 /* See linux kernel: arch/loongarch/include/asm/elf.h */
-#define ELF_NREG                45
 typedef struct target_elf_gregset_t {
-    target_elf_greg_t regs[ELF_NREG];
+    struct target_user_pt_regs pt;
 } target_elf_gregset_t;
 
 #endif