Linux user for 6.1 patches
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(-)
Signature · 1 line
2.31.1
[PULL 2/9] linux-user: Disable static assert involving __SIGRTMAX if it is missing
From: Michael Forney <[email protected]>
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
Message-Id: <[email protected]>
--- linux-user/signal.c | 2 ++ 1 file changed, 2 insertions(+)
linux-user/signal.c +2 -0
@@ -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 __SIGRTMAXQEMU_BUILD_BUG_ON (__SIGRTMAX +1 != _NSIG); +#endif static uint8_t host_to_target_signal_table[_NSIG] = { [SIGHUP ] =TARGET_SIGHUP , [SIGINT ] =TARGET_SIGINT ,
Signature · 1 line
2.31.1
[PULL 7/9] linux-user: Check for ieee128 fpbits in PPC64 HWCAP2 feature list
In reply to Laurent VivierFrom: Khem Raj <[email protected]>
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)
Message-Id: <[email protected]>
--- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
@@ -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
Signature · 1 line
2.31.1
[PULL 1/9] linux-user: Set CF_PARALLEL when mapping shared memory
In reply to Laurent VivierFrom: Richard Henderson <[email protected]>
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
Message-Id: <[email protected]>
--- linux-user/mmap.c | 14 ++++++++++++++ linux-user/syscall.c | 12 ++++++++++++ 2 files changed, 26 insertions(+)
linux-user/mmap.c +14 -0
@@ -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;
linux-user/syscall.c +12 -0
@@ -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 {
Signature · 1 line
2.31.1
[PULL 3/9] linux-user/trace-events: fix minor typo in format string
In reply to Laurent VivierFrom: Alex Bennée <[email protected]>
Message-Id: <[email protected]>
--- linux-user/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/trace-events +1 -1
@@ -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
Signature · 1 line
2.31.1
[PULL 8/9] linux-user: Fix incorrect use of feature-test-macros
In reply to Laurent VivierFrom: Michael Forney <[email protected]>
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.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
linux-user/syscall.c +3 -4
@@ -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,
Signature · 1 line
2.31.1
[PULL 5/9] linux-user: Let sigaction query SIGKILL/SIGSTOP
In reply to Laurent VivierFrom: Ilya Leoshkevich <[email protected]>
The kernel allows doing this, so let's allow this in qemu as well. Valgrind relies on this.
Message-Id: <[email protected]>
--- linux-user/signal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/signal.c +5 -1
@@ -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 ; }
Signature · 1 line
2.31.1
[PULL 4/9] linux-user: Implement pivot_root
In reply to Laurent VivierFrom: YAMAMOTO Takashi <[email protected]>
Used by runc.
Message-Id: <[email protected]>
--- linux-user/syscall.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
linux-user/syscall.c +21 -0
@@ -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 ;
Signature · 1 line
2.31.1
[PULL 9/9] linux-user: Use public sigev_notify_thread_id member if available
In reply to Laurent VivierFrom: Michael Forney <[email protected]>
_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
Message-Id: <[email protected]>
--- configure | 16 ++++++++++++++++ linux-user/syscall.c | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-)
configure +16 -0
@@ -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
linux-user/syscall.c +5 -1
@@ -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 ;
Signature · 1 line
2.31.1
[PULL 6/9] tests/tcg/linux-test: Check that sigaction can query SIGKILL/SIGSTOP
In reply to Laurent VivierFrom: Ilya Leoshkevich <[email protected]>
Verify that querying is allowed, but making changes isn't.
Message-Id: <[email protected]>
--- tests/tcg/multiarch/linux-test.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tests/tcg/multiarch/linux-test.c +9 -0
@@ -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
Signature · 1 line
2.31.1
Peter Maydell
AppliedQuoted 9 lines · 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.gittags/linux-user-for-6.1-pull-request
Quoted 8 lines
for you to fetch changes up to
96ff758c6e9cd5a01443ee15afbd0df4f00c37a8:linux-user: Use public
sigev_notify_thread_idmember 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