aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2025-08-28 13:44:40 +1000
committerRichard Henderson <richard.henderson@linaro.org>2025-08-30 07:04:04 +1000
commitabfa6c7c2a0ddc4eaf373de320d758435e7acf9b (patch)
tree6704a395e8a1e0a772efa36f6e15cc1f2e90670d /linux-user
parentb90e36861636fc5f021fd2a0676087d076cd0cc9 (diff)
downloadqemu-abfa6c7c2a0ddc4eaf373de320d758435e7acf9b.zip
qemu-abfa6c7c2a0ddc4eaf373de320d758435e7acf9b.tar.gz
qemu-abfa6c7c2a0ddc4eaf373de320d758435e7acf9b.tar.bz2
linux-user/xtensa: Expand target_elf_gregset_t
Make use of the fact that target_elf_gregset_t is a proper structure. 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>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/xtensa/elfload.c39
-rw-r--r--linux-user/xtensa/target_elf.h12
2 files changed, 19 insertions, 32 deletions
diff --git a/linux-user/xtensa/elfload.c b/linux-user/xtensa/elfload.c
index 49e709a..68aeed8 100644
--- a/linux-user/xtensa/elfload.c
+++ b/linux-user/xtensa/elfload.c
@@ -11,36 +11,21 @@ const char *get_elf_cpu_model(uint32_t eflags)
return XTENSA_DEFAULT_CPU_MODEL;
}
-#define tswapreg(ptr) tswapal(ptr)
-
-enum {
- TARGET_REG_PC,
- TARGET_REG_PS,
- TARGET_REG_LBEG,
- TARGET_REG_LEND,
- TARGET_REG_LCOUNT,
- TARGET_REG_SAR,
- TARGET_REG_WINDOWSTART,
- TARGET_REG_WINDOWBASE,
- TARGET_REG_THREADPTR,
- TARGET_REG_AR0 = 64,
-};
-
void elf_core_copy_regs(target_elf_gregset_t *r, const CPUXtensaState *env)
{
- unsigned i;
+ r->pt.pc = tswap32(env->pc);
+ r->pt.ps = tswap32(env->sregs[PS] & ~PS_EXCM);
+ r->pt.lbeg = tswap32(env->sregs[LBEG]);
+ r->pt.lend = tswap32(env->sregs[LEND]);
+ r->pt.lcount = tswap32(env->sregs[LCOUNT]);
+ r->pt.sar = tswap32(env->sregs[SAR]);
+ r->pt.windowstart = tswap32(env->sregs[WINDOW_START]);
+ r->pt.windowbase = tswap32(env->sregs[WINDOW_BASE]);
+ r->pt.threadptr = tswap32(env->uregs[THREADPTR]);
- r->regs[TARGET_REG_PC] = tswapreg(env->pc);
- r->regs[TARGET_REG_PS] = tswapreg(env->sregs[PS] & ~PS_EXCM);
- r->regs[TARGET_REG_LBEG] = tswapreg(env->sregs[LBEG]);
- r->regs[TARGET_REG_LEND] = tswapreg(env->sregs[LEND]);
- r->regs[TARGET_REG_LCOUNT] = tswapreg(env->sregs[LCOUNT]);
- r->regs[TARGET_REG_SAR] = tswapreg(env->sregs[SAR]);
- r->regs[TARGET_REG_WINDOWSTART] = tswapreg(env->sregs[WINDOW_START]);
- r->regs[TARGET_REG_WINDOWBASE] = tswapreg(env->sregs[WINDOW_BASE]);
- r->regs[TARGET_REG_THREADPTR] = tswapreg(env->uregs[THREADPTR]);
xtensa_sync_phys_from_window((CPUXtensaState *)env);
- for (i = 0; i < env->config->nareg; ++i) {
- r->regs[TARGET_REG_AR0 + i] = tswapreg(env->phys_regs[i]);
+
+ for (unsigned i = 0; i < env->config->nareg; ++i) {
+ r->pt.a[i] = tswap32(env->phys_regs[i]);
}
}
diff --git a/linux-user/xtensa/target_elf.h b/linux-user/xtensa/target_elf.h
index 43e241a..850a720 100644
--- a/linux-user/xtensa/target_elf.h
+++ b/linux-user/xtensa/target_elf.h
@@ -8,14 +8,16 @@
#ifndef XTENSA_TARGET_ELF_H
#define XTENSA_TARGET_ELF_H
-#define HAVE_ELF_CORE_DUMP 1
+#include "target_ptrace.h"
-typedef abi_ulong target_elf_greg_t;
+#define HAVE_ELF_CORE_DUMP 1
-/* See linux kernel: arch/xtensa/include/asm/elf.h. */
-#define ELF_NREG 128
+/*
+ * See linux kernel: arch/xtensa/include/asm/elf.h, where elf_gregset_t
+ * is mapped to struct user_pt_regs via typedef and sizeof.
+ */
typedef struct target_elf_gregset_t {
- target_elf_greg_t regs[ELF_NREG];
+ struct target_user_pt_regs pt;
} target_elf_gregset_t;
#endif