[PATCH 2/5] linux-user/mips: write the floating-point registers to a core dump
Matt Turner <[email protected]> Wed, 5 Aug 2026 13:15:04 -0400
| Newsgroups | gmane.comp.emulators.qemu |
|---|---|
| Message-ID | <[email protected]> |
Write an NT_FPREGSET note for MIPS and MIPS64, matching the kernel's elf_fpregset_t layout (ELF_NFPREG = 33): fpr[0..31] hold f0-f31, and fcsr occupies the low 32 bits of slot 32. The pad field rounds the struct to 33 × 8 bytes = 264 bytes. Signed-off-by: Matt Turner <[email protected]> --- linux-user/mips/elfload.c | 8 ++++++++ linux-user/mips/target_elf.h | 13 +++++++++++++ linux-user/mips64/target_elf.h | 13 +++++++++++++ 3 files changed, 34 insertions(+) diff --git ./linux-user/mips/elfload.c ./linux-user/mips/elfload.c index ce2c4514f3..1d62ae0a4d 100644 --- ./linux-user/mips/elfload.c +++ ./linux-user/mips/elfload.c @@ -130,6 +130,14 @@ const char *get_elf_base_platform(CPUState *cs) #undef MATCH_PLATFORM_INSN +void elf_core_copy_fpregs(target_elf_fpregset_t *r, const CPUMIPSState *env) +{ + for (int i = 0; i < 32; i++) { + r->fpr[i] = tswap64(env->active_fpu.fpr[i].d); + } + r->fcsr = tswap32(env->active_fpu.fcr31); +} + /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ #ifndef TARGET_MIPS64 void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMIPSState *env) diff --git ./linux-user/mips/target_elf.h ./linux-user/mips/target_elf.h index 157306f7a0..426f905d3a 100644 --- ./linux-user/mips/target_elf.h +++ ./linux-user/mips/target_elf.h @@ -26,4 +26,17 @@ typedef struct target_elf_gregset_t { }; } target_elf_gregset_t; +#define HAVE_ELF_CORE_FPREGS 1 + +/* + * Matches the kernel's elf_fpregset_t (ELF_NFPREG = 33): + * fpr[0..31] hold f0-f31; fcsr occupies the low 32 bits of slot 32. + * pad rounds the struct to 33 × 8 bytes = 264 bytes. + */ +typedef struct target_elf_fpregset_t { + uint64_t fpr[32]; + uint32_t fcsr; + uint32_t pad; +} target_elf_fpregset_t; + #endif diff --git ./linux-user/mips64/target_elf.h ./linux-user/mips64/target_elf.h index 061471a0f1..efb5d97563 100644 --- ./linux-user/mips64/target_elf.h +++ ./linux-user/mips64/target_elf.h @@ -32,4 +32,17 @@ typedef struct target_elf_gregset_t { }; } target_elf_gregset_t; +#define HAVE_ELF_CORE_FPREGS 1 + +/* + * Matches the kernel's elf_fpregset_t (ELF_NFPREG = 33): + * fpr[0..31] hold f0-f31; fcsr occupies the low 32 bits of slot 32. + * pad rounds the struct to 33 × 8 bytes = 264 bytes. + */ +typedef struct target_elf_fpregset_t { + uint64_t fpr[32]; + uint32_t fcsr; + uint32_t pad; +} target_elf_fpregset_t; + #endif -- 2.54.0