From: Richard Henderson Date: Thu, 28 Aug 2025 01:37:08 +0000 (+1000) Subject: linux-user/loongarch64: Expand target_elf_gregset_t X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=190cc717f8cf50b7d38b8f9b8a2045540f71c571;p=thirdparty%2Fqemu.git 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 Signed-off-by: Richard Henderson --- diff --git a/linux-user/loongarch64/elfload.c b/linux-user/loongarch64/elfload.c index 832890de100..ce3bd0c6079 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 90bca4499d2..1f40419af24 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