All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 00/14] Linux user next patches
@ 2026-04-25 15:51 Helge Deller
  2026-04-25 15:51 ` [PULL 01/14] MAINTAINERS: Add myself as maintainer for linux-user Helge Deller
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

The following changes since commit 98b060da3a4f92b2a994ead5b16a87e783baf77c:

  Update version for v11.0.0 release (2026-04-21 16:28:47 +0100)

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 9e7734ead149d73f1d25f61d0b7f075d4b2cb07d:

  linux-user: Flush errors by using exit() instead of _exit() in error path (2026-04-25 16:38:39 +0200)

----------------------------------------------------------------
linux-user: Pull request

This patch series adds myself as linux-user maintainer, and includes some
patches which have piled up for linux-user during the last few weeks.

Please apply.
Thanks!
Helge

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

Alistair Francis (1):
  linux-user/strace: Use pointer type for read and write values

Gyorgy Tamasi (1):
  linux-user: Don't define target_stat64 struct for loongarch64

Helge Deller (7):
  MAINTAINERS: Add myself as maintainer for linux-user
  linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW
  linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
  linux-user: Add getsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
  linux-user: Fix CLONE_PARENT_SETTID when using fork-like clone
  linux-user: Use abi_int for imr_ifindex in ip_mreqn struct
  linux-user: Flush errors by using exit() instead of _exit() in error
    path

James Hilliard (1):
  linux-user/mips: sync k0 TLS for EF_MIPS_MACH_OCTEON userlands

Matt Turner (1):
  linux-user/ppc: Fix ppc64 rt_sigframe stack offset

Richard Henderson (2):
  linux-user/arm/nwfpe: Replace user_registers with current_cpu
  linux-user/arm/nwfpe: Use thread-local storage for qemufpa

Yixin Wei (1):
  linux-user: fix off-by-one in host_to_target_for_each_rtattr()

 MAINTAINERS                   |  1 +
 linux-user/alpha/sockbits.h   |  7 +++++
 linux-user/arm/cpu_loop.c     |  2 +-
 linux-user/arm/nwfpe/fpa11.c  | 12 ++-------
 linux-user/arm/nwfpe/fpa11.h  | 25 ++++++------------
 linux-user/elfload.c          |  3 +++
 linux-user/fd-trans.c         |  2 +-
 linux-user/generic/sockbits.h |  8 ++++++
 linux-user/hppa/sockbits.h    |  7 +++++
 linux-user/main.c             |  2 +-
 linux-user/mips/sockbits.h    |  7 +++++
 linux-user/mips/target_cpu.h  |  5 ++++
 linux-user/ppc/signal.c       | 16 ++++++++++--
 linux-user/qemu.h             |  1 +
 linux-user/sparc/sockbits.h   |  7 +++++
 linux-user/strace.list        |  4 +--
 linux-user/syscall.c          | 49 +++++++++++++++++++++++++++--------
 linux-user/syscall_defs.h     |  4 +--
 18 files changed, 115 insertions(+), 47 deletions(-)

-- 
2.53.0



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

* [PULL 01/14] MAINTAINERS: Add myself as maintainer for linux-user
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 02/14] linux-user/ppc: Fix ppc64 rt_sigframe stack offset Helge Deller
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

I'd like to step up as maintainer for linux-user. I'm actively using
linux-user to emulate a HP-PARISC (hppa) linux environment on my debian
buildd servers, so I'm very much interested that linux-user is running
good and stable.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ad215eced8..e0f707a1ec 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4075,6 +4075,7 @@ T: git https://github.com/qemu-bsd-user/qemu-bsd-user bsd-user-rebase-3.1
 
 Linux user
 M: Laurent Vivier <laurent@vivier.eu>
+M: Helge Deller <deller@gmx.de>
 R: Pierrick Bouvier <pierrick.bouvier@linaro.org>
 S: Odd Fixes
 F: linux-user/
-- 
2.53.0



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

* [PULL 02/14] linux-user/ppc: Fix ppc64 rt_sigframe stack offset
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
  2026-04-25 15:51 ` [PULL 01/14] MAINTAINERS: Add myself as maintainer for linux-user Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 03/14] linux-user: fix off-by-one in host_to_target_for_each_rtattr() Helge Deller
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Matt Turner <mattst88@gmail.com>

The kernel's 64-bit signal delivery (signal_64.c) uses:

    newsp = frame - __SIGNAL_FRAMESIZE

while the 32-bit path (signal_32.c) uses:

    newsp = frame - (__SIGNAL_FRAMESIZE + 16)

The extra 16 bytes in the 32-bit case is to place siginfo and ucontext
at the same offsets as older kernels (see the comment in signal_32.c).
The 64-bit rt_sigframe starts with ucontext directly and does not need
this adjustment.

QEMU's setup_rt_frame() unconditionally used (SIGNAL_FRAMESIZE + 16)
for both 32-bit and 64-bit, placing the handler's SP 16 bytes too low
on ppc64. Signal delivery and return still worked because do_rt_sigreturn
had the matching wrong offset, but the vDSO DWARF unwind info encodes
the correct kernel offset. This caused any DWARF unwinder (libunwind,
libgcc, etc.) to compute a CFA that is 16 bytes off, reading garbage
register values from the signal frame.

Define RT_SIGFRAME_ADJUST (0 on ppc64, 16 on ppc32) and use it in both
setup_rt_frame and do_rt_sigreturn to match the kernel.

This was verified by A/B testing with libunwind's test suite:

  ppc64le: Gtest-bt, Ltest-bt, Gtest-concurrent, Ltest-concurrent,
           and Ltest-sig-context all change from FAIL to PASS.
  ppc64be: Gtest-bt, Ltest-bt, and Ltest-sig-context all change
           from FAIL to PASS.

Signed-off-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: qemu-stable@nongnu.org
---
 linux-user/ppc/signal.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c
index 24e5a02a78..a9c10e0987 100644
--- a/linux-user/ppc/signal.c
+++ b/linux-user/ppc/signal.c
@@ -210,6 +210,18 @@ QEMU_BUILD_BUG_ON(offsetof(struct target_rt_sigframe, uc.tuc_mcontext)
 
 #endif
 
+#ifdef TARGET_PPC64
+#define RT_SIGFRAME_ADJUST 0
+#else
+/*
+ * For 32-bit rt sigframes we have an extra 16 bytes of gap
+ * on top of __SIGNAL_FRAMESIZE; this is to get the siginfo
+ * and ucontext in the same positions as in older kernels.
+ * See Linux's arch/powerpc/kernel/signal_32.c.
+ */
+#define RT_SIGFRAME_ADJUST 16
+#endif
+
 #if defined(TARGET_PPC64)
 
 struct target_func_ptr {
@@ -525,7 +537,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
     env->fpscr = 0;
 
     /* Create a stack frame for the caller of the handler.  */
-    newsp = rt_sf_addr - (SIGNAL_FRAMESIZE + 16);
+    newsp = rt_sf_addr - (SIGNAL_FRAMESIZE + RT_SIGFRAME_ADJUST);
     err |= put_user(env->gpr[1], newsp, target_ulong);
 
     if (err)
@@ -641,7 +653,7 @@ long do_rt_sigreturn(CPUPPCState *env)
     struct target_rt_sigframe *rt_sf = NULL;
     target_ulong rt_sf_addr;
 
-    rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + 16;
+    rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + RT_SIGFRAME_ADJUST;
     if (!lock_user_struct(VERIFY_READ, rt_sf, rt_sf_addr, 1))
         goto sigsegv;
 
-- 
2.53.0



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

* [PULL 03/14] linux-user: fix off-by-one in host_to_target_for_each_rtattr()
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
  2026-04-25 15:51 ` [PULL 01/14] MAINTAINERS: Add myself as maintainer for linux-user Helge Deller
  2026-04-25 15:51 ` [PULL 02/14] linux-user/ppc: Fix ppc64 rt_sigframe stack offset Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 04/14] linux-user: Don't define target_stat64 struct for loongarch64 Helge Deller
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Yixin Wei <easonwei1998@gmail.com>

host_to_target_for_each_rtattr() uses "len > sizeof(struct rtattr)"
as its loop condition. When the last rtattr in a netlink message has
exactly sizeof(struct rtattr) (4) bytes remaining, the loop exits
without byte-swapping its rta_len and rta_type. A big-endian guest
then reads rta_len in the wrong byte order and fails validation.

The companion function target_to_host_for_each_rtattr() correctly
uses ">=" (added in commit fa2229dbf8). The kernel's RTA_OK macro
also uses ">=". Fix the host_to_target direction to match.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2485
Signed-off-by: Yixin Wei <yixinwei@meta.com>
Fixes: 6c5b5645ae0 ("linux-user: add rtnetlink(7) support")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: qemu-stable@nongnu.org
---
 linux-user/fd-trans.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
index 64dd0745d2..7f55a0690b 100644
--- a/linux-user/fd-trans.c
+++ b/linux-user/fd-trans.c
@@ -480,7 +480,7 @@ static abi_long host_to_target_for_each_rtattr(struct rtattr *rtattr,
     unsigned short aligned_rta_len;
     abi_long ret;
 
-    while (len > sizeof(struct rtattr)) {
+    while (len >= sizeof(struct rtattr)) {
         rta_len = rtattr->rta_len;
         if (rta_len < sizeof(struct rtattr) ||
             rta_len > len) {
-- 
2.53.0



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

* [PULL 04/14] linux-user: Don't define target_stat64 struct for loongarch64
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (2 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 03/14] linux-user: fix off-by-one in host_to_target_for_each_rtattr() Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 05/14] linux-user/arm/nwfpe: Replace user_registers with current_cpu Helge Deller
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Gyorgy Tamasi <gyorgy.tamasi@gmail.com>

The kernel defines 'struct stat64' only if
__BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64).
loongarch64 doesn't set __ARCH_WANT_STAT64, and it isn't 32-bit,
so it won't get this struct.

QEMU incorrectly does define a target_stat64 struct. However this
isn't causing any guest-visible problems, because defining the
target_stat64 struct and TARGET_HAS_STRUCT_STAT64 affects these
syscalls:
 TARGET_NR_stat64
 TARGET_NR_lstat64
 TARGET_NR_fstat64
 TARGET_NR_fstatat64
 TARGET_NR_newfstatat

For loongarch64 the only one of those we provide is newfstatat,
and that is actually a separate QEMU bug, because the kernel does
not provide that syscall for this architecture. No real guest
code will be using a syscall that doesn't exist in the ABI.

(Some of these syscalls are present in the loongarch64 "ABI1.0",
but that ABI was never accepted in the upstream kernel, and
QEMU does not model that ABI, only the "ABI2.0".)

Stop defining TARGET_HAS_STRUCT_STAT64 anyway, for consistency
with the kernel and to avoid confusion.

Note:
Commit message suggested by Peter Maydell <peter.maydell@linaro.org>

Signed-off-by: Gyorgy Tamasi <gyorgy.tamasi@gmail.com>
Tested-by: Gyorgy Tamasi <gyorgy.tamasi@gmail.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 679af640c0..6967306be4 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2005,7 +2005,7 @@ struct target_stat {
     abi_uint __unused5;
 };
 
-#if !defined(TARGET_RISCV64)
+#if !defined(TARGET_RISCV64) && !defined(TARGET_LOONGARCH64)
 #define TARGET_HAS_STRUCT_STAT64
 struct target_stat64 {
     abi_ullong st_dev;
-- 
2.53.0



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

* [PULL 05/14] linux-user/arm/nwfpe: Replace user_registers with current_cpu
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (3 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 04/14] linux-user: Don't define target_stat64 struct for loongarch64 Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 06/14] linux-user/arm/nwfpe: Use thread-local storage for qemufpa Helge Deller
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Richard Henderson <richard.henderson@linaro.org>

Use the thread-local variable current_cpu instead of
a global variable to access the general registers.
This also means we don't need to pass env to EmulateAll.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/arm/cpu_loop.c    |  2 +-
 linux-user/arm/nwfpe/fpa11.c |  9 +--------
 linux-user/arm/nwfpe/fpa11.h | 23 +++++++----------------
 3 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index 19874f4c72..262ab5cc41 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -215,7 +215,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is_thumb)
 static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode)
 {
     TaskState *ts = get_task_state(env_cpu(env));
-    int rc = EmulateAll(opcode, &ts->fpa, env);
+    int rc = EmulateAll(opcode, &ts->fpa);
     int raise, enabled;
 
     if (rc == 0) {
diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c
index 0f1afbd91d..44783934b2 100644
--- a/linux-user/arm/nwfpe/fpa11.c
+++ b/linux-user/arm/nwfpe/fpa11.c
@@ -30,7 +30,6 @@
 
 
 FPA11* qemufpa = NULL;
-CPUARMState* user_registers;
 
 /* Reset the FPA11 chip.  Called to initialize and reset the emulator. */
 void resetFPA11(void)
@@ -156,7 +155,7 @@ void SetRoundingPrecision(const unsigned int opcode)
 
 /* Emulate the instruction in the opcode. */
 /* ??? This is not thread safe.  */
-unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)
+unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa)
 {
   unsigned int nRc = 0;
 //  unsigned long flags;
@@ -173,12 +172,6 @@ unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs)
   }
 
   qemufpa=qfpa;
-  user_registers=qregs;
-
-#if 0
-  fprintf(stderr,"emulating FP insn 0x%08x, PC=0x%08x\n",
-          opcode, qregs[ARM_REG_PC]);
-#endif
   fpa11 = GET_FPA11();
 
   if (fpa11->initflag == 0)		/* good place for __builtin_expect */
diff --git a/linux-user/arm/nwfpe/fpa11.h b/linux-user/arm/nwfpe/fpa11.h
index d459c5da02..20f9d2eb81 100644
--- a/linux-user/arm/nwfpe/fpa11.h
+++ b/linux-user/arm/nwfpe/fpa11.h
@@ -25,15 +25,6 @@
 
 #define GET_FPA11() (qemufpa)
 
-/*
- * The processes registers are always at the very top of the 8K
- * stack+task struct.  Use the same method as 'current' uses to
- * reach them.
- */
-extern CPUARMState *user_registers;
-
-#define GET_USERREG() (user_registers)
-
 /* Need task_struct */
 //#include <linux/sched.h>
 
@@ -91,25 +82,25 @@ void SetRoundingPrecision(const unsigned int);
 
 static inline unsigned int readRegister(unsigned int reg)
 {
-    return (user_registers->regs[(reg)]);
+    CPUARMState *env = cpu_env(current_cpu);
+    return env->regs[reg];
 }
 
 static inline void writeRegister(unsigned int x, unsigned int y)
 {
-#if 0
-	printf("writing %d to r%d\n",y,x);
-#endif
-        user_registers->regs[(x)]=(y);
+    CPUARMState *env = cpu_env(current_cpu);
+    env->regs[x] = y;
 }
 
 static inline void writeConditionCodes(unsigned int x)
 {
-    cpsr_write(user_registers, x, CPSR_NZCV, CPSRWriteByInstr);
+    CPUARMState *env = cpu_env(current_cpu);
+    cpsr_write(env, x, CPSR_NZCV, CPSRWriteByInstr);
 }
 
 #define ARM_REG_PC 15
 
-unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs);
+unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa);
 
 unsigned int EmulateCPDO(const unsigned int);
 unsigned int EmulateCPDT(const unsigned int);
-- 
2.53.0



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

* [PULL 06/14] linux-user/arm/nwfpe: Use thread-local storage for qemufpa
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (4 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 05/14] linux-user/arm/nwfpe: Replace user_registers with current_cpu Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 07/14] linux-user/strace: Use pointer type for read and write values Helge Deller
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Richard Henderson <richard.henderson@linaro.org>

Fix the thread safety of the emulation by not storing a
pointer in global storage.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/arm/nwfpe/fpa11.c | 3 +--
 linux-user/arm/nwfpe/fpa11.h | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c
index 44783934b2..15888463f7 100644
--- a/linux-user/arm/nwfpe/fpa11.c
+++ b/linux-user/arm/nwfpe/fpa11.c
@@ -29,7 +29,7 @@
 //#include <asm/system.h>
 
 
-FPA11* qemufpa = NULL;
+__thread FPA11* qemufpa = NULL;
 
 /* Reset the FPA11 chip.  Called to initialize and reset the emulator. */
 void resetFPA11(void)
@@ -154,7 +154,6 @@ void SetRoundingPrecision(const unsigned int opcode)
 }
 
 /* Emulate the instruction in the opcode. */
-/* ??? This is not thread safe.  */
 unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa)
 {
   unsigned int nRc = 0;
diff --git a/linux-user/arm/nwfpe/fpa11.h b/linux-user/arm/nwfpe/fpa11.h
index 20f9d2eb81..659d38ae3a 100644
--- a/linux-user/arm/nwfpe/fpa11.h
+++ b/linux-user/arm/nwfpe/fpa11.h
@@ -74,7 +74,7 @@ typedef struct tagFPA11 {
     float_status fp_status;      /* QEMU float emulator status */
 } FPA11;
 
-extern FPA11* qemufpa;
+extern __thread FPA11* qemufpa;
 
 void resetFPA11(void);
 void SetRoundingMode(const unsigned int);
-- 
2.53.0



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

* [PULL 07/14] linux-user/strace: Use pointer type for read and write values
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (5 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 06/14] linux-user/arm/nwfpe: Use thread-local storage for qemufpa Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 08/14] linux-user/mips: sync k0 TLS for EF_MIPS_MACH_OCTEON userlands Helge Deller
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Alistair Francis <alistair.francis@wdc.com>

The stack pointer is being truncated as 32-bits for qemu-riscv64, so
let's use %p to print the syscall pointer argument.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3238
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.list | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index 35f001fecd..6162a407f9 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1114,7 +1114,7 @@
 { TARGET_NR_quotactl, "quotactl" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_read
-{ TARGET_NR_read, "read" , "%s(%d,%#x,%d)", NULL, NULL },
+{ TARGET_NR_read, "read" , "%s(%d,%p,%d)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_readahead
 { TARGET_NR_readahead, "readahead" , NULL, NULL, NULL },
@@ -1674,7 +1674,7 @@
                      print_syscall_ret_waitpid },
 #endif
 #ifdef TARGET_NR_write
-{ TARGET_NR_write, "write" , "%s(%d,%#x,%d)", NULL, NULL },
+{ TARGET_NR_write, "write" , "%s(%d,%p,%d)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_writev
 { TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL },
-- 
2.53.0



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

* [PULL 08/14] linux-user/mips: sync k0 TLS for EF_MIPS_MACH_OCTEON userlands
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (6 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 07/14] linux-user/strace: Use pointer type for read and write values Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 09/14] linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW Helge Deller
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: James Hilliard <james.hilliard1@gmail.com>

Cavium Octeon userspace is not following a generic MIPS Linux TLS
ABI rule here. Older Octeon glibc uses the k0 register as the fast
thread pointer, while newer Octeon2 and Octeon3 glibc variants use
the normal rdhwr $29 path.

linux-user already updates CP0_UserLocal for cpu_set_tls() and
TARGET_NR_set_thread_area, but it does not keep gpr[26]
synchronized. That leaves EF_MIPS_MACH_OCTEON userlands able to
complete set_thread_area() and still reach pthread startup or
pthread_self() with a stale k0 value.

Use the existing MIPS ELF machine flags from linux-user/elfload.c and
mirror CP0_UserLocal into gpr[26] only for EF_MIPS_MACH_OCTEON.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/elfload.c         | 3 +++
 linux-user/mips/target_cpu.h | 5 +++++
 linux-user/qemu.h            | 1 +
 linux-user/syscall.c         | 2 +-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 59b543f740..0e757787d2 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1476,6 +1476,9 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
     /* Usual start for brk is after all sections of the main executable. */
     info->brk = TARGET_PAGE_ALIGN(hiaddr + load_bias);
     info->elf_flags = ehdr->e_flags;
+#ifdef TARGET_MIPS
+    info->use_k0_tls = (ehdr->e_flags & EF_MIPS_MACH) == EF_MIPS_MACH_OCTEON;
+#endif
 
     prot_exec = PROT_EXEC;
 #ifdef TARGET_AARCH64
diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h
index c375616c55..2bbd0a81c5 100644
--- a/linux-user/mips/target_cpu.h
+++ b/linux-user/mips/target_cpu.h
@@ -35,7 +35,12 @@ static inline void cpu_clone_regs_parent(CPUMIPSState *env, unsigned flags)
 
 static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls)
 {
+    TaskState *ts = get_task_state(env_cpu(env));
+
     env->active_tc.CP0_UserLocal = newtls;
+    if (ts->info->use_k0_tls) {
+        env->active_tc.gpr[26] = newtls;
+    }
 }
 
 static inline abi_ulong get_sp_from_cpustate(CPUMIPSState *state)
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index cfe5f45fc4..7f98fb2607 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -65,6 +65,7 @@ struct image_info {
         uint32_t        note_flags;
 
 #ifdef TARGET_MIPS
+        bool            use_k0_tls;
         int             fp_abi;
         int             interp_fp_abi;
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f4b74ad350..8e96cc26db 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -13216,7 +13216,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_set_thread_area
     case TARGET_NR_set_thread_area:
 #if defined(TARGET_MIPS)
-      cpu_env->active_tc.CP0_UserLocal = arg1;
+      cpu_set_tls(cpu_env, arg1);
       return 0;
 #elif defined(TARGET_I386) && defined(TARGET_ABI32)
       return do_set_thread_area(cpu_env, arg1);
-- 
2.53.0



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

* [PULL 09/14] linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (7 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 08/14] linux-user/mips: sync k0 TLS for EF_MIPS_MACH_OCTEON userlands Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 10/14] linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW Helge Deller
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

Define the entries which always use the 64-bit timestamps.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/alpha/sockbits.h   | 7 +++++++
 linux-user/generic/sockbits.h | 8 ++++++++
 linux-user/hppa/sockbits.h    | 7 +++++++
 linux-user/mips/sockbits.h    | 7 +++++++
 linux-user/sparc/sockbits.h   | 7 +++++++
 5 files changed, 36 insertions(+)

diff --git a/linux-user/alpha/sockbits.h b/linux-user/alpha/sockbits.h
index d54dc98c09..0201ab9374 100644
--- a/linux-user/alpha/sockbits.h
+++ b/linux-user/alpha/sockbits.h
@@ -75,6 +75,13 @@
 /* Instruct lower device to use last 4-bytes of skb data as FCS */
 #define TARGET_SO_NOFCS     43
 
+#define TARGET_SO_TIMESTAMP_NEW        63
+#define TARGET_SO_TIMESTAMPNS_NEW      64
+#define TARGET_SO_TIMESTAMPING_NEW     65
+
+#define TARGET_SO_RCVTIMEO_NEW         66
+#define TARGET_SO_SNDTIMEO_NEW         67
+
 /* TARGET_O_NONBLOCK clashes with the bits used for socket types.  Therefore we
  * have to define SOCK_NONBLOCK to a different value here.
  */
diff --git a/linux-user/generic/sockbits.h b/linux-user/generic/sockbits.h
index b3b4a8e44c..33e6c3a572 100644
--- a/linux-user/generic/sockbits.h
+++ b/linux-user/generic/sockbits.h
@@ -58,4 +58,12 @@
 
 #define TARGET_SO_PROTOCOL             38
 #define TARGET_SO_DOMAIN               39
+
+#define TARGET_SO_TIMESTAMP_NEW        63
+#define TARGET_SO_TIMESTAMPNS_NEW      64
+#define TARGET_SO_TIMESTAMPING_NEW     65
+
+#define TARGET_SO_RCVTIMEO_NEW         66
+#define TARGET_SO_SNDTIMEO_NEW         67
+
 #endif
diff --git a/linux-user/hppa/sockbits.h b/linux-user/hppa/sockbits.h
index 23f69a3293..2304dbbf79 100644
--- a/linux-user/hppa/sockbits.h
+++ b/linux-user/hppa/sockbits.h
@@ -67,6 +67,13 @@
 
 #define TARGET_SO_CNX_ADVICE           0x402E
 
+#define TARGET_SO_TIMESTAMP_NEW        0x4038
+#define TARGET_SO_TIMESTAMPNS_NEW      0x4039
+#define TARGET_SO_TIMESTAMPING_NEW     0x403A
+
+#define TARGET_SO_RCVTIMEO_NEW         0x4040
+#define TARGET_SO_SNDTIMEO_NEW         0x4041
+
 /* TARGET_O_NONBLOCK clashes with the bits used for socket types.  Therefore we
  * have to define SOCK_NONBLOCK to a different value here.
  */
diff --git a/linux-user/mips/sockbits.h b/linux-user/mips/sockbits.h
index 562cad88e2..1f479d54aa 100644
--- a/linux-user/mips/sockbits.h
+++ b/linux-user/mips/sockbits.h
@@ -71,6 +71,13 @@
 #define TARGET_SO_RCVBUFFORCE          33
 #define TARGET_SO_PASSSEC              34
 
+#define TARGET_SO_TIMESTAMP_NEW        63
+#define TARGET_SO_TIMESTAMPNS_NEW      64
+#define TARGET_SO_TIMESTAMPING_NEW     65
+
+#define TARGET_SO_RCVTIMEO_NEW         66
+#define TARGET_SO_SNDTIMEO_NEW         67
+
 /** sock_type - Socket types
  *
  * Please notice that for binary compat reasons MIPS has to
diff --git a/linux-user/sparc/sockbits.h b/linux-user/sparc/sockbits.h
index 0a822e3e1f..42ecfdc8f9 100644
--- a/linux-user/sparc/sockbits.h
+++ b/linux-user/sparc/sockbits.h
@@ -61,6 +61,13 @@
 #define TARGET_SO_TIMESTAMPING         0x0023
 #define TARGET_SCM_TIMESTAMPING        TARGET_SO_TIMESTAMPING
 
+#define TARGET_SO_TIMESTAMP_NEW        0x0046
+#define TARGET_SO_TIMESTAMPNS_NEW      0x0042
+#define TARGET_SO_TIMESTAMPING_NEW     0x0043
+
+#define TARGET_SO_RCVTIMEO_NEW         0x0044
+#define TARGET_SO_SNDTIMEO_NEW         0x0045
+
 #define TARGET_SO_RXQ_OVFL             0x0024
 
 #define TARGET_SO_WIFI_STATUS          0x0025
-- 
2.53.0



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

* [PULL 10/14] linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (8 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 09/14] linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 11/14] linux-user: Add getsockopt() " Helge Deller
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

Add handlers for both sockopts which use 64-bit time_t from userspace.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/885
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8e96cc26db..751e6eabe5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1143,7 +1143,6 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,
     return 0;
 }
 
-#if defined(TARGET_NR_clock_adjtime64) && defined(CONFIG_CLOCK_ADJTIME)
 static inline abi_long copy_from_user_timeval64(struct timeval *tv,
                                                 abi_ulong target_tv_addr)
 {
@@ -1160,7 +1159,6 @@ static inline abi_long copy_from_user_timeval64(struct timeval *tv,
 
     return 0;
 }
-#endif
 
 static inline abi_long copy_to_user_timeval64(abi_ulong target_tv_addr,
                                               const struct timeval *tv)
@@ -2391,6 +2389,25 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
                                 &tv, sizeof(tv)));
                 return ret;
         }
+        case TARGET_SO_RCVTIMEO_NEW:
+        case TARGET_SO_SNDTIMEO_NEW:
+        {
+                struct timeval tv;
+
+                if (optlen != sizeof(struct target__kernel_sock_timeval)) {
+                    return -TARGET_EINVAL;
+                }
+
+                if (copy_from_user_timeval64(&tv, optval_addr)) {
+                    return -TARGET_EFAULT;
+                }
+
+                ret = get_errno(setsockopt(sockfd, SOL_SOCKET,
+                                optname == TARGET_SO_RCVTIMEO_NEW ?
+                                    SO_RCVTIMEO : SO_SNDTIMEO,
+                                &tv, sizeof(tv)));
+                return ret;
+        }
         case TARGET_SO_ATTACH_FILTER:
         {
                 struct target_sock_fprog *tfprog;
-- 
2.53.0



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

* [PULL 11/14] linux-user: Add getsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (9 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 10/14] linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 12/14] linux-user: Fix CLONE_PARENT_SETTID when using fork-like clone Helge Deller
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

Add handlers for both sockopts which use 64-bit time_t from userspace.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/885
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 751e6eabe5..d0390e04b4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2621,7 +2621,8 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         /* These don't just return a single integer */
         case TARGET_SO_PEERNAME:
             goto unimplemented;
-        case TARGET_SO_RCVTIMEO: {
+        case TARGET_SO_RCVTIMEO:
+        case TARGET_SO_RCVTIMEO_NEW: {
             struct timeval tv;
             socklen_t tvlen;
 
@@ -2641,11 +2642,17 @@ get_timeout:
             if (ret < 0) {
                 return ret;
             }
-            if (len > sizeof(struct target_timeval)) {
-                len = sizeof(struct target_timeval);
-            }
-            if (copy_to_user_timeval(optval_addr, &tv)) {
-                return -TARGET_EFAULT;
+            if (len == sizeof(struct target__kernel_sock_timeval)) {
+                if (copy_to_user_timeval64(optval_addr, &tv)) {
+                    return -TARGET_EFAULT;
+                }
+            } else {
+                if (len >= sizeof(struct target_timeval)) {
+                    len = sizeof(struct target_timeval);
+                    if (copy_to_user_timeval(optval_addr, &tv)) {
+                        return -TARGET_EFAULT;
+                    }
+                }
             }
             if (put_user_u32(len, optlen)) {
                 return -TARGET_EFAULT;
@@ -2653,6 +2660,7 @@ get_timeout:
             break;
         }
         case TARGET_SO_SNDTIMEO:
+        case TARGET_SO_SNDTIMEO_NEW:
             optname = SO_SNDTIMEO;
             goto get_timeout;
         case TARGET_SO_PEERCRED: {
-- 
2.53.0



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

* [PULL 12/14] linux-user: Fix CLONE_PARENT_SETTID when using fork-like clone
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (10 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 11/14] linux-user: Add getsockopt() " Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 13/14] linux-user: Use abi_int for imr_ifindex in ip_mreqn struct Helge Deller
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

The CLONE_PARENT_SETTID option requires the implementation to store the
child thread ID at the location pointed to by parent_tid in the parent's
memory.

Fix our implementation and move the code from the client side (where
fork returned 0), to the parent side and store the return value from the
fork call (which is the client TID) in the parent_tid pointer.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3340
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/syscall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d0390e04b4..910a4da0a6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7050,8 +7050,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
                the child process gets its own copy of the lock.  */
             if (flags & CLONE_CHILD_SETTID)
                 put_user_u32(sys_gettid(), child_tidptr);
-            if (flags & CLONE_PARENT_SETTID)
-                put_user_u32(sys_gettid(), parent_tidptr);
             ts = get_task_state(cpu);
             if (flags & CLONE_SETTLS)
                 cpu_set_tls (env, newtls);
@@ -7059,6 +7057,8 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
                 ts->child_tidptr = child_tidptr;
         } else {
             cpu_clone_regs_parent(env, flags);
+            if (flags & CLONE_PARENT_SETTID)
+                put_user_u32(ret, parent_tidptr);
             if (flags & CLONE_PIDFD) {
                 int pid_fd = 0;
 #if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open)
-- 
2.53.0



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

* [PULL 13/14] linux-user: Use abi_int for imr_ifindex in ip_mreqn struct
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (11 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 12/14] linux-user: Fix CLONE_PARENT_SETTID when using fork-like clone Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-25 15:51 ` [PULL 14/14] linux-user: Flush errors by using exit() instead of _exit() in error path Helge Deller
  2026-04-28 12:02 ` [PULL 00/14] Linux user next patches Stefan Hajnoczi
  14 siblings, 0 replies; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

Peter Hartley noticed, that in the qemu code the imr_ifindex member of
struct target_ip_mreq needs to be of type "int" instead of "long", which
is what the Linux kernel uses on all architectures.

Adjust the type accordingly, and add a QEMU_BUILD_BUG_ON() checker to
prevent such issues in the future.

This change should fix multicast issues when using hosts and guests with
different endianess or bit size.

Reported-by: Peter Hartley <peter@talesfromthearmchair.net>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2553
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall.c      | 2 ++
 linux-user/syscall_defs.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 910a4da0a6..4594909242 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2161,6 +2161,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
 
             QEMU_BUILD_BUG_ON(sizeof(struct ip_mreq) !=
                               sizeof(struct target_ip_mreq));
+            QEMU_BUILD_BUG_ON(sizeof(struct ip_mreqn) !=
+                              sizeof(struct target_ip_mreqn));
 
             if (optname == IP_MULTICAST_IF) {
                 min_size = sizeof(struct in_addr);
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 6967306be4..5799769f83 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -210,7 +210,7 @@ struct target_ip_mreq {
 struct target_ip_mreqn {
     struct target_in_addr imr_multiaddr;
     struct target_in_addr imr_address;
-    abi_long imr_ifindex;
+    abi_int imr_ifindex;
 };
 
 struct target_ip_mreq_source {
-- 
2.53.0



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

* [PULL 14/14] linux-user: Flush errors by using exit() instead of _exit() in error path
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (12 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 13/14] linux-user: Use abi_int for imr_ifindex in ip_mreqn struct Helge Deller
@ 2026-04-25 15:51 ` Helge Deller
  2026-04-27  6:28   ` Philippe Mathieu-Daudé
  2026-04-28 12:02 ` [PULL 00/14] Linux user next patches Stefan Hajnoczi
  14 siblings, 1 reply; 17+ messages in thread
From: Helge Deller @ 2026-04-25 15:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Philippe Mathieu-Daudé

From: Helge Deller <deller@gmx.de>

Qemu user mode does not properly flushes error messages related to bad
arguments when exiting (at least when the output is piped to a file
instead of running on a terminal).
Ensure that we always flush by using exit() instead of _exit().

Reported by: Tobias Bergkvist
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2544
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index c49d1e91d2..84e110dfe9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -767,7 +767,7 @@ int main(int argc, char **argv, char **envp)
         execfd = open(exec_path, O_RDONLY);
         if (execfd < 0) {
             printf("Error while loading %s: %s\n", exec_path, strerror(errno));
-            _exit(EXIT_FAILURE);
+            exit(EXIT_FAILURE);
         }
     }
 
-- 
2.53.0



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

* Re: [PULL 14/14] linux-user: Flush errors by using exit() instead of _exit() in error path
  2026-04-25 15:51 ` [PULL 14/14] linux-user: Flush errors by using exit() instead of _exit() in error path Helge Deller
@ 2026-04-27  6:28   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-04-27  6:28 UTC (permalink / raw)
  To: Helge Deller, qemu-devel
  Cc: Helge Deller, Jiaxun Yang, Laurent Vivier, Pierrick Bouvier,
	Tobias Bergkvist

On 25/4/26 17:51, Helge Deller wrote:
> From: Helge Deller <deller@gmx.de>
> 
> Qemu user mode does not properly flushes error messages related to bad
> arguments when exiting (at least when the output is piped to a file
> instead of running on a terminal).
> Ensure that we always flush by using exit() instead of _exit().
> 

Reported by: Tobias Bergkvist <tobias@bergkv.ist>
Reviewed-by: Warner Losh <imp@bsdimp.com>

> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2544
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/main.c b/linux-user/main.c
> index c49d1e91d2..84e110dfe9 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -767,7 +767,7 @@ int main(int argc, char **argv, char **envp)
>           execfd = open(exec_path, O_RDONLY);
>           if (execfd < 0) {
>               printf("Error while loading %s: %s\n", exec_path, strerror(errno));
> -            _exit(EXIT_FAILURE);
> +            exit(EXIT_FAILURE);
>           }
>       }
>   



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

* Re: [PULL 00/14] Linux user next patches
  2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
                   ` (13 preceding siblings ...)
  2026-04-25 15:51 ` [PULL 14/14] linux-user: Flush errors by using exit() instead of _exit() in error path Helge Deller
@ 2026-04-28 12:02 ` Stefan Hajnoczi
  14 siblings, 0 replies; 17+ messages in thread
From: Stefan Hajnoczi @ 2026-04-28 12:02 UTC (permalink / raw)
  To: Helge Deller
  Cc: qemu-devel, Helge Deller, Jiaxun Yang, Laurent Vivier,
	Pierrick Bouvier, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2026-04-28 13:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-25 15:51 [PULL 00/14] Linux user next patches Helge Deller
2026-04-25 15:51 ` [PULL 01/14] MAINTAINERS: Add myself as maintainer for linux-user Helge Deller
2026-04-25 15:51 ` [PULL 02/14] linux-user/ppc: Fix ppc64 rt_sigframe stack offset Helge Deller
2026-04-25 15:51 ` [PULL 03/14] linux-user: fix off-by-one in host_to_target_for_each_rtattr() Helge Deller
2026-04-25 15:51 ` [PULL 04/14] linux-user: Don't define target_stat64 struct for loongarch64 Helge Deller
2026-04-25 15:51 ` [PULL 05/14] linux-user/arm/nwfpe: Replace user_registers with current_cpu Helge Deller
2026-04-25 15:51 ` [PULL 06/14] linux-user/arm/nwfpe: Use thread-local storage for qemufpa Helge Deller
2026-04-25 15:51 ` [PULL 07/14] linux-user/strace: Use pointer type for read and write values Helge Deller
2026-04-25 15:51 ` [PULL 08/14] linux-user/mips: sync k0 TLS for EF_MIPS_MACH_OCTEON userlands Helge Deller
2026-04-25 15:51 ` [PULL 09/14] linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW Helge Deller
2026-04-25 15:51 ` [PULL 10/14] linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW Helge Deller
2026-04-25 15:51 ` [PULL 11/14] linux-user: Add getsockopt() " Helge Deller
2026-04-25 15:51 ` [PULL 12/14] linux-user: Fix CLONE_PARENT_SETTID when using fork-like clone Helge Deller
2026-04-25 15:51 ` [PULL 13/14] linux-user: Use abi_int for imr_ifindex in ip_mreqn struct Helge Deller
2026-04-25 15:51 ` [PULL 14/14] linux-user: Flush errors by using exit() instead of _exit() in error path Helge Deller
2026-04-27  6:28   ` Philippe Mathieu-Daudé
2026-04-28 12:02 ` [PULL 00/14] Linux user next patches Stefan Hajnoczi

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.