late linux-user fixes for 2.11
From: Riku Voipio <[email protected]>
The following changes since commit b0fbe46ad82982b289a44ee2495b59b0bad8a842:
Update version for v2.11.0-rc0 release (2017-11-07 16:05:28 +0000)
are available in the git repository at:
git://git.linaro.org/people/riku.voipio/qemu.git tags/pull-linux-user-20171120
for you to fetch changes up to f516511ea84d8bb3395d6ea95a7c7b80dc2a05e9:
linux-user: Fix calculation of auxv length (2017-11-20 16:15:41 +0200)
----------------------------------------------------------------
late linux-user fixes for Qemu 2.11
----------------------------------------------------------------
Emilio G. Cota (1):
linux-user: fix 'finshed' typo in comment
Helge Deller (5):
linux-user/hppa: Fix TARGET_SA_* defines linux-user/hppa: Fix typo for TARGET_NR_epoll_wait linux-user/hppa: Fix TARGET_MAP_TYPE
linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK
linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
James Clarke (1):
linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64
James Cowgill (1):
linux-user: return EINVAL from prctl(PR_*_SECCOMP)
Peter Maydell (5):
linux-user/s390x: Mask si_addr for SIGSEGV
linux-user/ppc: Report correct fault address for data faults linux-user/sparc: Put address for data faults where linux-user expects it
linux-user: Handle rt_sigaction correctly for SPARC
linux-user: Fix calculation of auxv length
Richard Henderson (2):
linux-user: Restrict usage of sa_restorer
linux-user/hppa: Fix cpu_clone_regs
linux-user/elfload.c | 11 +++++++-- linux-user/hppa/syscall_nr.h | 2 +- linux-user/hppa/target_cpu.h | 4 ++++ linux-user/main.c | 8 +++++-- linux-user/signal.c | 4 ++-- linux-user/syscall.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- linux-user/syscall_defs.h | 40 ++++++++++++++++++++++++++++++++- target/sparc/mmu_helper.c | 8 +++++++ 8 files changed, 144 insertions(+), 35 deletions(-)
[Qemu-devel] [PULL 02/15] linux-user/hppa: Fix TARGET_SA_* defines
From: Helge Deller <[email protected]>
--- linux-user/syscall_defs.h | 8 ++++++++ 1 file changed, 8 insertions(+)
linux-user/syscall_defs.h +8 -0
@@ -473,6 +473,14 @@ int do_sigaction(int sig, const struct target_sigaction *act,#define TARGET_SA_RESETHAND 0x00000010#define TARGET_SA_NOCLDWAIT 0x00000020/* not supported yet */ #define TARGET_SA_SIGINFO 0x00000040 +#elif defined(TARGET_HPPA ) +#define TARGET_SA_ONSTACK 0x00000001 +#define TARGET_SA_RESETHAND 0x00000004 +#define TARGET_SA_NOCLDSTOP 0x00000008 +#define TARGET_SA_SIGINFO 0x00000010 +#define TARGET_SA_NODEFER 0x00000020 +#define TARGET_SA_RESTART 0x00000040 +#define TARGET_SA_NOCLDWAIT 0x00000080#else #define TARGET_SA_NOCLDSTOP 0x00000001#define TARGET_SA_NOCLDWAIT 0x00000002/* not supported yet */
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 01/15] linux-user: Restrict usage of sa_restorer
In reply to [email protected]From: Richard Henderson <[email protected]>
Reading and writing to an sa_restorer member that isn't supposed to exist corrupts user memory. Introduce TARGET_ARCH_HAS_SA_RESTORER, similar to the kernel's __ARCH_HAS_SA_RESTORER.
--- linux-user/signal.c | 4 ++-- linux-user/syscall_defs.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-)
linux-user/signal.c +2 -2
@@ -777,7 +777,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,if (oact) {__put_user (k->_sa_handler, &oact->_sa_handler);__put_user (k->sa_flags, &oact->sa_flags); -#if !defined(TARGET_MIPS ) +#ifdef TARGET_ARCH_HAS_SA_RESTORER __put_user (k->sa_restorer, &oact->sa_restorer);#endif /* Not swapped. */
@@ -787,7 +787,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,/* FIXME: This is not threadsafe. */ __get_user (k->_sa_handler, &act->_sa_handler);__get_user (k->sa_flags, &act->sa_flags); -#if !defined(TARGET_MIPS ) +#ifdef TARGET_ARCH_HAS_SA_RESTORER __get_user (k->sa_restorer, &act->sa_restorer);#endif /* To be swapped in target_to_host_sigset. */
linux-user/syscall_defs.h +13 -0
@@ -445,6 +445,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,#define TARGET_SA_RESTART 2u#define TARGET_SA_NODEFER 0x20u#define TARGET_SA_RESETHAND 4u +#define TARGET_ARCH_HAS_SA_RESTORER 1#elif defined(TARGET_MIPS )#define TARGET_SA_NOCLDSTOP 0x00000001#define TARGET_SA_NOCLDWAIT 0x00010000
@@ -483,6 +484,10 @@ int do_sigaction(int sig, const struct target_sigaction *act,#define TARGET_SA_RESTORER 0x04000000#endif +#ifdef TARGET_SA_RESTORER +#define TARGET_ARCH_HAS_SA_RESTORER 1 +#endif +#if defined(TARGET_ALPHA )#define TARGET_SIGHUP 1
@@ -718,19 +723,27 @@ struct target_sigaction {abi_ulong _sa_handler;#endif target_sigset_t sa_mask; +#ifdef TARGET_ARCH_HAS_SA_RESTORER +/* ??? This is always present, but ignored unless O32. */ +abi_ulong sa_restorer; +#endif };#else struct target_old_sigaction {abi_ulong _sa_handler;abi_ulong sa_mask;abi_ulong sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER abi_ulong sa_restorer; +#endif };struct target_sigaction {abi_ulong _sa_handler;abi_ulong sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER abi_ulong sa_restorer; +#endif target_sigset_t sa_mask; };#endif
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 03/15] linux-user/hppa: Fix cpu_clone_regs
In reply to [email protected]From: Richard Henderson <[email protected]>
By failing to return from the syscall in the child, the child issues another clone syscall and hilarity ensues.
--- linux-user/hppa/target_cpu.h | 4 ++++ 1 file changed, 4 insertions(+)
linux-user/hppa/target_cpu.h +4 -0
@@ -24,7 +24,11 @@ static inline void cpu_clone_regs(CPUHPPAState *env, target_ulong newsp)if (newsp) { env->gr[30 ] = newsp; } +/* Indicate child in return value. */ env->gr[28 ] =0 ; +/* Return from the syscall. */ + env->iaoq_f = env->gr[31 ]; + env->iaoq_b = env->gr[31 ] +4 ; }static inline void cpu_set_tls (CPUHPPAState *env,target_ulong newtls)
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 04/15] linux-user/hppa: Fix typo for TARGET_NR_epoll_wait
In reply to [email protected]From: Helge Deller <[email protected]>
Message-Id: <[email protected]>
--- linux-user/hppa/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/hppa/syscall_nr.h +1 -1
@@ -228,7 +228,7 @@#define TARGET_NR_lookup_dcookie 223#define TARGET_NR_epoll_create 224#define TARGET_NR_epoll_ctl 225 -#define TARGET_NR_epill_wait 226 +#define TARGET_NR_epoll_wait 226#define TARGET_NR_remap_file_pages 227#define TARGET_NR_semtimedop 228#define TARGET_NR_mq_open 229
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 05/15] linux-user/hppa: Fix TARGET_MAP_TYPE
In reply to [email protected]From: Helge Deller <[email protected]>
TARGET_MAP_TYPE needs to be 0x03 instead of 0x0f on the hppa architecture, otherwise it conflicts with MAP_FIXED which is 0x04.
Message-ID: <[email protected]>
--- linux-user/syscall_defs.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/syscall_defs.h +5 -1
@@ -1336,7 +1336,11 @@ struct target_winsize {/* Common */ #define TARGET_MAP_SHARED 0x01/* Share changes */ #define TARGET_MAP_PRIVATE 0x02/* Changes are private */ -#define TARGET_MAP_TYPE 0x0f/* Mask for type of mapping */ +#if defined(TARGET_HPPA ) +#define TARGET_MAP_TYPE 0x03/* Mask for type of mapping */ +#else +#define TARGET_MAP_TYPE 0x0f/* Mask for type of mapping */ +#endif /* Target specific */ #if defined(TARGET_MIPS )
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 06/15] linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK
In reply to [email protected]From: Helge Deller <[email protected]>
Message-ID: <[email protected]>
--- linux-user/syscall_defs.h | 3 +++ 1 file changed, 3 insertions(+)
linux-user/syscall_defs.h +3 -0
@@ -2361,6 +2361,9 @@ struct target_statfs64 {#define TARGET_F_SETOWN 24/* for sockets. */ #define TARGET_F_GETOWN 23/* for sockets. */ #elif defined(TARGET_HPPA ) +#define TARGET_F_RDLCK 1 +#define TARGET_F_WRLCK 2 +#define TARGET_F_UNLCK 3#define TARGET_F_GETLK 5#define TARGET_F_SETLK 6#define TARGET_F_SETLKW 7
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 07/15] linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
In reply to [email protected]From: Helge Deller <[email protected]>
Add the missing defines and for TARGET_MAP_STACK and TARGET_MAP_HUGETLB for alpha, mips, ppc, x86, hppa. Fix the mmap_flags translation table to translate MAP_HUGETLB between host and target architecture, and to drop MAP_STACK.
Message-Id: <[email protected]> [rth: Drop MAP_STACK instead of translating it, since it is ignored in the kernel anyway. Fix tabs to spaces.]
--- linux-user/syscall.c | 31 ++++++++++++++++++++----------- linux-user/syscall_defs.h | 10 ++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-)
linux-user/syscall.c +20 -11
@@ -5872,17 +5872,26 @@ static const StructEntry struct_termios_def = { };static bitmask_transtbl mmap_flags_tbl[] = { - {TARGET_MAP_SHARED ,TARGET_MAP_SHARED ,MAP_SHARED ,MAP_SHARED }, - {TARGET_MAP_PRIVATE ,TARGET_MAP_PRIVATE ,MAP_PRIVATE ,MAP_PRIVATE }, - {TARGET_MAP_FIXED ,TARGET_MAP_FIXED ,MAP_FIXED ,MAP_FIXED }, - {TARGET_MAP_ANONYMOUS ,TARGET_MAP_ANONYMOUS ,MAP_ANONYMOUS ,MAP_ANONYMOUS }, - {TARGET_MAP_GROWSDOWN ,TARGET_MAP_GROWSDOWN ,MAP_GROWSDOWN ,MAP_GROWSDOWN }, - {TARGET_MAP_DENYWRITE ,TARGET_MAP_DENYWRITE ,MAP_DENYWRITE ,MAP_DENYWRITE }, - {TARGET_MAP_EXECUTABLE ,TARGET_MAP_EXECUTABLE ,MAP_EXECUTABLE ,MAP_EXECUTABLE }, - {TARGET_MAP_LOCKED ,TARGET_MAP_LOCKED ,MAP_LOCKED ,MAP_LOCKED }, - {TARGET_MAP_NORESERVE ,TARGET_MAP_NORESERVE ,MAP_NORESERVE , -MAP_NORESERVE }, - {0 ,0 ,0 ,0 } + {TARGET_MAP_SHARED ,TARGET_MAP_SHARED ,MAP_SHARED ,MAP_SHARED }, + {TARGET_MAP_PRIVATE ,TARGET_MAP_PRIVATE ,MAP_PRIVATE ,MAP_PRIVATE }, + {TARGET_MAP_FIXED ,TARGET_MAP_FIXED ,MAP_FIXED ,MAP_FIXED }, + {TARGET_MAP_ANONYMOUS ,TARGET_MAP_ANONYMOUS , +MAP_ANONYMOUS ,MAP_ANONYMOUS }, + {TARGET_MAP_GROWSDOWN ,TARGET_MAP_GROWSDOWN , +MAP_GROWSDOWN ,MAP_GROWSDOWN }, + {TARGET_MAP_DENYWRITE ,TARGET_MAP_DENYWRITE , +MAP_DENYWRITE ,MAP_DENYWRITE }, + {TARGET_MAP_EXECUTABLE ,TARGET_MAP_EXECUTABLE , +MAP_EXECUTABLE ,MAP_EXECUTABLE }, + {TARGET_MAP_LOCKED ,TARGET_MAP_LOCKED ,MAP_LOCKED ,MAP_LOCKED }, + {TARGET_MAP_NORESERVE ,TARGET_MAP_NORESERVE , +MAP_NORESERVE ,MAP_NORESERVE }, + {TARGET_MAP_HUGETLB ,TARGET_MAP_HUGETLB ,MAP_HUGETLB ,MAP_HUGETLB }, +/* MAP_STACK had been ignored by the kernel for quite some time. +Recognize it for the target insofar as we do not want to pass +it through to the host. */ + {TARGET_MAP_STACK ,TARGET_MAP_STACK ,0 ,0 }, + {0 ,0 ,0 ,0 } };#if defined(TARGET_I386 )
linux-user/syscall_defs.h +10 -0
@@ -1353,6 +1353,8 @@ struct target_winsize {#define TARGET_MAP_NORESERVE 0x0400/* don't check for reservations */ #define TARGET_MAP_POPULATE 0x10000/* populate (prefault) pagetables */ #define TARGET_MAP_NONBLOCK 0x20000/* do not block on IO */ +#define TARGET_MAP_STACK 0x40000/* ignored */ +#define TARGET_MAP_HUGETLB 0x80000/* create a huge page mapping */ #elif defined(TARGET_PPC )#define TARGET_MAP_FIXED 0x10/* Interpret addr exactly */ #define TARGET_MAP_ANONYMOUS 0x20/* don't use a file */
@@ -1363,6 +1365,8 @@ struct target_winsize {#define TARGET_MAP_NORESERVE 0x0040/* don't check for reservations */ #define TARGET_MAP_POPULATE 0x8000/* populate (prefault) pagetables */ #define TARGET_MAP_NONBLOCK 0x10000/* do not block on IO */ +#define TARGET_MAP_STACK 0x20000/* ignored */ +#define TARGET_MAP_HUGETLB 0x40000/* create a huge page mapping */ #elif defined(TARGET_ALPHA )#define TARGET_MAP_ANONYMOUS 0x10/* don't use a file */ #define TARGET_MAP_FIXED 0x100/* Interpret addr exactly */
@@ -1373,6 +1377,8 @@ struct target_winsize {#define TARGET_MAP_NORESERVE 0x10000/* no check for reservations */ #define TARGET_MAP_POPULATE 0x20000/* pop (prefault) pagetables */ #define TARGET_MAP_NONBLOCK 0x40000/* do not block on IO */ +#define TARGET_MAP_STACK 0x80000/* ignored */ +#define TARGET_MAP_HUGETLB 0x100000/* create a huge page mapping */ #elif defined(TARGET_HPPA )#define TARGET_MAP_ANONYMOUS 0x10/* don't use a file */ #define TARGET_MAP_FIXED 0x04/* Interpret addr exactly */
@@ -1383,6 +1389,8 @@ struct target_winsize {#define TARGET_MAP_NORESERVE 0x04000/* no check for reservations */ #define TARGET_MAP_POPULATE 0x10000/* pop (prefault) pagetables */ #define TARGET_MAP_NONBLOCK 0x20000/* do not block on IO */ +#define TARGET_MAP_STACK 0x40000/* ignored */ +#define TARGET_MAP_HUGETLB 0x80000/* create a huge page mapping */ #else #define TARGET_MAP_FIXED 0x10/* Interpret addr exactly */ #define TARGET_MAP_ANONYMOUS 0x20/* don't use a file */
@@ -1393,6 +1401,8 @@ struct target_winsize {#define TARGET_MAP_NORESERVE 0x4000/* don't check for reservations */ #define TARGET_MAP_POPULATE 0x8000/* populate (prefault) pagetables */ #define TARGET_MAP_NONBLOCK 0x10000/* do not block on IO */ +#define TARGET_MAP_STACK 0x20000/* ignored */ +#define TARGET_MAP_HUGETLB 0x40000/* create a huge page mapping */ #define TARGET_MAP_UNINITIALIZED 0x4000000/* for anonymous mmap, memory could be uninitialized */ #endif
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 08/15] linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64
In reply to [email protected]From: James Clarke <[email protected]>
--- linux-user/syscall.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
linux-user/syscall.c +25 -11
@@ -671,18 +671,32 @@ static inline int next_free_host_timer(void)/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ #ifdef TARGET_ARM -static inline int regpairs_aligned (void *cpu_env) { +static inline int regpairs_aligned (void *cpu_env,int num) +{return ((((CPUARMState *)cpu_env)->eabi) ==1 ) ; }#elif defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 ) -static inline int regpairs_aligned (void *cpu_env) {return 1 ; } +static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; }#elif defined(TARGET_PPC ) && !defined(TARGET_PPC64 )/* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs * of registers which translates to the same as ARM/MIPS, because we start with * r3 as arg1 */ -static inline int regpairs_aligned (void *cpu_env) {return 1 ; } +static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } +#elif defined(TARGET_SH4 ) +/* SH4 doesn't align register pairs, except for p{read,write}64 */ +static inline int regpairs_aligned (void *cpu_env,int num) +{ +switch (num) { +case TARGET_NR_pread64: +case TARGET_NR_pwrite64: +return 1 ; + +default : +return 0 ; + } +}#else -static inline int regpairs_aligned (void *cpu_env) {return 0 ; } +static inline int regpairs_aligned (void *cpu_env,int num) {return 0 ; }#endif #define ERRNO_TABLE_SIZE 1200
@@ -6870,7 +6884,7 @@ static inline abi_long target_truncate64(void *cpu_env, const char *arg1,abi_long arg3, abi_long arg4) { - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { arg2 = arg3; arg3 = arg4; }
@@ -6884,7 +6898,7 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1,abi_long arg3, abi_long arg4) { - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { arg2 = arg3; arg3 = arg4; }
@@ -10508,7 +10522,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_pread64case TARGET_NR_pread64: -if (regpairs_aligned (cpu_env)) { +if (regpairs_aligned (cpu_env, num)) { arg4 = arg5; arg5 = arg6; }
@@ -10518,7 +10532,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg2, ret);break ;case TARGET_NR_pwrite64: -if (regpairs_aligned (cpu_env)) { +if (regpairs_aligned (cpu_env, num)) { arg4 = arg5; arg5 = arg6; }
@@ -11288,7 +11302,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg6 = ret;#else /* 6 args: fd, offset (high, low), len (high, low), advice */ -if (regpairs_aligned (cpu_env)) { +if (regpairs_aligned (cpu_env, num)) {/* offset is in (3,4), len in (5,6) and advice in 7 */ arg2 = arg3; arg3 = arg4;
@@ -11307,7 +11321,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_fadvise64case TARGET_NR_fadvise64:/* 5 args: fd, offset (high, low), len, advice */ -if (regpairs_aligned (cpu_env)) { +if (regpairs_aligned (cpu_env, num)) {/* offset is in (3,4), len in 5 and advice in 6 */ arg2 = arg3; arg3 = arg4;
@@ -11420,7 +11434,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_readahead case TARGET_NR_readahead: #if TARGET_ABI_BITS == 32 - if (regpairs_aligned(cpu_env)) { + if (regpairs_aligned(cpu_env, num)) { arg2 = arg3; arg3 = arg4; arg4 = arg5;
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 09/15] linux-user: fix 'finshed' typo in comment
In reply to [email protected]From: "Emilio G. Cota" <[email protected]>
--- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
@@ -6258,7 +6258,7 @@ static void *clone_func(void *arg)pthread_mutex_lock (&info->mutex);pthread_cond_broadcast (&info->cond);pthread_mutex_unlock (&info->mutex); -/* Wait until the parent has finshed initializing the tls state. */ +/* Wait until the parent has finished initializing the tls state. */ pthread_mutex_lock (&clone_lock);pthread_mutex_unlock (&clone_lock);cpu_loop (env);
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 10/15] linux-user: return EINVAL from prctl(PR_*_SECCOMP)
In reply to [email protected]From: James Cowgill <[email protected]>
If an application tries to install a seccomp filter using prctl(PR_SET_SECCOMP), the filter is likely for the target instead of the host architecture. This will probably cause qemu to be immediately killed when it executes another syscall.
Prevent this from happening by returning EINVAL from both seccomp prctl calls. This is the error returned by the kernel when seccomp support is disabled.
--- linux-user/syscall.c | 6 ++++++ 1 file changed, 6 insertions(+)
linux-user/syscall.c +6 -0
@@ -10505,6 +10505,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; }#endif +case PR_GET_SECCOMP : +case PR_SET_SECCOMP : +/* Disable seccomp to prevent the target disabling syscalls we +* need. */ + ret = -TARGET_EINVAL ; +break ;default :/* Most prctl options have no pointer arguments */ ret =get_errno (prctl (arg1, arg2, arg3, arg4, arg5));
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 11/15] linux-user/s390x: Mask si_addr for SIGSEGV
In reply to [email protected]From: Peter Maydell <[email protected]>
For s390x, the address passed to a signal handler in the siginfo_t si_addr field is masked (in the kernel this is done in do_sigbus() and do_sigsegv() in arch/s390/mm/fault.c). Implement this architecture-specific oddity in linux-user.
This is one of the issues described in
https://bugs.launchpad.net/qemu/+bug/1705118
--- linux-user/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/main.c +5 -1
@@ -3238,6 +3238,10 @@ void cpu_loop(CPUAlphaState *env)#endif /* TARGET_ALPHA */ #ifdef TARGET_S390X + +/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */ +#define S390X_FAIL_ADDR_MASK -4096LL +void cpu_loop (CPUS390XState *env) {CPUState *cs =CPU (s390_env_get_cpu (env));
@@ -3294,7 +3298,7 @@ void cpu_loop(CPUS390XState *env) sig =TARGET_SIGSEGV ;/* XXX: check env->error_code */ n =TARGET_SEGV_MAPERR ; - addr = env->__excp_addr; + addr = env->__excp_addr &S390X_FAIL_ADDR_MASK ; goto do_signal;case PGM_EXECUTE :case PGM_SPECIFICATION :
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 12/15] linux-user/ppc: Report correct fault address for data faults
In reply to [email protected]From: Peter Maydell <[email protected]>
For faults on loads and stores, ppc_cpu_handle_mmu_fault() in target/ppc/user_only_helper.c stores the offending address in env->spr[SPR_DAR]. Report this correctly to the guest in si_addr, rather than incorrectly using the address of the instruction that caused the fault.
This fixes the test case in
https://bugs.launchpad.net/qemu/+bug/1077116
for ppc, ppc64 and ppc64le.
--- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/main.c +1 -1
@@ -1420,7 +1420,7 @@ void cpu_loop(CPUPPCState *env) info.si_code =TARGET_SEGV_MAPERR ;break ; } - info._sifields._sigfault._addr = env->nip; + info._sifields._sigfault._addr = env->spr[SPR_DAR ];queue_signal (env, info.si_signo,QEMU_SI_FAULT , &info);break ;case POWERPC_EXCP_ISI :/* Instruction storage exception */
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 13/15] linux-user/sparc: Put address for data faults where linux-user expects it
In reply to [email protected]From: Peter Maydell <[email protected]>
In the user-mode-only version of sparc_cpu_handle_mmu_fault(), we must save the fault address for a data fault into the CPU state's mmu registers, because the code in linux-user/main.c expects to find it there in order to populate the si_addr field of the guest siginfo.
--- target/sparc/mmu_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target/sparc/mmu_helper.c +8 -0
@@ -30,10 +30,18 @@int sparc_cpu_handle_mmu_fault (CPUState *cs,vaddr address,int rw,int mmu_idx) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; +if (rw &2 ) { cs->exception_index =TT_TFAULT ; }else { cs->exception_index =TT_DFAULT ; +#ifdef TARGET_SPARC64 + env->dmmu.mmuregs[4 ] = address; +#else + env->mmuregs[4 ] = address; +#endif }return 1 ; }
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 14/15] linux-user: Handle rt_sigaction correctly for SPARC
In reply to [email protected]From: Peter Maydell <[email protected]>
SPARC is like Alpha in its handling of the rt_sigaction syscall:
it takes an extra parameter 'restorer' which needs to be copied into the sa_restorer field of the sigaction struct. The order of the arguments differs slightly between SPARC and Alpha but the implementation is otherwise the same. (Compare the rt_sigaction() functions in arch/sparc/kernel/sys_sparc_64.c and arch/alpha/kernel/signal.c.)
Note that this change is somewhat moot until SPARC acquires support for actually delivering RT signals.
--- linux-user/syscall.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
linux-user/syscall.c +23 -4
@@ -8579,8 +8579,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_rt_sigaction: {#if defined(TARGET_ALPHA ) -struct target_sigaction act, oact, *pact =0 ; +/* For Alpha and SPARC this is a 5 argument syscall, with +* a 'restorer' parameter which must be copied into the +* sa_restorer field of the sigaction struct. +* For Alpha that 'restorer' is arg5; for SPARC it is arg4, +* and arg5 is the sigsetsize. +* Alpha also has a separate rt_sigaction struct that it uses +* here; SPARC uses the usual sigaction struct. +*/ struct target_rt_sigaction *rt_act; +struct target_sigaction act, oact, *pact =0 ;if (arg4 !=sizeof (target_sigset_t)) { ret = -TARGET_EINVAL ;
@@ -8606,18 +8614,29 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user_struct(rt_act, arg3, 1); }#else +#ifdef TARGET_SPARC +target_ulong restorer = arg4; +target_ulong sigsetsize = arg5; +#else +target_ulong sigsetsize = arg4; +#endif struct target_sigaction *act;struct target_sigaction *oact; -if (arg4 !=sizeof (target_sigset_t)) { +if (sigsetsize !=sizeof (target_sigset_t)) { ret = -TARGET_EINVAL ;break ; }if (arg2) { -if (!lock_user_struct (VERIFY_READ , act, arg2,1 )) +if (!lock_user_struct (VERIFY_READ , act, arg2,1 )) { goto efault; - }else + } +#ifdef TARGET_SPARC + act->sa_restorer = restorer; +#endif + }else { act =NULL ; + }if (arg3) {if (!lock_user_struct (VERIFY_WRITE , oact, arg3,0 )) { ret = -TARGET_EFAULT ;
Signature · 1 line
2.14.2
[Qemu-devel] [PULL 15/15] linux-user: Fix calculation of auxv length
In reply to [email protected]From: Peter Maydell <[email protected]>
In commit 7c4ee5bcc82e643 we changed the order in which we construct the AUXV, but forgot to adjust the calculation of the length. The result is that we set info->auxv_len to a bogus and negative value, and then later on the code in open_self_auxv() gets confused and ends up presenting the guest with an empty file.
Since we now have to calculate the auxv length up-front as part of figuring out how much we're going to put on the stack, set info->auxv_len then; this allows us to assert that we put the same number of entries into auxv as we pre-calculated, rather than merely having a comment saying we need to do that.
--- linux-user/elfload.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
linux-user/elfload.c +9 -2
@@ -1732,6 +1732,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,#ifdef ELF_HWCAP2 size +=2 ;#endif + info->auxv_len = size * n; + size += envc + argc +2 ; size +=1 ;/* argc itself */ size *= n;
@@ -1760,7 +1762,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,put_user_ual (val, u_auxv); u_auxv += n; \ }while (0 ) -/* There must be exactly DLINFO_ITEMS entries here. */ #ifdef ARCH_DLINFO/* * ARCH_DLINFO must come first so platform specific code can enforce
@@ -1768,6 +1769,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,*/ ARCH_DLINFO ;#endif +/* There must be exactly DLINFO_ITEMS entries here, or the assert +* on info->auxv_len will trigger. +*/ NEW_AUX_ENT (AT_PHDR , (abi_ulong)(info->load_addr + exec->e_phoff));NEW_AUX_ENT (AT_PHENT , (abi_ulong)(sizeof (struct elf_phdr )));NEW_AUX_ENT (AT_PHNUM , (abi_ulong)(exec->e_phnum));
@@ -1793,7 +1797,10 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,NEW_AUX_ENT (AT_NULL ,0 );#undef NEW_AUX_ENT - info->auxv_len = u_argv - info->saved_auxv; +/* Check that our initial calculation of the auxv length matches how much +* we actually put into it. +*/ +assert (info->auxv_len == u_auxv - info->saved_auxv);put_user_ual (argc, u_argc);
Signature · 1 line
2.14.2
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
t [tag update] patchew/[email protected] -> patchew/[email protected] t [tag update] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'788f1bba45 linux-user: Fix calculation of auxv length052a0df24b linux-user: Handle rt_sigaction correctly for SPARCf604e7242e linux-user/sparc: Put address for data faults where linux-user expects it 72147cb49c linux-user/ppc: Report correct fault address for data faults e463bfe01b linux-user/s390x: Mask si_addr for SIGSEGV453566e577 linux-user: return EINVAL from prctl(PR_*_SECCOMP)fa4841c61b linux-user: fix 'finshed' typo in comment8c79f00a62 linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64 00aa6fca9b linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB 0404230a13 linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK 843644155e linux-user/hppa: Fix TARGET_MAP_TYPE928786ff34 linux-user/hppa: Fix typo for TARGET_NR_epoll_wait244abacff6 linux-user/hppa: Fix cpu_clone_regs63e9a64d06 linux-user/hppa: Fix TARGET_SA_* defines46e4119671 linux-user: Restrict usage of sa_restorer
=== OUTPUT BEGIN ===
Checking PATCH 1/15: linux-user: Restrict usage of sa_restorer... Checking PATCH 2/15: linux-user/hppa: Fix TARGET_SA_* defines... Checking PATCH 3/15: linux-user/hppa: Fix cpu_clone_regs... Checking PATCH 4/15: linux-user/hppa: Fix typo for TARGET_NR_epoll_wait... Checking PATCH 5/15: linux-user/hppa: Fix TARGET_MAP_TYPE...
ERROR: code indent should never use tabs
#25: FILE: linux-user/syscall_defs.h:1340:
+#define TARGET_MAP_TYPE 0x03^I^I/* Mask for type of mapping */$
ERROR: code indent should never use tabs
#27: FILE: linux-user/syscall_defs.h:1342:
+#define TARGET_MAP_TYPE 0x0f^I^I/* Mask for type of mapping */$
total: 2 errors, 0 warnings, 12 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 6/15: linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK... Checking PATCH 7/15: linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB... Checking PATCH 8/15: linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64... Checking PATCH 9/15: linux-user: fix 'finshed' typo in comment...
Checking PATCH 10/15: linux-user: return EINVAL from prctl(PR_*_SECCOMP)...
Checking PATCH 11/15: linux-user/s390x: Mask si_addr for SIGSEGV...
Checking PATCH 12/15: linux-user/ppc: Report correct fault address for data faults... Checking PATCH 13/15: linux-user/sparc: Put address for data faults where linux-user expects it... Checking PATCH 14/15: linux-user: Handle rt_sigaction correctly for SPARC...
Checking PATCH 15/15: linux-user: Fix calculation of auxv length...
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Peter Maydell
AppliedQuoted 10 lines · On 20 November 2017 at 21:21, <[email protected]> wrote:
From: Riku Voipio <[email protected]>
The following changes since commit
b0fbe46ad82982b289a44ee2495b59b0bad8a842:Update version for v2.11.0-rc0 release (2017-11-07 16:05:28 +0000)
are available in the git repository at:
git://git.linaro.org/people/riku.voipio/qemu.gittags/pull-linux-user-20171120
Quoted 8 lines
for you to fetch changes up to
f516511ea84d8bb3395d6ea95a7c7b80dc2a05e9:linux-user: Fix calculation of auxv length (2017-11-20 16:15:41 +0200)
----------------------------------------------------------------
late linux-user fixes for Qemu 2.11----------------------------------------------------------------
Applied, thanks.
-- PMM
This series failed build test on ppc host. Please find the details below.
Hi,
This series failed build test on ppc host. Please find the details below.
Type: series
Subject: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
Message-id: [email protected]
=== 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 echo "=== ENV ===" env echo "=== PACKAGES ===" rpm -qa echo "=== TEST BEGIN ===" INSTALL=$PWD/install BUILD=$PWD/build mkdir -p $BUILD $INSTALL SRC=$PWD cd $BUILD $SRC/configure --prefix=$INSTALL make -j100 # XXX: we need reliable clean up # make check -j100 V=1 make install === TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
error: RPC failed; result=18, HTTP code = 200
fatal: The remote end hung up unexpectedly
error: Could not fetch 3c8cf5a9c21ff8782164d1def7f44bd888713384 Traceback (most recent call last):
File "/home/patchew/patchew/patchew-cli", line 504, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf)
File "/home/patchew/patchew/patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
File "/usr/lib64/python3.4/subprocess.py", line 558, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f', '--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384', 'https://github.com/patchew-project/qemu']' returned non-zero exit status 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]