All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/9] Linux user for 6.1 patches
@ 2021-06-21 11:04 Laurent Vivier
  2021-06-21 11:04 ` [PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory Laurent Vivier
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier

The following changes since commit 1ea06abceec61b6f3ab33dadb0510b6e09fb61e2:

  Merge remote-tracking branch 'remotes/berrange-gitlab/tags/misc-fixes-pull-request' into staging (2021-06-14 15:59:13 +0100)

are available in the Git repository at:

  git://github.com/vivier/qemu.git tags/linux-user-for-6.1-pull-request

for you to fetch changes up to 96ff758c6e9cd5a01443ee15afbd0df4f00c37a8:

  linux-user: Use public sigev_notify_thread_id member if available (2021-06-20 16:41:47 +0200)

----------------------------------------------------------------
Linux-user pull request 20210621

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

Alex Bennée (1):
  linux-user/trace-events: fix minor typo in format string

Ilya Leoshkevich (2):
  linux-user: Let sigaction query SIGKILL/SIGSTOP
  tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP

Khem Raj (1):
  linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list

Michael Forney (3):
  linux-user: Disable static assert involving __SIGRTMAX if it is
    missing
  linux-user: Fix incorrect use of feature-test-macros
  linux-user: Use public sigev_notify_thread_id member if available

Richard Henderson (1):
  linux-user: Set CF_PARALLEL when mapping shared memory

YAMAMOTO Takashi (1):
  linux-user: Implement pivot_root

 configure                        | 16 +++++++++++
 linux-user/elfload.c             |  2 +-
 linux-user/mmap.c                | 14 ++++++++++
 linux-user/signal.c              |  8 +++++-
 linux-user/syscall.c             | 46 ++++++++++++++++++++++++++++----
 linux-user/trace-events          |  2 +-
 tests/tcg/multiarch/linux-test.c |  9 +++++++
 7 files changed, 89 insertions(+), 8 deletions(-)

-- 
2.31.1



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

* [PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 2/9] linux-user: Disable static assert involving __SIGRTMAX if it is missing Laurent Vivier
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée, Richard Henderson, Laurent Vivier

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

Signal the translator to use host atomic instructions for
guest operations, insofar as it is possible.  This is the
best we can do to allow the guest to interact atomically
with other processes.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/121
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210612060828.695332-1-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/mmap.c    | 14 ++++++++++++++
 linux-user/syscall.c | 12 ++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 7e3b2450368a..0e103859fed8 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -451,6 +451,20 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot,
         goto fail;
     }
 
+    /*
+     * If we're mapping shared memory, ensure we generate code for parallel
+     * execution and flush old translations.  This will work up to the level
+     * supported by the host -- anything that requires EXCP_ATOMIC will not
+     * be atomic with respect to an external process.
+     */
+    if (flags & MAP_SHARED) {
+        CPUState *cpu = thread_cpu;
+        if (!(cpu->tcg_cflags & CF_PARALLEL)) {
+            cpu->tcg_cflags |= CF_PARALLEL;
+            tb_flush(cpu);
+        }
+    }
+
     real_start = start & qemu_host_page_mask;
     host_offset = offset & qemu_host_page_mask;
 
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 974dd46c9a17..54037db8d66d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4603,6 +4603,7 @@ static inline abi_ulong target_shmlba(CPUArchState *cpu_env)
 static inline abi_ulong do_shmat(CPUArchState *cpu_env,
                                  int shmid, abi_ulong shmaddr, int shmflg)
 {
+    CPUState *cpu = env_cpu(cpu_env);
     abi_long raddr;
     void *host_raddr;
     struct shmid_ds shm_info;
@@ -4633,6 +4634,17 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env,
 
     mmap_lock();
 
+    /*
+     * We're mapping shared memory, so ensure we generate code for parallel
+     * execution and flush old translations.  This will work up to the level
+     * supported by the host -- anything that requires EXCP_ATOMIC will not
+     * be atomic with respect to an external process.
+     */
+    if (!(cpu->tcg_cflags & CF_PARALLEL)) {
+        cpu->tcg_cflags |= CF_PARALLEL;
+        tb_flush(cpu);
+    }
+
     if (shmaddr)
         host_raddr = shmat(shmid, (void *)g2h_untagged(shmaddr), shmflg);
     else {
-- 
2.31.1



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

* [PULL 2/9] linux-user: Disable static assert involving __SIGRTMAX if it is missing
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
  2021-06-21 11:04 ` [PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 3/9] linux-user/trace-events: fix minor typo in format string Laurent Vivier
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Michael Forney

From: Michael Forney <mforney@mforney.org>

This check is to ensure that the loop in signal_table_init() from
SIGRTMIN to SIGRTMAX falls within the bounds of host_to_target_signal_table
(_NSIG). However, it is not critical, since _NSIG is already defined
to be the one larger than the largest signal supported by the system
(as specified in the upcoming POSIX revision[0]).

musl libc does not define __SIGRTMAX, so disabling this check when
it is missing fixes one of the last remaining errors when building
qemu.

[0] https://www.austingroupbugs.net/view.php?id=741

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210526190203.4255-1-mforney@mforney.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/signal.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 9016896dcda0..0f19c59deee9 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -38,7 +38,9 @@ static void host_signal_handler(int host_signum, siginfo_t *info,
  * Signal number 0 is reserved for use as kill(pid, 0), to test whether
  * a process exists without sending it a signal.
  */
+#ifdef __SIGRTMAX
 QEMU_BUILD_BUG_ON(__SIGRTMAX + 1 != _NSIG);
+#endif
 static uint8_t host_to_target_signal_table[_NSIG] = {
     [SIGHUP] = TARGET_SIGHUP,
     [SIGINT] = TARGET_SIGINT,
-- 
2.31.1



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

* [PULL 3/9] linux-user/trace-events: fix minor typo in format string
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
  2021-06-21 11:04 ` [PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory Laurent Vivier
  2021-06-21 11:04 ` [PULL 2/9] linux-user: Disable static assert involving __SIGRTMAX if it is missing Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 4/9] linux-user: Implement pivot_root Laurent Vivier
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée, Laurent Vivier, Philippe Mathieu-Daudé

From: Alex Bennée <alex.bennee@linaro.org>

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210614144245.17660-1-alex.bennee@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/trace-events | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/trace-events b/linux-user/trace-events
index 1ec0d11ee3a9..e7d2f54e9401 100644
--- a/linux-user/trace-events
+++ b/linux-user/trace-events
@@ -11,7 +11,7 @@ user_do_rt_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr=0x%"PRIx
 user_do_sigreturn(void *env, uint64_t frame_addr) "env=%p frame_addr=0x%"PRIx64
 user_force_sig(void *env, int target_sig, int host_sig) "env=%p signal %d (host %d)"
 user_handle_signal(void *env, int target_sig) "env=%p signal %d"
-user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d (target %d("
+user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d (target %d)"
 user_queue_signal(void *env, int target_sig) "env=%p signal %d"
 user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_addr) "env=%p frame psw.addr 0x%"PRIx64 " current psw.addr 0x%"PRIx64
 
-- 
2.31.1



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

* [PULL 4/9] linux-user: Implement pivot_root
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (2 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 3/9] linux-user/trace-events: fix minor typo in format string Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 5/9] linux-user: Let sigaction query SIGKILL/SIGSTOP Laurent Vivier
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, YAMAMOTO Takashi

From: YAMAMOTO Takashi <yamamoto@midokura.com>

Used by runc.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210531055019.10149-6-yamamoto@midokura.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 54037db8d66d..723cb02d2a00 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8257,6 +8257,10 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
     return 0;
 }
 
+#if defined(TARGET_NR_pivot_root) && defined(__NR_pivot_root)
+_syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
+#endif
+
 /* This is an internal helper for do_syscall so that it is easier
  * to have a single return point, so that actions, such as logging
  * of syscall results, can be performed.
@@ -13220,6 +13224,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #endif
 
+#if defined(TARGET_NR_pivot_root)
+    case TARGET_NR_pivot_root:
+        {
+            void *p2;
+            p = lock_user_string(arg1); /* new_root */
+            p2 = lock_user_string(arg2); /* put_old */
+            if (!p || !p2) {
+                ret = -TARGET_EFAULT;
+            } else {
+                ret = get_errno(pivot_root(p, p2));
+            }
+            unlock_user(p2, arg2, 0);
+            unlock_user(p, arg1, 0);
+        }
+        return ret;
+#endif
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         return -TARGET_ENOSYS;
-- 
2.31.1



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

* [PULL 5/9] linux-user: Let sigaction query SIGKILL/SIGSTOP
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (3 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 4/9] linux-user: Implement pivot_root Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 6/9] tests/tcg/linux-test: Check that sigaction can " Laurent Vivier
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Ilya Leoshkevich

From: Ilya Leoshkevich <iii@linux.ibm.com>

The kernel allows doing this, so let's allow this in qemu as well.
Valgrind relies on this.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210601145600.3131040-2-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/signal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 0f19c59deee9..a8faea6f0909 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -853,7 +853,11 @@ int do_sigaction(int sig, const struct target_sigaction *act,
 
     trace_signal_do_sigaction_guest(sig, TARGET_NSIG);
 
-    if (sig < 1 || sig > TARGET_NSIG || sig == TARGET_SIGKILL || sig == TARGET_SIGSTOP) {
+    if (sig < 1 || sig > TARGET_NSIG) {
+        return -TARGET_EINVAL;
+    }
+
+    if (act && (sig == TARGET_SIGKILL || sig == TARGET_SIGSTOP)) {
         return -TARGET_EINVAL;
     }
 
-- 
2.31.1



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

* [PULL 6/9] tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (4 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 5/9] linux-user: Let sigaction query SIGKILL/SIGSTOP Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 7/9] linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list Laurent Vivier
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Ilya Leoshkevich

From: Ilya Leoshkevich <iii@linux.ibm.com>

Verify that querying is allowed, but making changes isn't.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210601145600.3131040-3-iii@linux.ibm.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 tests/tcg/multiarch/linux-test.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index 96bbad582318..c8c6aeddeb36 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -496,6 +496,15 @@ static void test_signal(void)
     sigemptyset(&act.sa_mask);
     act.sa_flags = 0;
     chk_error(sigaction(SIGSEGV, &act, NULL));
+
+    if (sigaction(SIGKILL, &act, NULL) == 0) {
+        error("sigaction(SIGKILL, &act, NULL) must not succeed");
+    }
+    if (sigaction(SIGSTOP, &act, NULL) == 0) {
+        error("sigaction(SIGSTOP, &act, NULL) must not succeed");
+    }
+    chk_error(sigaction(SIGKILL, NULL, &act));
+    chk_error(sigaction(SIGSTOP, NULL, &act));
 }
 
 #define SHM_SIZE 32768
-- 
2.31.1



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

* [PULL 7/9] linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (5 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 6/9] tests/tcg/linux-test: Check that sigaction can " Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 8/9] linux-user: Fix incorrect use of feature-test-macros Laurent Vivier
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Florian Weimer, Laurent Vivier, Khem Raj

From: Khem Raj <raj.khem@gmail.com>

glibc 2.34 is now checking for this in hwcaps at
runtime [1] and failing to run the binary if machine
does not support 128bit IEEE fp

Fixes
Fatal glibc error: CPU lacks float128 support (POWER 9 or later required)

[1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d337345ce145e23c5f3a956f349d924fdf54ce2d;hp=eb24865637a271ab7dad13190330105eab0d478d

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210614191729.2981488-1-raj.khem@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 17ab06f612dd..e7dd18fd40bf 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -830,7 +830,7 @@ static uint32_t get_elf_hwcap2(void)
                   PPC2_ISA207S), QEMU_PPC_FEATURE2_ARCH_2_07 |
                   QEMU_PPC_FEATURE2_VEC_CRYPTO);
     GET_FEATURE2(PPC2_ISA300, QEMU_PPC_FEATURE2_ARCH_3_00 |
-                 QEMU_PPC_FEATURE2_DARN);
+                 QEMU_PPC_FEATURE2_DARN | QEMU_PPC_FEATURE2_HAS_IEEE128);
 
 #undef GET_FEATURE
 #undef GET_FEATURE2
-- 
2.31.1



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

* [PULL 8/9] linux-user: Fix incorrect use of feature-test-macros
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (6 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 7/9] linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-21 11:04 ` [PULL 9/9] linux-user: Use public sigev_notify_thread_id member if available Laurent Vivier
  2021-06-22 17:13 ` [PULL 0/9] Linux user for 6.1 patches Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Michael Forney

From: Michael Forney <mforney@mforney.org>

The _POSIX_C_SOURCE and _XOPEN_SOURCE macros are used by the
application to indicate to libc which declarations it should expose.
Since qemu does not define them anywhere, it does not make sense
to check their value.

Instead, since the intent is to determine whether the host struct
stat supports the st_*tim fields, use the configure test result
which does exactly that.

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210526035531.7871-1-mforney@mforney.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 723cb02d2a00..70ae8884ee54 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7482,7 +7482,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
         __put_user(host_st->st_atime, &target_st->target_st_atime);
         __put_user(host_st->st_mtime, &target_st->target_st_mtime);
         __put_user(host_st->st_ctime, &target_st->target_st_ctime);
-#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
         __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
         __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
         __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
@@ -7517,7 +7517,7 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
         __put_user(host_st->st_atime, &target_st->target_st_atime);
         __put_user(host_st->st_mtime, &target_st->target_st_mtime);
         __put_user(host_st->st_ctime, &target_st->target_st_ctime);
-#if _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
         __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec);
         __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec);
         __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec);
@@ -10072,8 +10072,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 __put_user(st.st_atime, &target_st->target_st_atime);
                 __put_user(st.st_mtime, &target_st->target_st_mtime);
                 __put_user(st.st_ctime, &target_st->target_st_ctime);
-#if (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) && \
-    defined(TARGET_STAT_HAVE_NSEC)
+#if defined(HAVE_STRUCT_STAT_ST_ATIM) && defined(TARGET_STAT_HAVE_NSEC)
                 __put_user(st.st_atim.tv_nsec,
                            &target_st->target_st_atime_nsec);
                 __put_user(st.st_mtim.tv_nsec,
-- 
2.31.1



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

* [PULL 9/9] linux-user: Use public sigev_notify_thread_id member if available
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (7 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 8/9] linux-user: Fix incorrect use of feature-test-macros Laurent Vivier
@ 2021-06-21 11:04 ` Laurent Vivier
  2021-06-22 17:13 ` [PULL 0/9] Linux user for 6.1 patches Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2021-06-21 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Michael Forney

From: Michael Forney <mforney@mforney.org>

_sigev_un._tid is an internal glibc field and is not available on
musl libc. The sigevent(7) man page and Linux UAPI headers both use
sigev_notify_thread_id as a public way to access this field.

musl libc supports this field since 1.2.2[0], and glibc plans to
add support as well[1][2].

If sigev_notify_thread_id is not available, fall back to _sigev_un._tid
as before.

[0] http://git.musl-libc.org/cgit/musl/commit/?id=7c71792e87691451f2a6b76348e83ad1889f1dcb
[1] https://www.openwall.com/lists/musl/2019/08/01/5
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27417

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210526035556.7931-1-mforney@mforney.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 configure            | 16 ++++++++++++++++
 linux-user/syscall.c |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 8dcb9965b24e..942c531cce63 100755
--- a/configure
+++ b/configure
@@ -4440,6 +4440,19 @@ if compile_prog "" "" ; then
     st_atim=yes
 fi
 
+##########################################
+# check if we have sigev_notify_thread_id
+
+sigev_notify_thread_id=no
+cat > $TMPC << EOF
+#include <stddef.h>
+#include <signal.h>
+int main(void) { return offsetof(struct sigevent, sigev_notify_thread_id); }
+EOF
+if compile_prog "" "" ; then
+    sigev_notify_thread_id=yes
+fi
+
 ##########################################
 # check if trace backend exists
 
@@ -5692,6 +5705,9 @@ fi
 if test "$st_atim" = "yes" ; then
   echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
 fi
+if test "$sigev_notify_thread_id" = "yes" ; then
+  echo "HAVE_SIGEV_NOTIFY_THREAD_ID=y" >> $config_host_mak
+fi
 if test "$byteswap_h" = "yes" ; then
   echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
 fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 70ae8884ee54..64bbf331b282 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7405,6 +7405,10 @@ static inline abi_long host_to_target_timex64(abi_long target_addr,
 }
 #endif
 
+#ifndef HAVE_SIGEV_NOTIFY_THREAD_ID
+#define sigev_notify_thread_id _sigev_un._tid
+#endif
+
 static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
                                                abi_ulong target_addr)
 {
@@ -7425,7 +7429,7 @@ static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
     host_sevp->sigev_signo =
         target_to_host_signal(tswap32(target_sevp->sigev_signo));
     host_sevp->sigev_notify = tswap32(target_sevp->sigev_notify);
-    host_sevp->_sigev_un._tid = tswap32(target_sevp->_sigev_un._tid);
+    host_sevp->sigev_notify_thread_id = tswap32(target_sevp->_sigev_un._tid);
 
     unlock_user_struct(target_sevp, target_addr, 1);
     return 0;
-- 
2.31.1



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

* Re: [PULL 0/9] Linux user for 6.1 patches
  2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
                   ` (8 preceding siblings ...)
  2021-06-21 11:04 ` [PULL 9/9] linux-user: Use public sigev_notify_thread_id member if available Laurent Vivier
@ 2021-06-22 17:13 ` Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2021-06-22 17:13 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: QEMU Developers

On Mon, 21 Jun 2021 at 12:07, Laurent Vivier <laurent@vivier.eu> wrote:
>
> The following changes since commit 1ea06abceec61b6f3ab33dadb0510b6e09fb61e2:
>
>   Merge remote-tracking branch 'remotes/berrange-gitlab/tags/misc-fixes-pull-request' into staging (2021-06-14 15:59:13 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/vivier/qemu.git tags/linux-user-for-6.1-pull-request
>
> for you to fetch changes up to 96ff758c6e9cd5a01443ee15afbd0df4f00c37a8:
>
>   linux-user: Use public sigev_notify_thread_id member if available (2021-06-20 16:41:47 +0200)
>
> ----------------------------------------------------------------
> Linux-user pull request 20210621
>
> ----------------------------------------------------------------


Applied, thanks.

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

-- PMM


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

end of thread, other threads:[~2021-06-22 17:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 11:04 [PULL 0/9] Linux user for 6.1 patches Laurent Vivier
2021-06-21 11:04 ` [PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory Laurent Vivier
2021-06-21 11:04 ` [PULL 2/9] linux-user: Disable static assert involving __SIGRTMAX if it is missing Laurent Vivier
2021-06-21 11:04 ` [PULL 3/9] linux-user/trace-events: fix minor typo in format string Laurent Vivier
2021-06-21 11:04 ` [PULL 4/9] linux-user: Implement pivot_root Laurent Vivier
2021-06-21 11:04 ` [PULL 5/9] linux-user: Let sigaction query SIGKILL/SIGSTOP Laurent Vivier
2021-06-21 11:04 ` [PULL 6/9] tests/tcg/linux-test: Check that sigaction can " Laurent Vivier
2021-06-21 11:04 ` [PULL 7/9] linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list Laurent Vivier
2021-06-21 11:04 ` [PULL 8/9] linux-user: Fix incorrect use of feature-test-macros Laurent Vivier
2021-06-21 11:04 ` [PULL 9/9] linux-user: Use public sigev_notify_thread_id member if available Laurent Vivier
2021-06-22 17:13 ` [PULL 0/9] Linux user for 6.1 patches Peter Maydell

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.