@samitouri / QOSamiQemu / commits / bc22871fc0

linux-user/mips: write the floating-point registers to a core dump

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 <mattst88@gmail.com> Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Helge Deller <deller@gmx.de>

Matt Turner committed Aug 5, 2026 at 13:15 UTC bc22871fc0146f3cf6f4bbef9b6cdef16d1643f5
3 files changed +34
linux-user/mips/elfload.c
+8
@@ -130,6 +130,14 @@ const char *get_elf_base_platform(CPUState *cs)
130
131 #undef MATCH_PLATFORM_INSN
132
133 +void elf_core_copy_fpregs(target_elf_fpregset_t *r, const CPUMIPSState *env)
134 +{
135 + for (int i = 0; i < 32; i++) {
136 + r->fpr[i] = tswap64(env->active_fpu.fpr[i].d);
137 + }
138 + r->fcsr = tswap32(env->active_fpu.fcr31);
139 +}
140 +
141 /* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */
142 #ifndef TARGET_MIPS64
143 void elf_core_copy_regs(target_elf_gregset_t *r, const CPUMIPSState *env)
linux-user/mips/target_elf.h
+13
@@ -26,4 +26,17 @@ typedef struct target_elf_gregset_t {
26 };
27 } target_elf_gregset_t;
28
29 +#define HAVE_ELF_CORE_FPREGS 1
30 +
31 +/*
32 + * Matches the kernel's elf_fpregset_t (ELF_NFPREG = 33):
33 + * fpr[0..31] hold f0-f31; fcsr occupies the low 32 bits of slot 32.
34 + * pad rounds the struct to 33 × 8 bytes = 264 bytes.
35 + */
36 +typedef struct target_elf_fpregset_t {
37 + uint64_t fpr[32];
38 + uint32_t fcsr;
39 + uint32_t pad;
40 +} target_elf_fpregset_t;
41 +
42 #endif
linux-user/mips64/target_elf.h
+13
@@ -32,4 +32,17 @@ typedef struct target_elf_gregset_t {
32 };
33 } target_elf_gregset_t;
34
35 +#define HAVE_ELF_CORE_FPREGS 1
36 +
37 +/*
38 + * Matches the kernel's elf_fpregset_t (ELF_NFPREG = 33):
39 + * fpr[0..31] hold f0-f31; fcsr occupies the low 32 bits of slot 32.
40 + * pad rounds the struct to 33 × 8 bytes = 264 bytes.
41 + */
42 +typedef struct target_elf_fpregset_t {
43 + uint64_t fpr[32];
44 + uint32_t fcsr;
45 + uint32_t pad;
46 +} target_elf_fpregset_t;
47 +
48 #endif