linux-user: A set of miscellaneous patches
v15 cover linux-user: A set of miscellaneous patches
From: Aleksandar Markovic <[email protected]>
This is a collection of misc patches for Linux user that I recently accumulated from variuous sources. All of them originate from problems observed on mips target. However, most of these changes actually affect and fix linux-user problems on multiple targets.
There are three checkpatch warninhs and two checkpatch errors that sould be ignored in the given circumstances.
NOTE: Two checkpatch errors and three warnings are false alarms.
v14->v15:
- removed inclusion of sys/stat.h from patch #1
- a minor correction in the commit message for patch #3
- amended patch #5 to reflect the kernel behavior wrt FPE
v13->v14:
- several minor corrections in commit messages
v12->v13:
- removed two patches that got accepted
- simplified the patch on statx()
- added a patch on TARGET_HAVE_ARCH_STRUCT_FLOCK
- added a patch on fixing EXCP_FPE handling on MIPS
v11->v12:
- used the preffered Laurent's email address for linux-user
- added a note on checkpetch warnings and errors in the commit letter
v10->v11:
- patch on <ADD|DROP>_MEMEBERSHIP basically reverted to its first version
- corrected patch on statx()
- added patch on strace support for statx()
- added patch on fixing flock structure for MIPS O64 ABI
v9->v10:
- improved commit messages for patches 2 and 3
v8->v9:
- fixed build error on some systems related to SOL_ALG
v7->v8:
- added a patch on setsockopt() option SOL_ALG
v6->v7:
- fixed a build error for older kernels related to the patch on setsockopt() options
- removed four patches that on the meantime got accepted into the main source tree
v5->v6:
- fixed a mistake in patch #4
- improved commit messages in patches #4 and #6
v4->v5:
- added the patch on statx() support
- improved the patch on IPV6_<ADD|DROP>_MEMBERSHIP to take into account the possibility of different names for a field
- minor corrections in commit messages
v3->v4:
- improved commit messages (fixed some typos, improved relevance)
v2->v3:
- updated and improved commit messages
- added IPV6_DROP_MEMBERSHIP support to the patch on setsockopt()'s option
v1->v2:
- added the patch on setsockopt()'s option IPV6_ADD_MEMBERSHIP
- improved the commit messages
Aleksandar Markovic (3):
linux-user: Fix target_flock structure for MIPS O64 ABI
linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK
linux-user: Handle EXCP_FPE properly for MIPS
Aleksandar Rikalo (1):
linux-user: Add support for translation of statx() syscall
Jim Wilson (1):
linux-user: Add support for strace for statx() syscall
linux-user/generic/fcntl.h | 8 +-- linux-user/mips/cpu_loop.c | 17 ++++++ linux-user/mips/target_fcntl.h | 17 +++++- linux-user/strace.c | 86 +++++++++++++++++++++++++++++++ linux-user/strace.list | 3 ++ linux-user/syscall.c | 114 ++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 37 +++++++++++++ 7 files changed, 276 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
PATCH v15 1/5 linux-user: Add support for translation of statx() syscall
From: Aleksandar Rikalo <[email protected]>
Implement support for translation of system call statx().
The implementation is based on "best effort" approach: if host is capable of executing statx(), host statx() is used. If not, the implementation includes invoking a more mature system call fstatat() on the host side to achieve as close as possible functionality.
Support for statx() in kernel and glibc was, however, introduced at different points of time (the difference is more than a year):
- kernel: Linux 4.11 (30 April 2017)
- glibc: glibc 2.28 (1 Aug 2018)
In this patch, the availability of statx() support is established via __NR_statx (if it is defined, statx() is considered available). This coincedes with statx() introduction in kernel.
However, the structure statx definition may not be available in any header for hosts with glibc older than 2.28 (and it is, by design, to be defined in one of glibc headers), even though the full statx() functionality may be supported in kernel. Hence, a structure "target_statx" is defined in this patch, to remove that dependency on glibc headers, and to use statx() functionality as soon as the host kernel is capable of supporting it. Such statx structure definition is used for both target and host structures statx (of course, this doesn't mean the endian arrangement is the same on target and host - the endian conversion is done in all necessary cases).
--- linux-user/syscall.c | 114 +++++++++++++++++++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 37 +++++++++++++++ 2 files changed, 150 insertions(+), 1 deletion(-)
linux-user/syscall.c +113 -1
@@ -315,6 +315,14 @@ _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type, unsigned long, idx1, unsigned long, idx2)#endif +/* +* It is assumed that struct statx is architecture independent. +*/ +#if defined(TARGET_NR_statx) && defined(__NR_statx) +_syscall5(int, statx, int, dirfd, const char *, pathname, int, flags, + unsigned int, mask, struct target_statx *, statxbuf) +#endif +static bitmask_transtbl fcntl_flags_tbl[] = { {TARGET_O_ACCMODE ,TARGET_O_WRONLY ,O_ACCMODE ,O_WRONLY , }, {TARGET_O_ACCMODE ,TARGET_O_RDWR ,O_ACCMODE ,O_RDWR , },
@@ -6467,6 +6475,48 @@ static inline abi_long host_to_target_stat64(void *cpu_env, }#endif +#if defined(TARGET_NR_statx) && defined(__NR_statx) +static inline abi_long host_to_target_statx (struct target_statx *host_stx, +abi_ulong target_addr) +{ +struct target_statx *target_stx; + +if (!lock_user_struct (VERIFY_WRITE , target_stx, target_addr,0 )) { +return -TARGET_EFAULT ; + } +memset (target_stx,0 ,sizeof (*target_stx)); + +__put_user (host_stx->stx_mask, &target_stx->stx_mask); +__put_user (host_stx->stx_blksize, &target_stx->stx_blksize); +__put_user (host_stx->stx_attributes, &target_stx->stx_attributes); +__put_user (host_stx->stx_nlink, &target_stx->stx_nlink); +__put_user (host_stx->stx_uid, &target_stx->stx_uid); +__put_user (host_stx->stx_gid, &target_stx->stx_gid); +__put_user (host_stx->stx_mode, &target_stx->stx_mode); +__put_user (host_stx->stx_ino, &target_stx->stx_ino); +__put_user (host_stx->stx_size, &target_stx->stx_size); +__put_user (host_stx->stx_blocks, &target_stx->stx_blocks); +__put_user (host_stx->stx_attributes_mask, &target_stx->stx_attributes_mask); +__put_user (host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); +__put_user (host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec); +__put_user (host_stx->stx_btime.tv_sec, &target_stx->stx_atime.tv_sec); +__put_user (host_stx->stx_btime.tv_nsec, &target_stx->stx_atime.tv_nsec); +__put_user (host_stx->stx_ctime.tv_sec, &target_stx->stx_atime.tv_sec); +__put_user (host_stx->stx_ctime.tv_nsec, &target_stx->stx_atime.tv_nsec); +__put_user (host_stx->stx_mtime.tv_sec, &target_stx->stx_atime.tv_sec); +__put_user (host_stx->stx_mtime.tv_nsec, &target_stx->stx_atime.tv_nsec); +__put_user (host_stx->stx_rdev_major, &target_stx->stx_rdev_major); +__put_user (host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); +__put_user (host_stx->stx_dev_major, &target_stx->stx_dev_major); +__put_user (host_stx->stx_dev_minor, &target_stx->stx_dev_minor); + +unlock_user_struct (target_stx, target_addr,1 ); + +return 0 ; +} +#endif + +/* ??? Using host futex calls even when target atomic operations are not really atomic probably breaks things. However implementing futexes locally would make futexes shared between multiple processes
@@ -7045,7 +7095,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,abi_long ret;#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) \ || defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) \ - || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) + || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) \ + || defined(TARGET_NR_statx)struct stat st;#endif #if defined(TARGET_NR_statfs) || defined(TARGET_NR_statfs64) \
@@ -10123,6 +10174,67 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_stat64 (cpu_env, arg3, &st);return ret;#endif +#if defined(TARGET_NR_statx) +case TARGET_NR_statx: + { +struct target_statx *target_stx; +int dirfd = arg1; +int flags = arg3; + + p =lock_user_string (arg2); +if (p ==NULL ) { +return -TARGET_EFAULT ; + } +#if defined(__NR_statx) + { +/* +* It is assumed that struct statx is architecture independent. +*/ +struct target_statx host_stx; +int mask = arg4; + + ret =get_errno (statx (dirfd, p, flags, mask, &host_stx)); +if (!is_error (ret)) { +if (host_to_target_statx (&host_stx, arg5) !=0 ) { +unlock_user (p, arg2,0 ); +return -TARGET_EFAULT ; + } + } + +if (ret != -TARGET_ENOSYS ) { +unlock_user (p, arg2,0 ); +return ret; + } + } +#endif + ret =get_errno (fstatat (dirfd,path (p), &st, flags)); +unlock_user (p, arg2,0 ); + +if (!is_error (ret)) { +if (!lock_user_struct (VERIFY_WRITE , target_stx, arg5,0 )) { +return -TARGET_EFAULT ; + } +memset (target_stx,0 ,sizeof (*target_stx)); +__put_user (major (st.st_dev), &target_stx->stx_dev_major); +__put_user (minor (st.st_dev), &target_stx->stx_dev_minor); +__put_user (st.st_ino, &target_stx->stx_ino); +__put_user (st.st_mode, &target_stx->stx_mode); +__put_user (st.st_uid, &target_stx->stx_uid); +__put_user (st.st_gid, &target_stx->stx_gid); +__put_user (st.st_nlink, &target_stx->stx_nlink); +__put_user (major (st.st_rdev), &target_stx->stx_rdev_major); +__put_user (minor (st.st_rdev), &target_stx->stx_rdev_minor); +__put_user (st.st_size, &target_stx->stx_size); +__put_user (st.st_blksize, &target_stx->stx_blksize); +__put_user (st.st_blocks, &target_stx->stx_blocks); +__put_user (st.st_atime, &target_stx->stx_atime.tv_sec); +__put_user (st.st_mtime, &target_stx->stx_mtime.tv_sec); +__put_user (st.st_ctime, &target_stx->stx_ctime.tv_sec); +unlock_user_struct (target_stx, arg5,1 ); + } + } +return ret; +#endif #ifdef TARGET_NR_lchowncase TARGET_NR_lchown:if (!(p =lock_user_string (arg1)))
linux-user/syscall_defs.h +37 -0
@@ -2536,4 +2536,41 @@ struct target_user_cap_data {/* Return size of the log buffer */ #define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10 +struct target_statx_timestamp { +int64_t tv_sec; +uint32_t tv_nsec; +int32_t __reserved; +}; + +struct target_statx { +/* 0x00 */ +uint32_t stx_mask;/* What results were written [uncond] */ +uint32_t stx_blksize;/* Preferred general I/O size [uncond] */ +uint64_t stx_attributes;/* Flags conveying information about the file */ +/* 0x10 */ +uint32_t stx_nlink;/* Number of hard links */ +uint32_t stx_uid;/* User ID of owner */ +uint32_t stx_gid;/* Group ID of owner */ +uint16_t stx_mode;/* File mode */ +uint16_t __spare0[1 ]; +/* 0x20 */ +uint64_t stx_ino;/* Inode number */ +uint64_t stx_size;/* File size */ +uint64_t stx_blocks;/* Number of 512-byte blocks allocated */ +uint64_t stx_attributes_mask;/* Mask to show what is supported */ +/* 0x40 */ +struct target_statx_timestamp stx_atime;/* Last access time */ +struct target_statx_timestamp stx_btime;/* File creation time */ +struct target_statx_timestamp stx_ctime;/* Last attribute change time */ +struct target_statx_timestamp stx_mtime;/* Last data modification time */ +/* 0x80 */ +uint32_t stx_rdev_major;/* Device ID of special file [if bdev/cdev] */ +uint32_t stx_rdev_minor; +uint32_t stx_dev_major;/* ID of device containing file [uncond] */ +uint32_t stx_dev_minor; +/* 0x90 */ +uint64_t __spare2[14 ];/* Spare space for future expansion */ +/* 0x100 */ +}; +#endif
Signature · 1 line
2.7.4
PATCH v15 2/5 linux-user: Add support for strace for statx() syscall
In reply to Aleksandar MarkovicFrom: Jim Wilson <[email protected]>
All of the flags need to be conditional as old systems don't have statx support. Otherwise it works the same as other stat family syscalls. This requires the pending patch to add statx support.
Tested on Ubuntu 16.04 (no host statx) and Ubuntu 19.04 (with host statx) using a riscv32-linux toolchain.
--- linux-user/strace.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 3 ++ 2 files changed, 89 insertions(+)
linux-user/strace.c +86 -0
@@ -976,6 +976,76 @@ UNUSED static struct flags msg_flags[] = { FLAG_END, }; +UNUSED static struct flags statx_flags[] = { +#ifdef AT_EMPTY_PATH + FLAG_GENERIC(AT_EMPTY_PATH), +#endif +#ifdef AT_NO_AUTOMOUNT + FLAG_GENERIC(AT_NO_AUTOMOUNT), +#endif +#ifdef AT_SYMLINK_NOFOLLOW + FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), +#endif +#ifdef AT_STATX_SYNC_AS_STAT + FLAG_GENERIC(AT_STATX_SYNC_AS_STAT), +#endif +#ifdef AT_STATX_FORCE_SYNC + FLAG_GENERIC(AT_STATX_FORCE_SYNC), +#endif +#ifdef AT_STATX_DONT_SYNC + FLAG_GENERIC(AT_STATX_DONT_SYNC), +#endif + FLAG_END, +}; + +UNUSED static struct flags statx_mask[] = { +/* This must come first, because it includes everything. */ +#ifdef STATX_ALL + FLAG_GENERIC(STATX_ALL), +#endif +/* This must come second; it includes everything except STATX_BTIME. */ +#ifdef STATX_BASIC_STATS + FLAG_GENERIC(STATX_BASIC_STATS), +#endif +#ifdef STATX_TYPE + FLAG_GENERIC(STATX_TYPE), +#endif +#ifdef STATX_MODE + FLAG_GENERIC(STATX_MODE), +#endif +#ifdef STATX_NLINK + FLAG_GENERIC(STATX_NLINK), +#endif +#ifdef STATX_UID + FLAG_GENERIC(STATX_UID), +#endif +#ifdef STATX_GID + FLAG_GENERIC(STATX_GID), +#endif +#ifdef STATX_ATIME + FLAG_GENERIC(STATX_ATIME), +#endif +#ifdef STATX_MTIME + FLAG_GENERIC(STATX_MTIME), +#endif +#ifdef STATX_CTIME + FLAG_GENERIC(STATX_CTIME), +#endif +#ifdef STATX_INO + FLAG_GENERIC(STATX_INO), +#endif +#ifdef STATX_SIZE + FLAG_GENERIC(STATX_SIZE), +#endif +#ifdef STATX_BLOCKS + FLAG_GENERIC(STATX_BLOCKS), +#endif +#ifdef STATX_BTIME + FLAG_GENERIC(STATX_BTIME), +#endif + FLAG_END, +}; + /* * print_xxx utility functions. These are used to print syscall * parameters in certain format. All of these have parameter
@@ -2611,6 +2681,22 @@ print_tgkill(const struct syscallname *name, }#endif +#ifdef TARGET_NR_statx +static void +print_statx (const struct syscallname *name, +abi_long arg0,abi_long arg1,abi_long arg2, +abi_long arg3,abi_long arg4,abi_long arg5) +{ +print_syscall_prologue (name); +print_at_dirfd (arg0,0 ); +print_string (arg1,0 ); +print_flags (statx_flags, arg2,0 ); +print_flags (statx_mask, arg3,0 ); +print_pointer (arg4,1 ); +print_syscall_epilogue (name); +} +#endif +/* * An array of all of the syscalls we know about */
linux-user/strace.list +3 -0
@@ -1650,3 +1650,6 @@ #ifdef TARGET_NR_atomic_barrier { TARGET_NR_atomic_barrier, "atomic_barrier", NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_statx +{ TARGET_NR_statx, "statx", NULL, print_statx, NULL }, +#endif
Signature · 1 line
2.7.4
PATCH v15 3/5 linux-user: Fix target_flock structure for MIPS O64 ABI
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
Among MIPS ABIs, only MIPS O32 and N32 have special (different than other architectures) definition of structure flock in kernel.
Bring target_flock definition in QEMU for MIPS O64 ABI to the correct state, which is currently different than the most common definition, and it should actually be the same.
--- linux-user/generic/fcntl.h | 2 +- linux-user/mips/target_fcntl.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
linux-user/generic/fcntl.h +1 -1
@@ -129,7 +129,7 @@ struct target_flock {short l_whence;abi_long l_start;abi_long l_len; -#if defined(TARGET_MIPS ) +#if defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 )abi_long l_sysid;#endif int l_pid;
linux-user/mips/target_fcntl.h +4 -0
@@ -27,7 +27,11 @@#define TARGET_F_SETOWN 24/* for sockets. */ #define TARGET_F_GETOWN 23/* for sockets. */ +#if (TARGET_ABI_BITS ==32 )#define TARGET_ARCH_FLOCK_PAD abi_long pad[4]; +#else +#define TARGET_ARCH_FLOCK_PAD +#endif #define TARGET_ARCH_FLOCK64_PAD #define TARGET_F_GETLK64 33/* using 'struct flock64' */
Signature · 1 line
2.7.4
PATCH v15 4/5 linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
Bring target_flock definitions to be more in sync with the way flock is defined in kernel.
Basically, the rules from the kernel are:
1. Majority of architectures have a common flock definition.
2. Architectures with 32-bit MIPS ABIs have a sligtly different flock definition; those architectures are the only arcitectures that have HAVE_ARCH_STRUCT_FLOCK defined, and that preprocessor constant is used in the common header as a flag for including or not including common flock definition.
3. Sparc architectures also have a sligtly different flock definition, but the difference is only the padding at the end of the structure. The presence of that padding is determined by preprocessor constants __ARCH_FLOCK6_PAD and __ARCH_FLOCK64_PAD.
QEMU linux-user already implements rules 1. and 3. in a very similar way as they are implemented in kernel. However, rule 2. is implemented in a dissimilar way (for example, the constant TARGET_HAVE_ARCH_STRUCT_FLOCK is missing), and this patch brings QEMU implementation much closer to the kernel implementation. TARGET_HAVE_ARCH_STRUCT_FLOCK64 constant is also introduced to mimic HAVE_ARCH_STRUCT_FLOCK64 from kernel, but it is not defined anywhere, however, this is the case with HAVE_ARCH_STRUCT_FLOCK64 in kernel as well.
--- linux-user/generic/fcntl.h | 8 +++++--- linux-user/mips/target_fcntl.h | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-)
linux-user/generic/fcntl.h +5 -3
@@ -120,6 +120,7 @@ struct target_f_owner_ex {#define TARGET_F_SHLCK 8#endif +#ifndef TARGET_HAVE_ARCH_STRUCT_FLOCK #ifndef TARGET_ARCH_FLOCK_PAD #define TARGET_ARCH_FLOCK_PAD #endif
@@ -129,13 +130,12 @@ struct target_flock {short l_whence;abi_long l_start;abi_long l_len; -#if defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 ) -abi_long l_sysid; -#endif int l_pid;TARGET_ARCH_FLOCK_PAD }; +#endif +#ifndef TARGET_HAVE_ARCH_STRUCT_FLOCK64 #ifndef TARGET_ARCH_FLOCK64_PAD #define TARGET_ARCH_FLOCK64_PAD #endif
@@ -149,3 +149,5 @@ struct target_flock64 {TARGET_ARCH_FLOCK64_PAD };#endif + +#endif
linux-user/mips/target_fcntl.h +13 -4
@@ -28,11 +28,20 @@#define TARGET_F_GETOWN 23/* for sockets. */ #if (TARGET_ABI_BITS ==32 ) -#define TARGET_ARCH_FLOCK_PAD abi_long pad[4]; -#else -#define TARGET_ARCH_FLOCK_PAD + +struct target_flock { +short l_type; +short l_whence; +abi_long l_start; +abi_long l_len; +abi_long l_sysid; +int l_pid; +abi_long pad[4 ]; +}; + +#define TARGET_HAVE_ARCH_STRUCT_FLOCK +#endif -#define TARGET_ARCH_FLOCK64_PAD #define TARGET_F_GETLK64 33/* using 'struct flock64' */ #define TARGET_F_SETLK64 34
Signature · 1 line
2.7.4
PATCH v15 5/5 linux-user: Handle EXCP_FPE properly for MIPS
In reply to Aleksandar MarkovicFrom: Aleksandar Markovic <[email protected]>
Handle EXCP_FPE properly for MIPS in cpu loop.
Note that a vast majority of FP instructions are not affected by the absence of the code in this patch, as they use alternative code paths for handling floating point exceptions (see, for example, invocations of update_fcr31()) - they rely on softfloat library for keeping track on exceptions that needs to be raised. However, there are few MIPS FP instructions (an example is CTC1) that use function do_raise_exception() directly, and they need the case that is added in this patch to propagate the FPE exception as designed.
The code is based on kernel's function force_fcr31_sig() in arch/mips/kernel.traps.c.
--- linux-user/mips/cpu_loop.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
linux-user/mips/cpu_loop.c +17 -0
@@ -540,6 +540,23 @@ done_syscall: info.si_code =TARGET_ILL_ILLOPC ;queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ; +case EXCP_FPE : + info.si_signo =TARGET_SIGFPE ; + info.si_errno =0 ; + info.si_code =TARGET_FPE_FLTUNK ; +if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_INVALID ) { + info.si_code =TARGET_FPE_FLTINV ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_DIV0 ) { + info.si_code =TARGET_FPE_FLTDIV ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_OVERFLOW ) { + info.si_code =TARGET_FPE_FLTOVF ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_UNDERFLOW ) { + info.si_code =TARGET_FPE_FLTUND ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_INEXACT ) { + info.si_code =TARGET_FPE_FLTRES ; + } +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ;/* The code below was inspired by the MIPS Linux kernel trap * handling code in arch/mips/kernel/traps.c. */
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v15 5/5] linux-user: Handle EXCP_FPE properly for MIPS
Le 28/06/2019 à 10:54, Aleksandar Markovic a écrit :
Quoted 41 lines
From: Aleksandar Markovic <[email protected]>
Handle
EXCP_FPEproperly for MIPS in cpu loop.Note that a vast majority of FP instructions are not affected by the absence of the code in this patch, as they use alternative code paths for handling floating point exceptions (see, for example, invocations of
update_fcr31()) - they rely on softfloat library for keeping track on exceptions that needs to be raised. However, there are few MIPS FP instructions (an example is CTC1) that use functiondo_raise_exception()directly, and they need the case that is added in this patch to propagate the FPE exception as designed.The code is based on kernel's function
force_fcr31_sig()inarch/mips/kernel.traps.c.Reported-by Yunqiang Su <[email protected]>Signed-off-by Aleksandar Markovic <[email protected]>--- linux-user/mips/cpu_loop.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)linux-user/mips/cpu_loop.c +10
-0@@ -540,6 +540,23 @@ done_syscall: info.si_code =TARGET_ILL_ILLOPC ;queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ; +case EXCP_FPE : + info.si_signo =TARGET_SIGFPE ; + info.si_errno =0 ; + info.si_code =TARGET_FPE_FLTUNK ; +if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_INVALID ) { + info.si_code =TARGET_FPE_FLTINV ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_DIV0 ) { + info.si_code =TARGET_FPE_FLTDIV ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_OVERFLOW ) { + info.si_code =TARGET_FPE_FLTOVF ;
linux-user/mips/cpu_loop.c done_syscall: · line 562
Quoted 10 lines
linux-user/mips/cpu_loop.c +7
-0+ }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_UNDERFLOW ) { + info.si_code =TARGET_FPE_FLTUND ; + }else if (GET_FP_CAUSE (env->active_fpu.fcr31) &FP_INEXACT ) { + info.si_code =TARGET_FPE_FLTRES ; + } +queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info); +break ;/* The code below was inspired by the MIPS Linux kernel trap * handling code in arch/mips/kernel/traps.c. */
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v15 0/5] linux-user: A set of miscellaneous patches
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'7a91f2ac4c linux-user: Handle EXCP_FPE properly for MIPS 569ce4b0b7 linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK 819bdffd01 linux-user: Fix target_flock structure for MIPS O64 ABI b1f7d32d9a linux-user: Add support for strace for statx() syscall 00cca0ba1d linux-user: Add support for translation of statx() syscall
=== OUTPUT BEGIN ===
1/5 Checking commit 00cca0ba1dae (linux-user: Add support for translation of statx() syscall)
WARNING: architecture specific defines should be avoided
#53: FILE: linux-user/syscall.c:321:
+#if defined(TARGET_NR_statx) && defined(__NR_statx)
WARNING: architecture specific defines should be avoided #65: FILE: linux-user/syscall.c:6478:
+#if defined(TARGET_NR_statx) && defined(__NR_statx)
WARNING: architecture specific defines should be avoided #135: FILE: linux-user/syscall.c:10188:
+#if defined(__NR_statx)
total: 0 errors, 3 warnings, 179 lines checked
Patch 1/5 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/5 Checking commit b1f7d32d9a70 (linux-user: Add support for strace for statx() syscall)
ERROR: storage class should be at the beginning of the declaration
#27: FILE: linux-user/strace.c:979:
+UNUSED static struct flags statx_flags[] = {
ERROR: storage class should be at the beginning of the declaration #49: FILE: linux-user/strace.c:1001:
+UNUSED static struct flags statx_mask[] = {
total: 2 errors, 0 warnings, 104 lines checked
Patch 2/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/5 Checking commit 819bdffd0139 (linux-user: Fix target_flock structure for MIPS O64 ABI) 4/5 Checking commit 569ce4b0b746 (linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK) 5/5 Checking commit 7a91f2ac4c93 (linux-user: Handle EXCP_FPE properly for MIPS) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed build test on s390x host. Please find the details below.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with # HEAD pointing to a commit that has the patches applied on top of "base"
# branch set -e CC=$HOME/bin/cc INSTALL=$PWD/install BUILD=$PWD/build mkdir -p $BUILD $INSTALL SRC=$PWD cd $BUILD $SRC/configure --cc=$CC --prefix=$INSTALL make -j4 # XXX: we need reliable clean up # make check -j4 V=1 make install
echo
echo "=== ENV ==="
env
echo
echo "=== PACKAGES ==="
rpm -qa
=== TEST SCRIPT END ===
CC microblaze-linux-user/linux-user/strace.o
CC mips64el-linux-user/linux-user/syscall.o
LINK microblazeel-linux-user/qemu-microblazeel
/var/tmp/patchew-tester-tmp-tr0wvoyz/src/linux-user/syscall.c:322:16: error: conflicting types for ‘statx’
322 | _syscall5(int, statx, int, dirfd, const char *, pathname, int, flags,
| ^~~~~/var/tmp/patchew-tester-tmp-tr0wvoyz/src/linux-user/syscall.c:213:13: note: in definition of macro ‘_syscall5’
The full log is available at
http://patchew.org/logs/[email protected]/testing.s390x/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Dear Patchew developers,
Le 28/06/2019 à 11:49, [email protected] a écrit :
Quoted 7 lines
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed build test on s390x host. Please find the details below.
To debug this kind of problem (at least to reproduce it), it may be interesting to know the OS release of the target build environment (glibc version, gcc version, ...) on which the build fails.
Is this possible to add this in the mail (or in the logs)?
...
Quoted 7 lines
CC microblaze-linux-user/linux-user/strace.o CC mips64el-linux-user/linux-user/syscall.o LINK microblazeel-linux-user/qemu-microblazeel /var/tmp/patchew-tester-tmp-tr0wvoyz/src/linux-user/syscall.c:322:16: error: conflicting types for ‘statx’ 322 | _syscall5(int, statx, int, dirfd, const char *, pathname, int, flags, | ^~~~~
/var/tmp/patchew-tester-tmp-tr0wvoyz/src/linux-user/syscall.c:213:13: note: in definition of macro ‘_syscall5’
Thanks,
Laurent
Quoted 9 lines · Laurent Vivier
Dear Patchew developers,
Le 28/06/2019 à 11:49, [email protected] a écrit :
Quoted 6 lines
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
Quoted 7 lines
Quoted 1 line
This series failed build test on s390x host. Please find the details below.
To debug this kind of problem (at least to reproduce it), it may be interesting to know the OS release of the target build environment (glibc version, gcc version, ...) on which the build fails.
Is this possible to add this in the mail (or in the logs)?
I've moved the env/rpm/uname commands before the actual testing commands, so the information can be collected even upon failures.
Fam
Quoted 17 lines
...
Quoted 7 lines
CC microblaze-linux-user/linux-user/strace.o CC mips64el-linux-user/linux-user/syscall.o LINK microblazeel-linux-user/qemu-microblazeel /var/tmp/patchew-tester-tmp-tr0wvoyz/src/linux-user/syscall.c:322:16: error: conflicting types for ‘statx’ 322 | _syscall5(int, statx, int, dirfd, const char *, pathname, int, flags, | ^~~~~
/var/tmp/patchew-tester-tmp-tr0wvoyz/src/linux-user/syscall.c:213:13: note: in definition of macro ‘_syscall5’Thanks,
Laurent_______________________________________________
Patchew-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/patchew-devel
Le 28/06/2019 à 14:41, Fam Zheng a écrit :
Quoted 12 lines · Laurent Vivier
Quoted 11 lines
Dear Patchew developers,
Le 28/06/2019 à 11:49, [email protected] a écrit :
Quoted 7 lines
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed build test on s390x host. Please find the details below.
Quoted 8 lines
Quoted 5 lines
To debug this kind of problem (at least to reproduce it), it may be interesting to know the OS release of the target build environment (glibc version, gcc version, ...) on which the build fails.
Is this possible to add this in the mail (or in the logs)?
I've moved the env/rpm/uname commands before the actual testing commands, so the information can be collected even upon failures.
Thank you Fam.
From the v16 log, I can see s390x runs Fedora 30 (v15 works fine on debian/sid s390x)
Laurent
Quoted 2 lines
I've moved the env/rpm/uname commands before the actual testing commands, so the information can be collected even upon failures.
Would it be hard for you to capture output of the command "ldd --version" and include it early in the log?
That would be sufficient for us to deduce "glibc version".
Thanks,
Aleksandar
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v15 0/5] linux-user: A set of miscellaneous patches
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
8e36bc8 linux-user: Handle EXCP_FPE properly for MIPS 8d588de linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK 9f12ce3 linux-user: Fix target_flock structure for MIPS O64 ABI c3af4f1 linux-user: Add support for strace for statx() syscall b00199b linux-user: Add support for translation of statx() syscall
=== OUTPUT BEGIN ===
1/5 Checking commit b00199b2c730 (linux-user: Add support for translation of statx() syscall)
WARNING: architecture specific defines should be avoided
#53: FILE: linux-user/syscall.c:321:
+#if defined(TARGET_NR_statx) && defined(__NR_statx)
WARNING: architecture specific defines should be avoided #65: FILE: linux-user/syscall.c:6478:
+#if defined(TARGET_NR_statx) && defined(__NR_statx)
WARNING: architecture specific defines should be avoided #135: FILE: linux-user/syscall.c:10188:
+#if defined(__NR_statx)
total: 0 errors, 3 warnings, 179 lines checked
Patch 1/5 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/5 Checking commit c3af4f1f9421 (linux-user: Add support for strace for statx() syscall)
ERROR: storage class should be at the beginning of the declaration
#27: FILE: linux-user/strace.c:979:
+UNUSED static struct flags statx_flags[] = {
ERROR: storage class should be at the beginning of the declaration #49: FILE: linux-user/strace.c:1001:
+UNUSED static struct flags statx_mask[] = {
total: 2 errors, 0 warnings, 104 lines checked
Patch 2/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/5 Checking commit 9f12ce370693 (linux-user: Fix target_flock structure for MIPS O64 ABI) 4/5 Checking commit 8d588de6f092 (linux-user: Introduce TARGET_HAVE_ARCH_STRUCT_FLOCK) 5/5 Checking commit 8e36bc871a28 (linux-user: Handle EXCP_FPE properly for MIPS) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]