Skip to contentSkip to conversation

tcg/linux-user patch queue

GIT PULL Applied Richard Henderson 1 participant 15 messages Jan 11 – Jan 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following changes since commit b254e486242466dad881fc2bbfa215f1b67cd30f:

Merge tag 'pull-riscv-to-apply-20260109' of https://github.com/alistair23/qemu into staging (2026-01-10 10:31:57 +1100)

are available in the Git repository at:

https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20260112

for you to fetch changes up to 365a2248ae69f306fe7997fd966bcb1c16a08695:

meson: disable libatomic with GCC >= 16 (2026-01-12 08:49:33 +1100)

----------------------------------------------------------------
tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i} tcg/optimize: Fixes for o_mask and a_mask
linux-user: Correction to HWCAP2 accessor
linux-user: Fixes for mremap
linux-user: Implement epoll_pwait2 syscall
meson: disable libatomic with GCC >= 16

----------------------------------------------------------------
Daniel P. Berrangé (1):
meson: disable libatomic with GCC >= 16

Jean-Christian CÎRSTEA (1):
linux-user: allow null pathname for statx()/fstatat()

Jim MacArthur (1):
linux-user/elfload.c: Correction to HWCAP2 accessor

Matthew Lugg (4):
linux-user: fix mremap unmapping adjacent region
linux-user: fix mremap errors for invalid ranges
linux-user: fix reserved_va page leak in do_munmap
tests: add tcg coverage for fixed mremap bugs

Michael Tokarev (2):
linux-user: cleanup epoll_pwait ifdeff'ery
linux-user: implement epoll_pwait2 syscall

Paolo Bonzini (1):
tcg/optimize: Do use affected bits

Richard Henderson (3):
tcg/optimize: Save o_mask in fold_masks_zosa_int tcg/optimize: Fix a_mask computation for orc tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i}

 linux-user/elfload.c            |  2 +-
 linux-user/mmap.c               | 16 ++++++++------
 linux-user/syscall.c            | 47 +++++++++++++++++++++++++++--------------
 tcg/optimize.c                  |  7 +++---
 tests/tcg/multiarch/test-mmap.c | 42 ++++++++++++++++++++++++++++++++++--
 meson.build                     |  9 ++++++++
 tcg/riscv/tcg-target.c.inc      | 33 +++++++++++++++++------------
 7 files changed, 114 insertions(+), 42 deletions(-)
#1 lore raw

[PULL 02/13] tcg/optimize: Fix a_mask computation for orc

In computing a_mask, for or, we remove the bits from t1->o_mask which are known to be zero. For orc, the bits known to be zero are the inverse of those known to be one.

Fixes cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
---
 tcg/optimize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/optimize.c +1 -1
index 1f95da487b..db1d89396b 100644
@@ -2360,7 +2360,7 @@ static bool fold_orc(OptContext *ctx, TCGOp *op)
     s_mask = t1->s_mask & t2->s_mask;
 
     /* Affected bits are those not known one, masked by those known one. */
-    a_mask = ~t1->o_mask & t2->o_mask;
+    a_mask = ~t1->o_mask & ~t2->o_mask;
 
     return fold_masks_zosa(ctx, op, z_mask, o_mask, s_mask, a_mask);
 }
Signature · 1 line
2.43.0
#2 lore raw

[PULL 01/13] tcg/optimize: Save o_mask in fold_masks_zosa_int

In reply to Richard Henderson

When adding o_mask to this function, we used it in a couple of places but failed to save it for future use. Also, update a related comment.

Fixes 56f15f67ea1 ("tcg/optimize: Add one's mask to TempOptInfo")
---
 tcg/optimize.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tcg/optimize.c +2 -1
index f69702b26e..1f95da487b 100644
@@ -1088,8 +1088,9 @@ static bool fold_masks_zosa_int(OptContext *ctx, TCGOp *op,
 
     ti = ts_info(ts);
     ti->z_mask = z_mask;
+    ti->o_mask = o_mask;
 
-    /* Canonicalize s_mask and incorporate data from z_mask. */
+    /* Canonicalize s_mask and incorporate data from [zo]_mask. */
     rep = clz64(~s_mask);
     rep = MAX(rep, clz64(z_mask));
     rep = MAX(rep, clz64(~o_mask));
Signature · 1 line
2.43.0
#3 lore raw

[PULL 03/13] tcg/optimize: Do use affected bits

In reply to Richard Henderson

From: Paolo Bonzini <[email protected]>

We inadvertently disabled affected bits optimizations on operations that use fold_masks_zosa. These happen relatively often in x86 code for extract/sextract; for example given the following:

mov %esi, %ebp
xor $0x1, %ebp

the optimizer is able to simplify the "extract_i64 rbp,tmp0,$0x0,$0x20" produced by the second instruction to a move.

Fixes 932522a9ddc ("tcg/optimize: Fold and to extract during optimize")

Message-ID: <[email protected]>

---
 tcg/optimize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/optimize.c +1 -1
index db1d89396b..5ae26e4a10 100644
@@ -1103,7 +1103,7 @@ static bool fold_masks_zosa_int(OptContext *ctx, TCGOp *op,
 static bool fold_masks_zosa(OptContext *ctx, TCGOp *op, uint64_t z_mask,
                             uint64_t o_mask, int64_t s_mask, uint64_t a_mask)
 {
-    fold_masks_zosa_int(ctx, op, z_mask, o_mask, s_mask, -1);
+    fold_masks_zosa_int(ctx, op, z_mask, o_mask, s_mask, a_mask);
     return true;
 }
 
Signature · 1 line
2.43.0
#4 lore raw

[PULL 11/13] linux-user: cleanup epoll_pwait ifdeff'ery

In reply to Richard Henderson

From: Michael Tokarev <[email protected]>

All linux targets these days have epoll_pwait system call (while some miss epoll_wait, which is less generic). And all linux targets definitely has one or another epoll_*wait* system call - so whole code block dealing with this system call should always be present.

Remove the now-unneeded ifdef'fery.

Message-ID: <[email protected]>

---
 linux-user/syscall.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
linux-user/syscall.c +1 -7
index ee7c34027e..2c7e1eb5b2 100644
@@ -13619,13 +13619,10 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     }
 #endif
 
-#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait)
 #if defined(TARGET_NR_epoll_wait)
     case TARGET_NR_epoll_wait:
 #endif
-#if defined(TARGET_NR_epoll_pwait)
     case TARGET_NR_epoll_pwait:
-#endif
     {
         struct target_epoll_event *target_ep;
         struct epoll_event *ep;
@@ -13650,7 +13647,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         }
 
         switch (num) {
-#if defined(TARGET_NR_epoll_pwait)
         case TARGET_NR_epoll_pwait:
         {
             sigset_t *set = NULL;
@@ -13670,7 +13666,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             }
             break;
         }
-#endif
 #if defined(TARGET_NR_epoll_wait)
         case TARGET_NR_epoll_wait:
             ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout,
@@ -13694,8 +13689,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         g_free(ep);
         return ret;
     }
-#endif
-#endif
+#endif /* CONFIG_EPOLL */
 #ifdef TARGET_NR_prlimit64
     case TARGET_NR_prlimit64:
     {
Signature · 1 line
2.43.0
#5 lore raw

[PULL 13/13] meson: disable libatomic with GCC >= 16

In reply to Richard Henderson

From: Daniel P. Berrangé <[email protected]>

Historically it was required to ask for libatomic explicitly with -latomic, but with GCC >= 16 apps will get linked to libatomic whether they ask for it or not.

This invalidates QEMU's check for atomic op support for int128 which explicitly does NOT want to use the libatomic impl. As a result with GCC >= 16, QEMU is now getting linked to libatomic and is activating CONFIG_ATOMIC128. This in turn exposes a bug in GCC's libatomic.a static buld which is incompatible with the use of -static-pie leading to build failures like:

/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/16/libatomic.a(cas_16_.o): relocation R_X86_64_32 against hidden symbol `libat_compare_exchange_16_i1' can not be used when making a PIE object /usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

The newly introduced -fno-link-libatomic flag can be used to disable the new automatic linking of libatomic. Setting this in qemu_isa_flags early on ensures that the check for CONFIG_ATOMIC128 still works correctly.

Message-ID: <[email protected]>

---
 meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)
meson.build +9 -0
index db87358d62..56df08c10e 100644
@@ -445,6 +445,15 @@ if host_arch in ['i386', 'x86_64']
   endif
 endif
 
+# GCC >= 16 automatically tries to link libatomic for all programs.
+#
+# QEMU explicitly does NOT want to use libatomic for int128 types.
+#
+# Later checks assume we won't get atomic ops for int128 without
+# explicitly asking for -latomic, so we must disable GCC's new
+# automatic linking with the new -fno-link-libatomic flag
+qemu_isa_flags += cc.get_supported_arguments('-fno-link-libatomic')
+
 qemu_common_flags = qemu_isa_flags + qemu_common_flags
 
 if get_option('prefer_static')
Signature · 1 line
2.43.0
#6 lore raw

[PULL 10/13] tests: add tcg coverage for fixed mremap bugs

In reply to Richard Henderson

From: Matthew Lugg <[email protected]>

These tests cover the first two fixes in this patch series. The final patch is not covered because the bug it fixes is not easily observable by the guest.

Message-ID: <[email protected]>

---
 tests/tcg/multiarch/test-mmap.c | 42 +++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)
tests/tcg/multiarch/test-mmap.c +40 -2
index 96257f8ebe..e297f4b1e9 100644
@@ -22,6 +22,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -41,7 +42,7 @@ do                                                             \
   }                                                            \
 } while (0)
 
-unsigned char *dummybuf;
+unsigned char *dummybuf; /* length is 2*pagesize */
 static unsigned int pagesize;
 static unsigned int pagemask;
 int test_fd;
@@ -451,9 +452,45 @@ void check_invalid_mmaps(void)
     fail_unless(addr == MAP_FAILED);
     fail_unless(errno == ENOMEM);
 
+    /* Attempt to remap a region which exceeds the bounds of memory. */
+    addr = mremap((void *)((uintptr_t)pagesize * 10), SIZE_MAX & ~(size_t)pagemask, pagesize, 0);
+    fprintf(stdout, "%s mremap addr=%p", __func__, (void *)addr);
+    fail_unless(addr == MAP_FAILED);
+    fail_unless(errno == EFAULT);
+
     fprintf(stdout, " passed\n");
 }
 
+void check_shrink_mmaps(void)
+{
+    unsigned char *a, *b, *c;
+    a = mmap(NULL, pagesize * 2, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+    b = mmap(NULL, pagesize * 2, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+    c = mmap(NULL, pagesize * 2, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+    fail_unless(a != MAP_FAILED);
+    fail_unless(b != MAP_FAILED);
+    fail_unless(c != MAP_FAILED);
+
+    /* Ensure we can read the full mappings */
+    memcpy(dummybuf, a, 2 * pagesize);
+    memcpy(dummybuf, b, 2 * pagesize);
+    memcpy(dummybuf, c, 2 * pagesize);
+
+    /* Shrink the middle mapping in-place; the others should be unaffected */
+    b = mremap(b, pagesize * 2, pagesize, 0);
+    fail_unless(b != MAP_FAILED);
+
+    /* Ensure we can still access all valid mappings */
+    memcpy(dummybuf, a, 2 * pagesize);
+    memcpy(dummybuf, b, pagesize);
+    memcpy(dummybuf, c, 2 * pagesize);
+
+    munmap(a, 2 * pagesize);
+    munmap(b, pagesize);
+    munmap(c, 2 * pagesize);
+}
+
 int main(int argc, char **argv)
 {
 	char tempname[] = "/tmp/.cmmapXXXXXX";
@@ -468,7 +505,7 @@ int main(int argc, char **argv)
 
 	/* Assume pagesize is a power of two.  */
 	pagemask = pagesize - 1;
-	dummybuf = malloc (pagesize);
+	dummybuf = malloc (pagesize * 2);
 	printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask);
 
 	test_fd = mkstemp(tempname);
@@ -496,6 +533,7 @@ int main(int argc, char **argv)
 	check_file_fixed_eof_mmaps();
 	check_file_unfixed_eof_mmaps();
 	check_invalid_mmaps();
+    check_shrink_mmaps();
 
 	/* Fails at the moment.  */
 	/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
Signature · 1 line
2.43.0
#7 lore raw

[PULL 04/13] tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i}

In reply to Richard Henderson

TCG_REG_TMP0 may be used by set_vtype* to load the vtype parameter, so delay any other use of TCG_REG_TMP0 until the correct vtype has been installed.

Fixes d4be6ee1111 ("tcg/riscv: Implement vector mov/dup{m/i}")
---
 tcg/riscv/tcg-target.c.inc | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)
tcg/riscv/tcg-target.c.inc +19 -14
index 31b9f7d87a..0967a445a3 100644
@@ -1074,7 +1074,7 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val,
 }
 
 static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece,
-                                   TCGReg dst, TCGReg src)
+                            TCGReg dst, TCGReg src)
 {
     set_vtype_len_sew(s, type, vece);
     tcg_out_opc_vx(s, OPC_VMV_V_X, dst, 0, src);
@@ -1082,29 +1082,34 @@ static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece,
 }
 
 static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece,
-                                    TCGReg dst, TCGReg base, intptr_t offset)
+                             TCGReg dst, TCGReg base, intptr_t offset)
 {
+    /* Note set_vtype* may clobber TMP0, so do that first. */
+    set_vtype_len_sew(s, type, vece);
     tcg_out_ld(s, TCG_TYPE_REG, TCG_REG_TMP0, base, offset);
-    return tcg_out_dup_vec(s, type, vece, dst, TCG_REG_TMP0);
+    tcg_out_opc_vx(s, OPC_VMV_V_X, dst, 0, TCG_REG_TMP0);
+    return true;
 }
 
 static void tcg_out_dupi_vec(TCGContext *s, TCGType type, unsigned vece,
-                                    TCGReg dst, int64_t arg)
+                             TCGReg dst, int64_t arg)
 {
     /* Arg is replicated by VECE; extract the highest element. */
     arg >>= (-8 << vece) & 63;
 
-    if (arg >= -16 && arg < 16) {
-        if (arg == 0 || arg == -1) {
-            set_vtype_len(s, type);
-        } else {
-            set_vtype_len_sew(s, type, vece);
-        }
-        tcg_out_opc_vi(s, OPC_VMV_V_I, dst, 0, arg);
-        return;
+    /* Note set_vtype* may clobber TMP0, so do that first. */
+    if (arg == 0 || arg == -1) {
+        set_vtype_len(s, type);
+    } else {
+        set_vtype_len_sew(s, type, vece);
+    }
+
+    if (arg >= -16 && arg < 16) {
+        tcg_out_opc_vi(s, OPC_VMV_V_I, dst, 0, arg);
+    } else {
+        tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP0, arg);
+        tcg_out_opc_vx(s, OPC_VMV_V_X, dst, 0, TCG_REG_TMP0);
     }
-    tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP0, arg);
-    tcg_out_dup_vec(s, type, vece, dst, TCG_REG_TMP0);
 }
 
 static void tcg_out_br(TCGContext *s, TCGLabel *l)
Signature · 1 line
2.43.0
#8 lore raw

[PULL 09/13] linux-user: fix reserved_va page leak in do_munmap

In reply to Richard Henderson

From: Matthew Lugg <[email protected]>

The old logic had an off-by-one bug. For instance, assuming 4k pages on host and guest, if 'len' is '4097' (indicating to unmap 2 pages), then 'last = start + 4096', so 'real_last = start + 4095', so ultimately 'real_len = 4096'. I do not believe this could cause any observable bugs in guests, because target_munmap page-aligns the length it passes in. However, calls to this function in target_mremap do not page-align the length, so those calls could "drop" pages, leading to a part of the reserved region becoming unmapped. At worst, a host allocation could get mapped into that hole, then clobbered by a new guest mapping.

Message-ID: <[email protected]>

---
 linux-user/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/mmap.c +2 -2
index 6163f1a0d1..4bcfaf7894 100644
@@ -1029,9 +1029,9 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len)
     void *host_start;
     int prot;
 
-    last = start + len - 1;
+    last = ROUND_UP(start + len, TARGET_PAGE_SIZE) - 1;
     real_start = start & -host_page_size;
-    real_last = ROUND_UP(last, host_page_size) - 1;
+    real_last = ROUND_UP(last + 1, host_page_size) - 1;
 
     /*
      * If guest pages remain on the first or last host pages,
Signature · 1 line
2.43.0
#9 lore raw

[PULL 08/13] linux-user: fix mremap errors for invalid ranges

In reply to Richard Henderson

From: Matthew Lugg <[email protected]>

If an address range given to mremap is invalid (exceeds addressing bounds on the guest), we were previously returning ENOMEM, which is not correct. The manpage and the Linux kernel implementation both agree that if old_addr/old_size refer to an invalid address, EFAULT is returned, and if new_addr/new_size refer to an invalid address, EINVAL is returned.

Message-ID: <[email protected]>

---
 linux-user/mmap.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
linux-user/mmap.c +6 -3
index ef3833a2bb..6163f1a0d1 100644
@@ -1110,12 +1110,15 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
     int prot;
     void *host_addr;
 
-    if (!guest_range_valid_untagged(old_addr, old_size) ||
-        ((flags & MREMAP_FIXED) &&
+    if (((flags & MREMAP_FIXED) &&
          !guest_range_valid_untagged(new_addr, new_size)) ||
         ((flags & MREMAP_MAYMOVE) == 0 &&
          !guest_range_valid_untagged(old_addr, new_size))) {
-        errno = ENOMEM;
+        errno = EINVAL;
+        return -1;
+    }
+    if (!guest_range_valid_untagged(old_addr, old_size)) {
+        errno = EFAULT;
         return -1;
     }
 
Signature · 1 line
2.43.0
#10 lore raw

[PULL 07/13] linux-user: fix mremap unmapping adjacent region

In reply to Richard Henderson

From: Matthew Lugg <[email protected]>

This typo meant that calls to mremap which shrink a mapping by some N bytes would, when the virtual address space was pre-reserved (e.g. 32-bit guest on 64-bit host), unmap the N bytes following the *original* mapping.

Message-ID: <[email protected]>

---
 linux-user/mmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/mmap.c +2 -1
index 423c77856a..ef3833a2bb 100644
@@ -1171,7 +1171,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
                     errno = ENOMEM;
                     host_addr = MAP_FAILED;
                 } else if (reserved_va && old_size > new_size) {
-                    mmap_reserve_or_unmap(old_addr + old_size,
+                    /* Re-reserve pages we just shrunk out of the mapping */
+                    mmap_reserve_or_unmap(old_addr + new_size,
                                           old_size - new_size);
                 }
             }
Signature · 1 line
2.43.0
#11 lore raw

[PULL 05/13] linux-user: allow null `pathname` for statx()/fstatat()

In reply to Richard Henderson

From: Jean-Christian CÎRSTEA <[email protected]>

Since Linux 6.11, the path argument may be NULL.

Before this patch, qemu-*-linux-user failed with EFAULT when pathname was specified as NULL, even for Linux kernel hosts > 6.10. This patch fixes this issue by checking whether arg2 is 0. If so, don't return EFAULT, but instead perform the appropiate syscall and let the host's kernel handle null pathname.

Message-ID: <[email protected]>

---
 linux-user/syscall.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
linux-user/syscall.c +7 -3
index 2060e561a2..ee7c34027e 100644
@@ -12141,9 +12141,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             int dirfd = arg1;
             int flags = arg3;
 
-            p = lock_user_string(arg2);
-            if (p == NULL) {
-                return -TARGET_EFAULT;
+            p = NULL;
+            /* Since Linux 6.11, the path argument may be NULL */
+            if (arg2 != 0) {
+                p = lock_user_string(arg2);
+                if (p == NULL) {
+                    return -TARGET_EFAULT;
+                }
             }
 #if defined(__NR_statx)
             {
Signature · 1 line
2.43.0
#12 lore raw

[PULL 12/13] linux-user: implement epoll_pwait2 syscall

In reply to Richard Henderson

From: Michael Tokarev <[email protected]>

epoll_pwait2 is the same as epoll_pwait but with timeout being (a pointer to) struct timespec instead of an integer.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3210

Message-ID: <[email protected]>

---
 linux-user/syscall.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)
linux-user/syscall.c +23 -6
index 2c7e1eb5b2..67ad681098 100644
@@ -708,8 +708,11 @@ safe_syscall5(int, ppoll, struct pollfd *, ufds, unsigned int, nfds,
               size_t, sigsetsize)
 #endif
 safe_syscall6(int, epoll_pwait, int, epfd, struct epoll_event *, events,
-              int, maxevents, int, timeout, const sigset_t *, sigmask,
-              size_t, sigsetsize)
+              int, maxevents, int, timeout,
+              const sigset_t *, sigmask, size_t, sigsetsize)
+safe_syscall6(int, epoll_pwait2, int, epfd, struct epoll_event *, events,
+              int, maxevents, struct timespec *, timeout_ts,
+              const sigset_t *, sigmask, size_t, sigsetsize)
 #if defined(__NR_futex)
 safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
               const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -13623,12 +13626,20 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_epoll_wait:
 #endif
     case TARGET_NR_epoll_pwait:
+    case TARGET_NR_epoll_pwait2:
     {
         struct target_epoll_event *target_ep;
         struct epoll_event *ep;
         int epfd = arg1;
         int maxevents = arg3;
-        int timeout = arg4;
+        struct timespec ts, *timeout_ts = NULL;
+
+        if (num == TARGET_NR_epoll_pwait2 && arg4 != 0) {
+            if (target_to_host_timespec(&ts, arg4)) {
+                return -TARGET_EFAULT;
+            }
+            timeout_ts = &ts;
+        }
 
         if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
             return -TARGET_EINVAL;
@@ -13648,6 +13659,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
 
         switch (num) {
         case TARGET_NR_epoll_pwait:
+        case TARGET_NR_epoll_pwait2:
         {
             sigset_t *set = NULL;
 
@@ -13658,8 +13670,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
                 }
             }
 
-            ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout,
-                                             set, SIGSET_T_SIZE));
+            if (num == TARGET_NR_epoll_pwait) {
+                ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, arg4,
+                                                 set, SIGSET_T_SIZE));
+            } else {
+                ret = get_errno(safe_epoll_pwait2(epfd, ep, maxevents, timeout_ts,
+                                                  set, SIGSET_T_SIZE));
+            }
 
             if (set) {
                 finish_sigsuspend_mask(ret);
@@ -13668,7 +13685,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         }
 #if defined(TARGET_NR_epoll_wait)
         case TARGET_NR_epoll_wait:
-            ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout,
+            ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, arg4,
                                              NULL, 0));
             break;
 #endif
Signature · 1 line
2.43.0
#13 lore raw

[PULL 06/13] linux-user/elfload.c: Correction to HWCAP2 accessor

In reply to Richard Henderson

From: Jim MacArthur <[email protected]>

get_elf_hwcap was used when get_elf_hwcap2 should have been.

Fixes fcac98d0ba8b ("linux-user: Remove ELF_HWCAP2")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3259

Message-ID: <[email protected]>

---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
index 0002d5be2f..35471c0c9a 100644
@@ -708,7 +708,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
     NEW_AUX_ENT(AT_EXECFN, info->file_string);
 
     if (HAVE_ELF_HWCAP2) {
-        NEW_AUX_ENT(AT_HWCAP2, get_elf_hwcap(thread_cpu));
+        NEW_AUX_ENT(AT_HWCAP2, get_elf_hwcap2(thread_cpu));
     }
     if (u_base_platform) {
         NEW_AUX_ENT(AT_BASE_PLATFORM, u_base_platform);
Signature · 1 line
2.43.0
author Applied
#14 lore raw
In reply to Richard Henderson
Quoted 12 lines · Richard Henderson

The following changes since commit b254e486242466dad881fc2bbfa215f1b67cd30f:

   Merge tag 'pull-riscv-to-apply-20260109' ofhttps://github.com/alistair23/qemu into staging (2026-01-10 10:31:57 +1100)

are available in the Git repository at:

   https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20260112

for you to fetch changes up to 365a2248ae69f306fe7997fd966bcb1c16a08695:

   meson: disable libatomic with GCC >= 16 (2026-01-12 08:49:33 +1100)
Quoted 7 lines

----------------------------------------------------------------
tcg/riscv: Fix TCG_REG_TMP0 clobber in tcg_gen_dup{m,i} tcg/optimize: Fixes for o_mask and a_mask
linux-user: Correction to HWCAP2 accessor
linux-user: Fixes for mremap
linux-user: Implement epoll_pwait2 syscall
meson: disable libatomic with GCC >= 16

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.0 as appropriate.

r~