[PATCH 4/5] linux-user/riscv: write the floating-point registers to a core dump
Matt Turner <[email protected]> Wed, 5 Aug 2026 13:15:06 -0400
| Newsgroups | gmane.comp.emulators.qemu |
|---|---|
| Message-ID | <[email protected]> |
Write an NT_FPREGSET note for RISC-V, matching struct __riscv_d_ext_state from uapi/asm/ptrace.h: f0-f31 as 64-bit values followed by fcsr. Signed-off-by: Matt Turner <[email protected]> --- linux-user/riscv/elfload.c | 9 +++++++++ linux-user/riscv/target_elf.h | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git ./linux-user/riscv/elfload.c ./linux-user/riscv/elfload.c index afe103a631..1bc8beacb1 100644 --- ./linux-user/riscv/elfload.c +++ ./linux-user/riscv/elfload.c @@ -11,6 +11,15 @@ const char *get_elf_cpu_model(uint32_t eflags) return "max"; } +void elf_core_copy_fpregs(target_elf_fpregset_t *r, const CPURISCVState *env) +{ + for (int i = 0; i < 32; i++) { + r->fpr[i] = tswap64(env->fpr[i]); + } + r->fcsr = tswap32(((uint32_t)env->frm << FSR_RD_SHIFT) | + (riscv_cpu_get_fflags((CPURISCVState *)env) << FSR_AEXC_SHIFT)); +} + void elf_core_copy_regs(target_elf_gregset_t *r, const CPURISCVState *env) { r->pc = tswapal(env->pc); diff --git ./linux-user/riscv/target_elf.h ./linux-user/riscv/target_elf.h index 859f726578..185b81a2db 100644 --- ./linux-user/riscv/target_elf.h +++ ./linux-user/riscv/target_elf.h @@ -27,4 +27,15 @@ typedef struct target_elf_gregset_t { abi_ulong regs[31]; } target_elf_gregset_t; +#define HAVE_ELF_CORE_FPREGS 1 + +/* + * Matches struct __riscv_d_ext_state from uapi/asm/ptrace.h: + * f0-f31 as 64-bit values followed by fcsr. + */ +typedef struct target_elf_fpregset_t { + uint64_t fpr[32]; + uint32_t fcsr; +} target_elf_fpregset_t; + #endif -- 2.54.0