All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/5] Linux user next patches
@ 2026-10-04 11:43 Helge Deller
  2026-10-04 11:43 ` [PULL 1/5] linux-user: add elf_core_eflags() hook for core dump e_flags Helge Deller
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Helge Deller @ 2026-10-04 11:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

From: Helge Deller <deller@gmx.de>

The following changes since commit d7a65d1793d691d356a56833620f7d1e6f5d653b:

  Merge tag 'hppa-a400-updates-pull-request' of https://github.com/hdeller/qemu-hppa into staging (2026-10-03 14:17:49 +0200)

are available in the Git repository at:

  https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request

for you to fetch changes up to 8e021b85cc06caec24a24302aa68f040a0970c12:

  linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008 (2026-10-04 13:32:14 +0200)

----------------------------------------------------------------
linux user patches

Some patches for linux-user, which
- make it possible to run pre-r6 mips64 binaries that need nan2008 without
  requiring the user to explicitly set a compatible -cpu, and
- copy the executable's e_flags into core dumps on mips and riscv

----------------------------------------------------------------

Alex Rønne Petersen (2):
  target/mips: fix Loongson-3A4000 definition to have abs2008 and
    nan2008
  linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs
    nan2008

Matt Turner (3):
  linux-user: add elf_core_eflags() hook for core dump e_flags
  linux-user/mips64: set EF_MIPS_ABI2 in mipsn32 core dumps
  linux-user/riscv: copy the executable's e_flags into core dumps

 linux-user/elfload.c           |  7 ++++++-
 linux-user/mips/elfload.c      | 14 ++++++++------
 linux-user/mips64/target_elf.h |  2 ++
 linux-user/riscv/target_elf.h  |  3 +++
 target/mips/cpu-defs.c.inc     |  4 ++--
 5 files changed, 21 insertions(+), 9 deletions(-)

-- 
2.54.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PULL 1/5] linux-user: add elf_core_eflags() hook for core dump e_flags
  2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
@ 2026-10-04 11:43 ` Helge Deller
  2026-10-04 11:43 ` [PULL 2/5] linux-user/mips64: set EF_MIPS_ABI2 in mipsn32 core dumps Helge Deller
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2026-10-04 11:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

From: Matt Turner <mattst88@gmail.com>

Let targets set e_flags in the core file header. Default to 0, as
before.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/elfload.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c4bdaa146a..c188fa03c3 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -144,6 +144,10 @@ typedef abi_int         target_pid_t;
 #define EXSTACK_DEFAULT false
 #endif
 
+#ifndef elf_core_eflags
+#define elf_core_eflags(info) 0
+#endif
+
 /*
  * Provide fallback definitions that the target may omit.
  * One way or another, we'll get a link error if the setting of
@@ -2212,7 +2216,8 @@ static int elf_core_dump(int signr, const CPUArchState *env)
 
         /* Create elf file header. */
         hptr = header;
-        fill_elf_header(hptr, css.count + 1, ELF_MACHINE, 0);
+        fill_elf_header(hptr, css.count + 1, ELF_MACHINE,
+                        elf_core_eflags(ts->info));
         hptr += sizeof(struct elfhdr);
 
         /* Create elf program headers. */
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 2/5] linux-user/mips64: set EF_MIPS_ABI2 in mipsn32 core dumps
  2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
  2026-10-04 11:43 ` [PULL 1/5] linux-user: add elf_core_eflags() hook for core dump e_flags Helge Deller
@ 2026-10-04 11:43 ` Helge Deller
  2026-10-04 11:43 ` [PULL 3/5] linux-user/riscv: copy the executable's e_flags into " Helge Deller
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2026-10-04 11:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

From: Matt Turner <mattst88@gmail.com>

mipsn32 core files had e_flags 0, so gdb took them for o32, found no
general-purpose registers and failed with an internal error in
frame_unwind_find_by_frame.

Linux sets e_flags to EF_MIPS_ABI2 for n32 cores (user_mipsn32_view in
arch/mips/kernel/ptrace.c).

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/mips64/target_elf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/mips64/target_elf.h b/linux-user/mips64/target_elf.h
index efb5d97563..fd9fb89269 100644
--- a/linux-user/mips64/target_elf.h
+++ b/linux-user/mips64/target_elf.h
@@ -16,6 +16,8 @@
 
 #ifdef TARGET_ABI_MIPSN32
 #define elf_check_abi(x)        ((x) & EF_MIPS_ABI2)
+/* See linux kernel: arch/mips/kernel/ptrace.c, user_mipsn32_view.  */
+#define elf_core_eflags(info)   EF_MIPS_ABI2
 #else
 #define elf_check_abi(x)        (!((x) & EF_MIPS_ABI2))
 #endif
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 3/5] linux-user/riscv: copy the executable's e_flags into core dumps
  2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
  2026-10-04 11:43 ` [PULL 1/5] linux-user: add elf_core_eflags() hook for core dump e_flags Helge Deller
  2026-10-04 11:43 ` [PULL 2/5] linux-user/mips64: set EF_MIPS_ABI2 in mipsn32 core dumps Helge Deller
@ 2026-10-04 11:43 ` Helge Deller
  2026-10-04 11:43 ` [PULL 4/5] target/mips: fix Loongson-3A4000 definition to have abs2008 and nan2008 Helge Deller
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2026-10-04 11:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

From: Matt Turner <mattst88@gmail.com>

Since commit 8c94db0ae97c ("binfmt_elf: preserve original ELF e_flags
for core dumps"), Linux writes the main executable's e_flags into RISC-V
core files, so debuggers can see the float ABI and RVC. QEMU wrote 0.

Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/riscv/target_elf.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/linux-user/riscv/target_elf.h b/linux-user/riscv/target_elf.h
index 185b81a2db..e99a9d92ca 100644
--- a/linux-user/riscv/target_elf.h
+++ b/linux-user/riscv/target_elf.h
@@ -21,6 +21,9 @@
 #define HAVE_ELF_HWCAP          1
 #define HAVE_ELF_CORE_DUMP      1
 
+/* See linux kernel: ARCH_HAS_ELF_CORE_EFLAGS.  */
+#define elf_core_eflags(info)   ((info)->elf_flags)
+
 /* Mirrors struct user_regs_struct: pc followed by x1 (ra) .. x31 (t6). */
 typedef struct target_elf_gregset_t {
     abi_ulong pc;
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 4/5] target/mips: fix Loongson-3A4000 definition to have abs2008 and nan2008
  2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
                   ` (2 preceding siblings ...)
  2026-10-04 11:43 ` [PULL 3/5] linux-user/riscv: copy the executable's e_flags into " Helge Deller
@ 2026-10-04 11:43 ` Helge Deller
  2026-10-04 11:43 ` [PULL 5/5] linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008 Helge Deller
  2026-10-06  9:24 ` [PULL 0/5] Linux user next patches Richard Henderson
  5 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2026-10-04 11:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

From: Alex Rønne Petersen <alex@alexrp.com>

Checked on a Loongson 3B4000; this uarch operates in 2008 mode.

Signed-off-by: Alex Rønne Petersen <alex@alexrp.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/mips/cpu-defs.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/mips/cpu-defs.c.inc b/target/mips/cpu-defs.c.inc
index cc1916232f..b2ddfa1e82 100644
--- a/target/mips/cpu-defs.c.inc
+++ b/target/mips/cpu-defs.c.inc
@@ -941,8 +941,8 @@ const mips_def_t mips_defs[] =
                     (1 << CP0PG_ELPA) | (1 << CP0PG_IEC),
         .CP1_fcr0 = (0x5 << FCR0_PRID) | (0x1 << FCR0_REV) | (0x1 << FCR0_F64) |
                     (0x1 << FCR0_PS) | (0x1 << FCR0_L) | (0x1 << FCR0_W) |
-                    (0x1 << FCR0_D) | (0x1 << FCR0_S),
-        .CP1_fcr31 = 0,
+                    (0x1 << FCR0_D) | (0x1 << FCR0_S) | (0x1 << FCR0_HAS2008),
+        .CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
         .CP1_fcr31_rw_bitmask = 0xFF83FFFF,
         .MSAIR = (0x01 << MSAIR_ProcID) | (0x40 << MSAIR_Rev),
         .lcsr_cpucfg1 = (1 << CPUCFG1_FP) | (2 << CPUCFG1_FPREV) |
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 5/5] linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008
  2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
                   ` (3 preceding siblings ...)
  2026-10-04 11:43 ` [PULL 4/5] target/mips: fix Loongson-3A4000 definition to have abs2008 and nan2008 Helge Deller
@ 2026-10-04 11:43 ` Helge Deller
  2026-10-06  9:24 ` [PULL 0/5] Linux user next patches Richard Henderson
  5 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2026-10-04 11:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

From: Alex Rønne Petersen <alex@alexrp.com>

Before this patch, we'd pick MIPS64R2-generic which does not have 2008 mode, so
the binary would just fail to run without an explicit -cpu flag. Now it'll just
work as in the pre-r6 mips32 case.

Signed-off-by: Alex Rønne Petersen <alex@alexrp.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/mips/elfload.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/linux-user/mips/elfload.c b/linux-user/mips/elfload.c
index 1d62ae0a4d..19850f4835 100644
--- a/linux-user/mips/elfload.c
+++ b/linux-user/mips/elfload.c
@@ -20,17 +20,19 @@ const char *get_elf_cpu_model(uint32_t eflags)
     case EF_MIPS_MACH_LS2F:
         return "Loongson-2F";
     case EF_MIPS_MACH_LS3A:
-        return "Loongson-3A1000";
+        return (eflags & EF_MIPS_NAN2008) ? "Loongson-3A4000"
+                                          : "Loongson-3A1000";
     default:
         break;
     }
-    switch (eflags & EF_MIPS_ARCH) {
-    case EF_MIPS_ARCH_64R6:
+    if ((eflags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R6) {
         return "I6400";
-    case EF_MIPS_ARCH_64R2:
+    }
+    if (eflags & EF_MIPS_NAN2008) {
+        return "Loongson-3A4000";
+    }
+    if ((eflags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R2) {
         return "MIPS64R2-generic";
-    default:
-        break;
     }
     return "5KEf";
 #else
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PULL 0/5] Linux user next patches
  2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
                   ` (4 preceding siblings ...)
  2026-10-04 11:43 ` [PULL 5/5] linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008 Helge Deller
@ 2026-10-06  9:24 ` Richard Henderson
  5 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2026-10-06  9:24 UTC (permalink / raw)
  To: Helge Deller, qemu-devel
  Cc: Laurent Vivier, Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Helge Deller, Jiaxun Yang, Aurelien Jarno, Pierrick Bouvier

On 10/4/26 13:43, Helge Deller wrote:
> From: Helge Deller<deller@gmx.de>
> 
> The following changes since commit d7a65d1793d691d356a56833620f7d1e6f5d653b:
> 
>    Merge tag 'hppa-a400-updates-pull-request' ofhttps://github.com/hdeller/qemu-hppa into staging (2026-10-03 14:17:49 +0200)
> 
> are available in the Git repository at:
> 
>    https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request
> 
> for you to fetch changes up to 8e021b85cc06caec24a24302aa68f040a0970c12:
> 
>    linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008 (2026-10-04 13:32:14 +0200)
> 
> ----------------------------------------------------------------
> linux user patches
> 
> Some patches for linux-user, which
> - make it possible to run pre-r6 mips64 binaries that need nan2008 without
>    requiring the user to explicitly set a compatible -cpu, and
> - copy the executable's e_flags into core dumps on mips and riscv

Applied, thanks.

r~


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-07  8:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-04 11:43 [PULL 0/5] Linux user next patches Helge Deller
2026-10-04 11:43 ` [PULL 1/5] linux-user: add elf_core_eflags() hook for core dump e_flags Helge Deller
2026-10-04 11:43 ` [PULL 2/5] linux-user/mips64: set EF_MIPS_ABI2 in mipsn32 core dumps Helge Deller
2026-10-04 11:43 ` [PULL 3/5] linux-user/riscv: copy the executable's e_flags into " Helge Deller
2026-10-04 11:43 ` [PULL 4/5] target/mips: fix Loongson-3A4000 definition to have abs2008 and nan2008 Helge Deller
2026-10-04 11:43 ` [PULL 5/5] linux-user/mips: pick Loongson-3A4000 if a pre-r6 mips64 binary needs nan2008 Helge Deller
2026-10-06  9:24 ` [PULL 0/5] Linux user next patches Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.