summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2025-08-28 11:37:08 +1000
committerRichard Henderson <richard.henderson@linaro.org>2025-08-30 07:04:04 +1000
commit190cc717f8cf50b7d38b8f9b8a2045540f71c571 (patch)
treea5de6c90d2616d52d5ace9f9ed51ec7e6763d25b
parent9308223c714d1efb275cf21c439ee85f5e6cad0d (diff)
downloadfocaccia-qemu-190cc717f8cf50b7d38b8f9b8a2045540f71c571.tar.gz
focaccia-qemu-190cc717f8cf50b7d38b8f9b8a2045540f71c571.zip
linux-user/loongarch64: Expand target_elf_gregset_t
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>
-rw-r--r--linux-user/loongarch64/elfload.c14
-rw-r--r--linux-user/loongarch64/target_elf.h7
2 files changed, 7 insertions, 14 deletions
diff --git a/linux-user/loongarch64/elfload.c b/linux-user/loongarch64/elfload.c
index 832890de10..ce3bd0c607 100644
--- a/linux-user/loongarch64/elfload.c
+++ b/linux-user/loongarch64/elfload.c
@@ -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);
 }
diff --git a/linux-user/loongarch64/target_elf.h b/linux-user/loongarch64/target_elf.h
index 90bca4499d..1f40419af2 100644
--- a/linux-user/loongarch64/target_elf.h
+++ b/linux-user/loongarch64/target_elf.h
@@ -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