linux-user/elfload: add s390x core dumping support
PATCH 1/1 linux-user/elfload: add s390x core dumping support
Provide the following definitions required by the common code:
* ELF_NREG: with the value of sizeof(s390_regs) / sizeof(long).
* target_elf_gregset_t: define it like all the other arches do.
* elf_core_copy_regs(): similar to kernel's s390_regs_get().
* USE_ELF_CORE_DUMP.
* ELF_EXEC_PAGESIZE.
--- linux-user/elfload.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
linux-user/elfload.c +33 -0
@@ -1385,6 +1385,39 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i regs->gprs[15] = infop->start_stack; } +/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ +#define ELF_NREG 27 +typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; + +enum { +TARGET_REG_PSWM =0 , +TARGET_REG_PSWA =1 , +TARGET_REG_GPRS =2 , +TARGET_REG_ARS =18 , +TARGET_REG_ORIG_R2 =26 , +}; + +static void elf_core_copy_regs (target_elf_gregset_t *regs, +const CPUS390XState *env) +{ +int i; +uint32_t *aregs; + + (*regs)[TARGET_REG_PSWM ] =tswapreg (env->psw.mask); + (*regs)[TARGET_REG_PSWA ] =tswapreg (env->psw.addr); +for (i =0 ; i <16 ; i++) { + (*regs)[TARGET_REG_GPRS + i] =tswapreg (env->regs[i]); + } + aregs = (uint32_t *)&((*regs)[TARGET_REG_ARS ]); +for (i =0 ; i <16 ; i++) { + aregs[i] =tswap32 (env->aregs[i]); + } + (*regs)[TARGET_REG_ORIG_R2 ] =0 ; +} + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 +#endif /* TARGET_S390X */ #ifdef TARGET_RISCV
Signature · 1 line
2.29.2
Laurent Vivier
AppliedLe 13/04/2021 à 22:56, Ilya Leoshkevich a écrit :
Quoted 48 lines
Provide the following definitions required by the common code:
*
ELF_NREG: with the value ofsizeof(s390_regs)/ sizeof(long).
*target_elf_gregset_t: define it like all the other arches do.
*elf_core_copy_regs(): similar to kernel'ss390_regs_get().
*USE_ELF_CORE_DUMP.
*ELF_EXEC_PAGESIZE.Signed-off-by Ilya Leoshkevich <[email protected]>--- linux-user/elfload.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)linux-user/elfload.c +26
-0@@ -1385,6 +1385,39 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i regs->gprs[15 ] = infop->start_stack; } +/* See linux kernel: arch/s390/include/uapi/asm/ptrace.h (s390_regs). */ +#define ELF_NREG 27 +typedef target_elf_greg_t target_elf_gregset_t [ELF_NREG ]; + +enum { +TARGET_REG_PSWM =0 , +TARGET_REG_PSWA =1 , +TARGET_REG_GPRS =2 , +TARGET_REG_ARS =18 , +TARGET_REG_ORIG_R2 =26 , +}; + +static void elf_core_copy_regs (target_elf_gregset_t *regs, +const CPUS390XState *env) +{ +int i; +uint32_t *aregs; + + (*regs)[TARGET_REG_PSWM ] =tswapreg (env->psw.mask); + (*regs)[TARGET_REG_PSWA ] =tswapreg (env->psw.addr); +for (i =0 ; i <16 ; i++) { + (*regs)[TARGET_REG_GPRS + i] =tswapreg (env->regs[i]); + } + aregs = (uint32_t *)&((*regs)[TARGET_REG_ARS ]); +for (i =0 ; i <16 ; i++) { + aregs[i] =tswap32 (env->aregs[i]);
linux-user/elfload.c static inline void init_thread(struct target_pt_regs *regs, struct image_info *i · line 1423
Quoted 10 lines
linux-user/elfload.c +7
-0+ } + (*regs)[TARGET_REG_ORIG_R2 ] =0 ; +} + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 +#endif /* TARGET_S390X */ #ifdef TARGET_RISCV
Applied to my linux-user-for-6.1 branch.
Thanks,
Laurent