linux-user fixes, mostly for hppa
cover linux-user fixes, mostly for hppa
I believe these were last posted back in March. I must claim responsibility for not pinging earlier.
r~
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
Richard Henderson (2):
linux-user: Restrict usage of sa_restorer
linux-user/hppa: Fix cpu_clone_regs
linux-user/hppa/syscall_nr.h | 2 +- linux-user/hppa/target_cpu.h | 4 ++++ linux-user/syscall_defs.h | 40 +++++++++++++++++++++++++++++++++++++++- linux-user/signal.c | 4 ++-- linux-user/syscall.c | 31 ++++++++++++++++++++----------- 5 files changed, 66 insertions(+), 15 deletions(-)
Signature · 1 line
2.13.6
PATCH 1/7 linux-user: Restrict usage of sa_restorer
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/syscall_defs.h | 13 +++++++++++++ linux-user/signal.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-)
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
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. */
Signature · 1 line
2.13.6
PATCH 2/7 linux-user/hppa: Fix TARGET_SA_* defines
In reply to Richard HendersonFrom: 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.13.6
PATCH 3/7 linux-user/hppa: Fix cpu_clone_regs
In reply to Richard HendersonFrom: 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.13.6
PATCH 4/7 linux-user/hppa: Fix typo for TARGET_NR_epoll_wait
In reply to Richard HendersonFrom: 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.13.6
PATCH 5/7 linux-user/hppa: Fix TARGET_MAP_TYPE
In reply to Richard HendersonFrom: 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.13.6
PATCH 6/7 linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK
In reply to Richard HendersonFrom: 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.13.6
PATCH 7/7 linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
In reply to Richard HendersonFrom: 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_defs.h | 10 ++++++++++ linux-user/syscall.c | 31 ++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-)
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
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 )
Signature · 1 line
2.13.6
Riku Voipio
AppliedQuoted 2 lines · Richard Henderson
I believe these were last posted back in March. I must claim responsibility for not pinging earlier.
Thanks, applied to linux-user
Quoted 26 lines
r~
Helge Deller (5):
linux-user/hppa: Fix TARGET_SA_* defines linux-user/hppa: Fix typo forTARGET_NR_epoll_waitlinux-user/hppa: FixTARGET_MAP_TYPE
linux-user/hppa: FixTARGET_F_RDLCK,TARGET_F_WRLCK,TARGET_F_UNLCK
linux-user: HandleTARGET_MAP_STACKandTARGET_MAP_HUGETLBRichard Henderson (2):
linux-user: Restrict usage ofsa_restorer
linux-user/hppa: Fixcpu_clone_regslinux-user/hppa/syscall_nr.h | 2 +- linux-user/hppa/target_cpu.h | 4 ++++ linux-user/syscall_defs.h | 40 +++++++++++++++++++++++++++++++++++++++- linux-user/signal.c | 4 ++-- linux-user/syscall.c | 31 ++++++++++++++++++++----------- 5 files changed, 66 insertions(+), 15 deletions(-)Signature · 1 line
2.13.6