linux-user: enable NPTL on everything
v3 cover linux-user: enable NPTL on everything
This patchset enables NPTL on all linux-user targets; this is a change for i386, m68k, mipsn32, mipsn32el, mips64, mips64el, or32, ppc64, ppc46abi32, sparc, sparc32plus, sparc64, unicore32 and x86_64 (but not plain ppc or plain mips).
Testing: I've tested with a chroot that or32 and sparc32plus work; in both cases there were basic bugs in linux-user support (stat didn't work on or32; pipe busted on sparc; see separate patches) from which I conclude that these were simply untested targets, so the bar for "make things at least not worse" is an extremely low one. I cannot find any m68k binaries which don't die with an illegal instruction very early on (probably because we emulate coldfire and most m68k binaries assume 680x0), so I am treating that target as basically also broken. I've also tested PPC and PPC64 chroots, and of course the linux-user-0.3 testset from the wiki. I tested x86-64 and i386 with a chroot on an ARM host: they generally work though they still have missing bits (for instance x86-64 has no implementation of setup_frame etc for signal handling!).
Changes v2->v3:
* fixed dumb typos in m68k pointed out by Laurent
* included Alex's patch for i386 TLS setting
* added a patch for x86-64 (turns out to be easy)
* new patch which fixes bugs in clone() argument order for cris, x86-64, m68k, openrisc, unicore32 (noticed for x86-64 since otherwise glibc asserts in fork; others fixed based on examination of kernel source code)
* new patch adding a missing 'break' in i386's get_thread_area (noticed in review of the m68k patch in that area)
* new patch which removes all the now-redundant configure machinery and ifdefs
Alexander Graf (1):
linux-user: Add i386 TLS setter
Peter Maydell (12):
configure: Flip default of target_nptl
configure: Don't say target_nptl="no" if there is no linux-user
target
configure: Enable threading on all ppc and mips linux-user targets
configure: Enable threading for unicore32-linux-user
linux-user: Move includes of target-specific headers to end of qemu.h
linux-user: Enable NPTL for OpenRISC
linux-user: Enable NPTL for SPARC targets
linux-user: Enable NPTL for m68k
linux-user: Add missing 'break' in i386 get_thread_area syscall
linux-user: Clean up handling of clone() argument order
linux-user: Enable NPTL for x86-64
configure: Make NPTL non-optional
configure | 34 ++-------------- include/exec/gdbstub.h | 2 +- linux-user/arm/syscall.h | 2 + linux-user/cris/syscall.h | 2 + linux-user/i386/syscall.h | 2 + linux-user/i386/target_cpu.h | 19 ++++++++- linux-user/m68k/target_cpu.h | 6 ++- linux-user/main.c | 43 -------------------- linux-user/microblaze/syscall.h | 2 + linux-user/mips/syscall.h | 2 + linux-user/mips64/syscall.h | 2 + linux-user/mmap.c | 11 ----- linux-user/openrisc/target_cpu.h | 9 ++++- linux-user/ppc/syscall.h | 2 + linux-user/qemu.h | 20 ++++------ linux-user/s390x/syscall.h | 2 + linux-user/sparc/syscall.h | 7 ++++ linux-user/sparc/target_cpu.h | 16 ++++++-- linux-user/sparc64/syscall.h | 7 ++++ linux-user/syscall.c | 82 +++++++++++++------------------------- 20 files changed, 110 insertions(+), 162 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v3 1/13 configure: Flip default of target_nptl
Most targets either (a) support threading or (b) don't have a linux-user/bsd-user target, so make it default to 'yes', with those targets that don't support threading having to specifically say so.
This is a mechanical no-behaviour-change commit; some of the "no" entries it adds will be taken out in later patches.
--- configure | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
configure +16 -10
@@ -4173,7 +4173,7 @@ mkdir -p $target_dir echo "# Automatically generated by configure - do not modify" > $config_target_mak bflt="no" -target_nptl="no" +target_nptl="yes" interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"` gdb_xml_files=""
@@ -4183,69 +4183,71 @@ TARGET_ABI_DIR="" case "$target_name" in i386) + target_nptl="no" ;; x86_64) TARGET_BASE_ARCH=i386 + target_nptl="no" ;; alpha) - target_nptl="yes" ;; arm|armeb) TARGET_ARCH=arm bflt="yes" - target_nptl="yes" gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" ;; cris) - target_nptl="yes" ;; lm32) + target_nptl="no" ;; m68k) bflt="yes" gdb_xml_files="cf-core.xml cf-fp.xml" + target_nptl="no" ;; microblaze|microblazeel) TARGET_ARCH=microblaze bflt="yes" - target_nptl="yes" ;; mips|mipsel) TARGET_ARCH=mips echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak - target_nptl="yes" ;; mipsn32|mipsn32el) TARGET_ARCH=mips64 TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak echo "TARGET_ABI32=y" >> $config_target_mak + target_nptl="no" ;; mips64|mips64el) TARGET_ARCH=mips64 TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak + target_nptl="no" ;; moxie) + target_nptl="no" ;; or32) TARGET_ARCH=openrisc TARGET_BASE_ARCH=openrisc + target_nptl="no" ;; ppc) gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_nptl="yes" ;; ppcemb) TARGET_BASE_ARCH=ppc TARGET_ABI_DIR=ppc gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_nptl="yes" ;; ppc64) TARGET_BASE_ARCH=ppc TARGET_ABI_DIR=ppc gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" + target_nptl="no" ;; ppc64abi32) TARGET_ARCH=ppc64
@@ -4253,30 +4255,34 @@ case "$target_name" in TARGET_ABI_DIR=ppc echo "TARGET_ABI32=y" >> $config_target_mak gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" + target_nptl="no" ;; sh4|sh4eb) TARGET_ARCH=sh4 bflt="yes" - target_nptl="yes" ;; sparc) + target_nptl="no" ;; sparc64) TARGET_BASE_ARCH=sparc + target_nptl="no" ;; sparc32plus) TARGET_ARCH=sparc64 TARGET_BASE_ARCH=sparc TARGET_ABI_DIR=sparc echo "TARGET_ABI32=y" >> $config_target_mak + target_nptl="no" ;; s390x) - target_nptl="yes" ;; unicore32) + target_nptl="no" ;; xtensa|xtensaeb) TARGET_ARCH=xtensa + target_nptl="no" ;; *) error_exit "Unsupported target CPU"
Signature · 1 line
1.7.9.5
PATCH v3 2/13 configure: Don't say target_nptl="no" if there is no linux-user target
In reply to Peter MaydellFor architectures with no linux-user target, don't claim no NPTL support. This has no behavioural change, but it means that we won't accidentally add a new linux-user target without threading support in future (because attempting to do so would be a compile failure rather than a silent lack of support).
--- configure | 3 --- 1 file changed, 3 deletions(-)
configure +0 -3
@@ -4199,7 +4199,6 @@ case "$target_name" in cris) ;; lm32) - target_nptl="no" ;; m68k) bflt="yes"
@@ -4228,7 +4227,6 @@ case "$target_name" in target_nptl="no" ;; moxie) - target_nptl="no" ;; or32) TARGET_ARCH=openrisc
@@ -4282,7 +4280,6 @@ case "$target_name" in ;; xtensa|xtensaeb) TARGET_ARCH=xtensa - target_nptl="no" ;; *) error_exit "Unsupported target CPU"
Signature · 1 line
1.7.9.5
PATCH v3 3/13 configure: Enable threading on all ppc and mips linux-user targets
In reply to Peter MaydellThough threading (target_nptl) was enabled on the base PPC and MIPS targets, it wasn't enabled for the variants mipsn32, mipsn32el, mips64, mips64el, ppc64 or ppc46abi32 (probably an oversight). Enable threading consistently on all these targets.
--- configure | 4 ---- 1 file changed, 4 deletions(-)
configure +0 -4
@@ -4218,13 +4218,11 @@ case "$target_name" in TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak echo "TARGET_ABI32=y" >> $config_target_mak - target_nptl="no" ;; mips64|mips64el) TARGET_ARCH=mips64 TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak - target_nptl="no" ;; moxie) ;;
@@ -4245,7 +4243,6 @@ case "$target_name" in TARGET_BASE_ARCH=ppc TARGET_ABI_DIR=ppc gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_nptl="no" ;; ppc64abi32) TARGET_ARCH=ppc64
@@ -4253,7 +4250,6 @@ case "$target_name" in TARGET_ABI_DIR=ppc echo "TARGET_ABI32=y" >> $config_target_mak gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_nptl="no" ;; sh4|sh4eb) TARGET_ARCH=sh4
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v3 03/13] configure: Enable threading on all ppc and mips linux-user targets
Quoted 10 lines · Peter Maydell
Add x86-64 implementation of
cpu_set_tls()(like the kernel, we just have to calldo_arch_prctl()to set FS); this allows us to enable NPTL.Signed-off-by Peter Maydell <[email protected]>--- configure | 1 - linux-user/i386/target_cpu.h | 7 +++++++ linux-user/syscall.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
r~
PATCH v3 4/13 configure: Enable threading for unicore32-linux-user
In reply to Peter Maydellunicore32-linux-user provides cpu_set_tls(), so the failure to enable target_nptl was presumably an oversight. Enable it.
--- configure | 1 - 1 file changed, 1 deletion(-)
configure +0 -1
@@ -4272,7 +4272,6 @@ case "$target_name" in s390x) ;; unicore32) - target_nptl="no" ;; xtensa|xtensaeb) TARGET_ARCH=xtensa
Signature · 1 line
1.7.9.5
PATCH v3 5/13 linux-user: Move includes of target-specific headers to end of qemu.h
In reply to Peter MaydellThe target-specific headers (target_cpu.h and target_signal.h) might need to use the target-independent structure and function definitions of qemu.h; so include them only at the bottom of qemu.h, not the top.
--- linux-user/qemu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
linux-user/qemu.h +7 -2
@@ -16,8 +16,6 @@#include "exec/user/thunk.h" #include "syscall_defs.h" #include "syscall.h" -#include "target_cpu.h" -#include "target_signal.h" #include "exec/gdbstub.h" #include "qemu/queue.h"
@@ -454,4 +452,11 @@ static inline void *lock_user_string(abi_ulong guest_addr)#include <pthread.h> #endif +/* Include target-specific struct and function definitions; +* they may need access to the target-independent structures +* above, so include them last. +*/ +#include "target_cpu.h" +#include "target_signal.h" +#endif /* QEMU_H */
Signature · 1 line
1.7.9.5
PATCH v3 6/13 linux-user: Enable NPTL for OpenRISC
In reply to Peter MaydellThe OpenRISC kernel ignores CLONE_SETTLS in its copy_thread() implementation, so a cpu_set_tls() implementation is a no-op. cpu_clone_regs() was setting the syscall return value in the wrong register -- it is gpr[11], not gpr[2]. With these two things fixed, we can compile with NPTL enabled.
--- configure | 1 - linux-user/openrisc/target_cpu.h | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
configure +0 -1
@@ -4229,7 +4229,6 @@ case "$target_name" in or32) TARGET_ARCH=openrisc TARGET_BASE_ARCH=openrisc - target_nptl="no" ;; ppc) gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
linux-user/openrisc/target_cpu.h +7 -2
@@ -25,9 +25,14 @@ static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp)if (newsp) { env->gpr[1 ] = newsp; } - env->gpr[2] = 0; + env->gpr[11] = 0; } -/* TODO: need to implement cpu_set_tls() */ +static inline void cpu_set_tls (CPUOpenRISCState *env,target_ulong newtls) +{ +/* Linux kernel 3.10 does not pay any attention to CLONE_SETTLS +* in copy_thread(), so QEMU need not do so either. +*/ +}#endif
Signature · 1 line
1.7.9.5
PATCH v3 7/13 linux-user: Enable NPTL for SPARC targets
In reply to Peter MaydellProvide the missing cpu_set_tls(), and resolve the FIXME in cpu_clone_regs() by clearing the carry flag for the child. This allows us to turn on building with NPTL for SPARC.
--- configure | 3 --- linux-user/sparc/target_cpu.h | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-)
configure +0 -3
@@ -4255,18 +4255,15 @@ case "$target_name" in bflt="yes" ;; sparc) - target_nptl="no" ;; sparc64) TARGET_BASE_ARCH=sparc - target_nptl="no" ;; sparc32plus) TARGET_ARCH=sparc64 TARGET_BASE_ARCH=sparc TARGET_ABI_DIR=sparc echo "TARGET_ABI32=y" >> $config_target_mak - target_nptl="no" ;; s390x) ;;
linux-user/sparc/target_cpu.h +12 -4
@@ -25,12 +25,20 @@ static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp)if (newsp) { env->regwptr[22 ] = newsp; } +/* syscall return for clone child: 0, and clear CF since +* this counts as a success return value. +*/ env->regwptr[0 ] =0 ; -/* FIXME: Do we also need to clear CF? */ -/* XXXXX */ - printf("HELPME: %s:%d\n", __FILE__, __LINE__); +#if defined(TARGET_SPARC64 ) && !defined(TARGET_ABI32 ) + env->xcc &= ~PSR_CARRY ; +#else + env->psr &= ~PSR_CARRY ; +#endif } -/* TODO: need to implement cpu_set_tls() */ +static inline void cpu_set_tls (CPUSPARCState *env,target_ulong newtls) +{ + env->gregs[7 ] = newtls; +}#endif
Signature · 1 line
1.7.9.5
PATCH v3 8/13 linux-user: Enable NPTL for m68k
In reply to Peter MaydellFor m68k, per-thread data is a purely kernel construct with no CPU level support. Implement it via a field in the TaskState structure, used by cpu_set_tls() and the set_thread_area/get_thread_area syscalls. This allows us to enable compilation with NPTL.
--- configure | 1 - linux-user/m68k/target_cpu.h | 6 +++++- linux-user/qemu.h | 1 + linux-user/syscall.c | 12 ++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-)
configure +0 -1
@@ -4203,7 +4203,6 @@ case "$target_name" in m68k) bflt="yes" gdb_xml_files="cf-core.xml cf-fp.xml" - target_nptl="no" ;; microblaze|microblazeel) TARGET_ARCH=microblaze
linux-user/m68k/target_cpu.h +5 -1
@@ -29,6 +29,10 @@ static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp) env->dregs[0] = 0; } -/* TODO: need to implement cpu_set_tls() */ +static inline void cpu_set_tls (CPUM68KState *env,target_ulong newtls) +{ +TaskState *ts = env->opaque; + ts->tp_value = newtls; +}#endif
linux-user/qemu.h +1 -0
@@ -121,6 +121,7 @@ typedef struct TaskState {#endif #ifdef TARGET_M68K int sim_syscalls; +abi_ulong tp_value;#endif #if defined(TARGET_ARM ) || defined(TARGET_M68K ) || defined(TARGET_UNICORE32 )/* Extra fields for semihosted binaries. */
linux-user/syscall.c +12 -0
@@ -8558,6 +8558,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,#elif defined(TARGET_I386 ) && defined(TARGET_ABI32 ) ret =do_set_thread_area (cpu_env, arg1);break ; +#elif defined(TARGET_M68K ) + { +TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + ts->tp_value = arg1; +break ; + }#else goto unimplemented_nowarn;#endif
@@ -8566,6 +8572,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_get_thread_area:#if defined(TARGET_I386 ) && defined(TARGET_ABI32 ) ret =do_get_thread_area (cpu_env, arg1); +#elif defined(TARGET_M68K ) + { +TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + ret = ts->tp_value; +break ; + }#else goto unimplemented_nowarn;#endif
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v3 08/13] linux-user: Enable NPTL for m68k
Quoted 6 lines · Peter Maydell
For m68k, per-thread data is a purely kernel construct with no CPU level support. Implement it via a field in the TaskState structure, used by
cpu_set_tls()and the set_thread_area/get_thread_area syscalls. This allows us to enable compilation with NPTL.Signed-off-by Peter Maydell <[email protected]>
PATCH v3 9/13 linux-user: Add missing 'break' in i386 get_thread_area syscall
In reply to Peter MaydellThe i386 code for the get_thread_area syscall was missing a 'break' which meant it would have fallen through into the implementation of the following syscall; add it.
--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
@@ -8572,6 +8572,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,case TARGET_NR_get_thread_area:#if defined(TARGET_I386 ) && defined(TARGET_ABI32 ) ret =do_get_thread_area (cpu_env, arg1); +break ;#elif defined(TARGET_M68K ) {TaskState *ts = ((CPUArchState *)cpu_env)->opaque;
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v3 09/13] linux-user: Add missing 'break' in i386 get_thread_area syscall
Quoted 8 lines · Peter Maydell
The i386 code for the
get_thread_areasyscall was missing a 'break' which meant it would have fallen through into the implementation of the following syscall; add it.Signed-off-by Peter Maydell <[email protected]>--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)
r~
PATCH v3 10/13 linux-user: Clean up handling of clone() argument order
In reply to Peter MaydellLinux manages to have three separate orderings of the arguments to the clone() syscall on different architectures. In the kernel these are selected via CONFIG_CLONE_BACKWARDS and CONFIG_CLONE_BACKWARDS2. Clean up our implementation of this to use similar #define names rather than a TARGET_* ifdef ladder.
This includes behaviour changes fixing bugs on cris, x86-64, m68k, openrisc and unicore32. cris had explicit but wrong handling; the others were just incorrectly using QEMU's default, which happened to be the equivalent of CONFIG_CLONE_BACKWARDS. (unicore32 appears to be broken in the mainline kernel in that it tries to use arg3 for both parent_tidptr and newtls simultaneously -- we don't attempt to emulate this bug...)
--- linux-user/arm/syscall.h | 2 ++ linux-user/cris/syscall.h | 2 ++ linux-user/i386/syscall.h | 2 ++ linux-user/microblaze/syscall.h | 2 ++ linux-user/mips/syscall.h | 2 ++ linux-user/mips64/syscall.h | 2 ++ linux-user/ppc/syscall.h | 2 ++ linux-user/s390x/syscall.h | 2 ++ linux-user/sparc/syscall.h | 7 +++++++ linux-user/sparc64/syscall.h | 7 +++++++ linux-user/syscall.c | 18 +++++++++++------- 11 files changed, 41 insertions(+), 7 deletions(-)
linux-user/arm/syscall.h +2 -0
@@ -40,3 +40,5 @@ struct target_pt_regs {#else #define UNAME_MACHINE "armv5tel"#endif + +#define TARGET_CLONE_BACKWARDS
linux-user/cris/syscall.h +2 -0
@@ -38,4 +38,6 @@ struct target_pt_regs { unsigned long eda; }; +#define TARGET_CLONE_BACKWARDS2 +#endif
linux-user/i386/syscall.h +2 -0
@@ -144,3 +144,5 @@ struct target_vm86plus_struct { };#define UNAME_MACHINE "i686" + +#define TARGET_CLONE_BACKWARDS
linux-user/microblaze/syscall.h +2 -0
@@ -48,4 +48,6 @@ struct target_pt_regs { uint32_t kernel_mode; }; +#define TARGET_CLONE_BACKWARDS +#endif
linux-user/mips/syscall.h +2 -0
@@ -225,3 +225,5 @@ struct target_pt_regs {#define TARGET_QEMU_ESIGRETURN 255#define UNAME_MACHINE "mips" + +#define TARGET_CLONE_BACKWARDS
linux-user/mips64/syscall.h +2 -0
@@ -222,3 +222,5 @@ struct target_pt_regs {#define TARGET_QEMU_ESIGRETURN 255#define UNAME_MACHINE "mips64" + +#define TARGET_CLONE_BACKWARDS
linux-user/ppc/syscall.h +2 -0
@@ -62,3 +62,5 @@ struct target_revectored_struct {#else #define UNAME_MACHINE "ppc"#endif + +#define TARGET_CLONE_BACKWARDS
linux-user/s390x/syscall.h +2 -0
@@ -21,3 +21,5 @@ struct target_pt_regs { };#define UNAME_MACHINE "s390x" + +#define TARGET_CLONE_BACKWARDS
linux-user/sparc/syscall.h +7 -0
@@ -7,3 +7,10 @@ struct target_pt_regs { };#define UNAME_MACHINE "sun4" + +/* SPARC kernels don't define this in their Kconfig, but they have the +* same ABI as if they did, implemented by sparc-specific code which fishes +* directly in the u_regs() struct for half the parameters in sparc_do_fork() +* and copy_thread(). +*/ +#define TARGET_CLONE_BACKWARDS
linux-user/sparc64/syscall.h +7 -0
@@ -8,3 +8,10 @@ struct target_pt_regs { };#define UNAME_MACHINE "sun4u" + +/* SPARC kernels don't define this in their Kconfig, but they have the +* same ABI as if they did, implemented by sparc-specific code which fishes +* directly in the u_regs() struct for half the parameters in sparc_do_fork() +* and copy_thread(). +*/ +#define TARGET_CLONE_BACKWARDS
linux-user/syscall.c +11 -7
@@ -6956,16 +6956,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret =get_errno (fsync (arg1));break ;case TARGET_NR_clone: -#if defined(TARGET_SH4 ) || defined(TARGET_ALPHA ) - ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg5, arg4)); -#elif defined(TARGET_CRIS ) - ret =get_errno (do_fork (cpu_env, arg2, arg1, arg3, arg4, arg5)); -#elif defined(TARGET_MICROBLAZE ) +/* Linux manages to have three different orderings for its +* arguments to clone(); the BACKWARDS and BACKWARDS2 defines +* match the kernel's CONFIG_CLONE_* settings. +* Microblaze is further special in that it uses a sixth +* implicit argument to clone for the TLS pointer. +*/ +#if defined(TARGET_MICROBLAZE ) ret =get_errno (do_fork (cpu_env, arg1, arg2, arg4, arg6, arg5)); -#elif defined(TARGET_S390X ) +#elif defined(TARGET_CLONE_BACKWARDS ) + ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg4, arg5)); +#elif defined(TARGET_CLONE_BACKWARDS2 ) ret =get_errno (do_fork (cpu_env, arg2, arg1, arg3, arg5, arg4));#else - ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg4, arg5)); + ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg5, arg4));#endif break ;#ifdef __NR_exit_group
Signature · 1 line
1.7.9.5
PATCH v3 11/13 linux-user: Add i386 TLS setter
In reply to Peter MaydellFrom: Alexander Graf <[email protected]>
We can easily set the TLS on i386. Add code to do so.
[PMM: also remove "target_nptl=no" line from configure, for
consistency with other patches in this series]
--- configure | 1 - linux-user/i386/target_cpu.h | 12 ++++++++++-- linux-user/syscall.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)
configure +0 -1
@@ -4183,7 +4183,6 @@ TARGET_ABI_DIR="" case "$target_name" in i386) - target_nptl="no" ;; x86_64) TARGET_BASE_ARCH=i386
linux-user/i386/target_cpu.h +10 -2
@@ -28,6 +28,14 @@ static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp) env->regs[R_EAX] = 0; } -/* TODO: need to implement cpu_set_tls() */ +#if defined(TARGET_ABI32 ) +abi_long do_set_thread_area (CPUX86State *env,abi_ulong ptr); -#endif +static inline void cpu_set_tls (CPUX86State *env,target_ulong newtls) +{ +do_set_thread_area (env, newtls); +cpu_x86_load_seg (env,R_GS , env->segs[R_GS ].selector); +} +#endif /* defined(TARGET_ABI32) */ + +#endif /* !defined(TARGET_CPU_H) */
linux-user/syscall.c +1 -1
@@ -4055,7 +4055,7 @@ static abi_long do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr, }#if defined(TARGET_I386 ) && defined(TARGET_ABI32 ) -static abi_long do_set_thread_area (CPUX86State *env,abi_ulong ptr) +abi_long do_set_thread_area (CPUX86State *env,abi_ulong ptr) {uint64_t *gdt_table =g2h (env->gdt.base);struct target_modify_ldt_ldt_s ldt_info;
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v3 11/13] linux-user: Add i386 TLS setter
Quoted 5 lines · Peter Maydell
From: Alexander Graf <[email protected]>
We can easily set the TLS on i386. Add code to do so.
Signed-off-by Alexander Graf <[email protected]>
Quoted 8 lines
[PMM: also remove "target_nptl=no" line from configure, for
consistency with other patches in this series]Signed-off-by Peter Maydell <[email protected]>--- configure | 1 - linux-user/i386/target_cpu.h | 12 ++++++++++-- linux-user/syscall.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-)
r~
PATCH v3 12/13 linux-user: Enable NPTL for x86-64
In reply to Peter MaydellAdd x86-64 implementation of cpu_set_tls() (like the kernel, we just have to call do_arch_prctl() to set FS); this allows us to enable NPTL.
--- configure | 1 - linux-user/i386/target_cpu.h | 7 +++++++ linux-user/syscall.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-)
configure +0 -1
@@ -4186,7 +4186,6 @@ case "$target_name" in ;; x86_64) TARGET_BASE_ARCH=i386 - target_nptl="no" ;; alpha) ;;
linux-user/i386/target_cpu.h +7 -0
@@ -36,6 +36,13 @@ static inline void cpu_set_tls(CPUX86State *env, target_ulong newtls)do_set_thread_area (env, newtls);cpu_x86_load_seg (env,R_GS , env->segs[R_GS ].selector); } +#else +abi_long do_arch_prctl (CPUX86State *env,int code,abi_ulong addr); + +static inline void cpu_set_tls (CPUX86State *env,target_ulong newtls) +{ +do_arch_prctl (env,TARGET_ARCH_SET_FS , newtls); +}#endif /* defined(TARGET_ABI32) */ #endif /* !defined(TARGET_CPU_H) */
linux-user/syscall.c +1 -1
@@ -4189,7 +4189,7 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr)#endif /* TARGET_I386 && TARGET_ABI32 */ #ifndef TARGET_ABI32 -static abi_long do_arch_prctl (CPUX86State *env,int code,abi_ulong addr) +abi_long do_arch_prctl (CPUX86State *env,int code,abi_ulong addr) {abi_long ret =0 ;abi_ulong val;
Signature · 1 line
1.7.9.5
PATCH v3 13/13 configure: Make NPTL non-optional
In reply to Peter MaydellNow all linux-user targets support building with NPTL, we can make it mandatory. This is a good idea because:
* NPTL is no longer new and experimental; it is completely standard
* in practice, linux-user without NPTL is nearly useless for binaries built against non-ancient glibc
* it allows us to delete the rather untested code for handling the non-NPTL configuration
Note that this patch leaves the CONFIG_USE_NPTL ifdefs in the bsd-user codebase alone. This makes no change for bsd-user, since our configure test for NPTL had a "#include <linux/futex.h>" which means bsd-user would never have been compiled with CONFIG_USE_NPTL defined, and it still is not.
--- configure | 25 +++---------------------- include/exec/gdbstub.h | 2 +- linux-user/main.c | 43 ------------------------------------------- linux-user/mmap.c | 11 ----------- linux-user/qemu.h | 10 ---------- linux-user/syscall.c | 47 +---------------------------------------------- 6 files changed, 5 insertions(+), 133 deletions(-)
configure +3 -22
@@ -155,7 +155,6 @@ curl="" curses="" docs="" fdt="" -nptl="" pixman="" sdl="" virtfs=""
@@ -854,10 +853,6 @@ for opt do ;; --enable-fdt) fdt="yes" ;; - --disable-nptl) nptl="no" - ;; - --enable-nptl) nptl="yes" - ;; --enable-mixemu) mixemu="yes" ;; --disable-linux-aio) linux_aio="no"
@@ -1095,8 +1090,6 @@ echo " --disable-slirp disable SLIRP userspace network connectivity" echo " --disable-kvm disable KVM acceleration support" echo " --enable-kvm enable KVM acceleration support" echo " --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)" -echo " --disable-nptl disable usermode NPTL support" -echo " --enable-nptl enable usermode NPTL support" echo " --enable-system enable all system emulation targets" echo " --disable-system disable all system emulation targets" echo " --enable-user enable supported user emulation targets"
@@ -1431,7 +1424,7 @@ fi ########################################## # NPTL probe -if test "$nptl" != "no" ; then +if test "$linux_user" = "yes"; then cat > $TMPC <<EOF #include <sched.h> #include <linux/futex.h>
@@ -1442,14 +1435,8 @@ int main(void) { return 0; } EOF - - if compile_object ; then - nptl=yes - else - if test "$nptl" = "yes" ; then - feature_not_found "nptl" - fi - nptl=no + if ! compile_object ; then + feature_not_found "nptl" fi fi
@@ -3547,7 +3534,6 @@ echo "bluez support $bluez" echo "Documentation $docs" [ ! -z "$uname_release" ] && \ echo "uname -r $uname_release" -echo "NPTL support $nptl" echo "GUEST_BASE $guest_base" echo "PIE $pie" echo "vde support $vde"
@@ -4173,7 +4159,6 @@ mkdir -p $target_dir echo "# Automatically generated by configure - do not modify" > $config_target_mak bflt="no" -target_nptl="yes" interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"` gdb_xml_files=""
@@ -4344,10 +4329,6 @@ fi if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then echo "TARGET_HAS_BFLT=y" >> $config_target_mak fi -if test "$target_user_only" = "yes" \ - -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then - echo "CONFIG_USE_NPTL=y" >> $config_target_mak -fi if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak fi
include/exec/gdbstub.h +1 -1
@@ -32,7 +32,7 @@ void gdb_register_coprocessor(CPUArchState *env,static inline int cpu_index (CPUState *cpu) { -#if defined(CONFIG_USER_ONLY ) && defined(CONFIG_USE_NPTL ) +#if defined(CONFIG_USER_ONLY )return cpu->host_tid;#else return cpu->cpu_index +1 ;
linux-user/main.c +0 -43
62 lines not on this page · raw message
linux-user/mmap.c +0 -11
@@ -33,7 +33,6 @@//#define DEBUG_MMAP -#if defined(CONFIG_USE_NPTL )static pthread_mutex_t mmap_mutex =PTHREAD_MUTEX_INITIALIZER ;static __threadint mmap_lock_count;
@@ -66,16 +65,6 @@ void mmap_fork_end(int child)else pthread_mutex_unlock (&mmap_mutex); } -#else -/* We aren't threadsafe to start with, so no need to worry about locking. */ -void mmap_lock (void ) -{ -} - -void mmap_unlock (void ) -{ -} -#endif /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect (abi_ulong start,abi_ulong len,int prot)
linux-user/qemu.h +0 -10
@@ -19,11 +19,7 @@#include "exec/gdbstub.h" #include "qemu/queue.h" -#if defined(CONFIG_USE_NPTL )#define THREAD __thread -#else -#define THREAD -#endif /* This struct is used to hold certain information about the image. * Basically, it replicates in user space what would be certain
@@ -116,9 +112,7 @@ typedef struct TaskState {uint32_t v86flags;uint32_t v86mask;#endif -#ifdef CONFIG_USE_NPTL abi_ulong child_tidptr; -#endif #ifdef TARGET_M68K int sim_syscalls;abi_ulong tp_value;
@@ -268,10 +262,8 @@ void mmap_unlock(void);abi_ulong mmap_find_vma (abi_ulong ,abi_ulong );void cpu_list_lock (void );void cpu_list_unlock (void ); -#if defined(CONFIG_USE_NPTL )void mmap_fork_start (void );void mmap_fork_end (int child); -#endif /* main.c */ extern unsigned long guest_stack_size;
@@ -449,9 +441,7 @@ static inline void *lock_user_string(abi_ulong guest_addr)#define unlock_user_struct (host_ptr, guest_addr, copy) \ unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0) -#if defined(CONFIG_USE_NPTL )#include <pthread.h> -#endif /* Include target-specific struct and function definitions; * they may need access to the target-independent structures
linux-user/syscall.c +1 -46
157 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH v3 13/13] configure: Make NPTL non-optional
Quoted 15 lines · Peter Maydell
Now all linux-user targets support building with NPTL, we can make it mandatory. This is a good idea because:
* NPTL is no longer new and experimental; it is completely standard
* in practice, linux-user without NPTL is nearly useless for binaries built against non-ancient glibc
* it allows us to delete the rather untested code for handling the non-NPTL configurationNote that this patch leaves the
CONFIG_USE_NPTLifdefs in the bsd-user codebase alone. This makes no change for bsd-user, since our configure test for NPTL had a "#include <linux/futex.h>" which means bsd-user would never have been compiled withCONFIG_USE_NPTLdefined, and it still is not.Signed-off-by Peter Maydell <[email protected]>
Quoted 9 lines
--- configure | 25 +++---------------------- include/exec/gdbstub.h | 2 +- linux-user/main.c | 43 ------------------------------------------- linux-user/mmap.c | 11 ----------- linux-user/qemu.h | 10 ---------- linux-user/syscall.c | 47 +---------------------------------------------- 6 files changed, 5 insertions(+), 133 deletions(-)
r~
Ping! Can we get this in for 1.6?
thanks
-- PMM
Quoted 76 lines · Peter Maydell
This patchset enables NPTL on all linux-user targets; this is a change for i386, m68k, mipsn32, mipsn32el, mips64, mips64el, or32, ppc64, ppc46abi32, sparc, sparc32plus, sparc64, unicore32 and
x86_64(but not plain ppc or plain mips).Testing: I've tested with a chroot that or32 and sparc32plus work; in both cases there were basic bugs in linux-user support (stat didn't work on or32; pipe busted on sparc; see separate patches) from which I conclude that these were simply untested targets, so the bar for "make things at least not worse" is an extremely low one. I cannot find any m68k binaries which don't die with an illegal instruction very early on (probably because we emulate coldfire and most m68k binaries assume 680x0), so I am treating that target as basically also broken. I've also tested PPC and PPC64 chroots, and of course the linux-user-0.3 testset from the wiki. I tested x86-64 and i386 with a chroot on an ARM host: they generally work though they still have missing bits (for instance x86-64 has no implementation of
setup_frameetc for signal handling!).Changes
v2->v3:
* fixed dumb typos in m68k pointed out by Laurent
* included Alex's patch for i386 TLS setting
* added a patch for x86-64 (turns out to be easy)
* new patch which fixes bugs inclone()argument order for cris, x86-64, m68k, openrisc, unicore32 (noticed for x86-64 since otherwise glibc asserts in fork; others fixed based on examination of kernel source code)
* new patch adding a missing 'break' in i386'sget_thread_area(noticed in review of the m68k patch in that area)
* new patch which removes all the now-redundant configure machinery and ifdefsAlexander Graf (1):
linux-user: Add i386 TLS setterPeter Maydell (12):
configure: Flip default oftarget_nptl
configure: Don't say target_nptl="no" if there is no linux-user
target
configure: Enable threading on all ppc and mips linux-user targets
configure: Enable threading for unicore32-linux-user
linux-user: Move includes of target-specific headers to end ofqemu.h
linux-user: Enable NPTL for OpenRISC
linux-user: Enable NPTL for SPARC targets
linux-user: Enable NPTL for m68k
linux-user: Add missing 'break' in i386get_thread_areasyscall
linux-user: Clean up handling ofclone()argument order
linux-user: Enable NPTL for x86-64
configure: Make NPTL non-optionalconfigure | 34 ++-------------- include/exec/gdbstub.h | 2 +- linux-user/arm/syscall.h | 2 + linux-user/cris/syscall.h | 2 + linux-user/i386/syscall.h | 2 + linux-user/i386/target_cpu.h | 19 ++++++++- linux-user/m68k/target_cpu.h | 6 ++- linux-user/main.c | 43 -------------------- linux-user/microblaze/syscall.h | 2 + linux-user/mips/syscall.h | 2 + linux-user/mips64/syscall.h | 2 + linux-user/mmap.c | 11 ----- linux-user/openrisc/target_cpu.h | 9 ++++- linux-user/ppc/syscall.h | 2 + linux-user/qemu.h | 20 ++++------ linux-user/s390x/syscall.h | 2 + linux-user/sparc/syscall.h | 7 ++++ linux-user/sparc/target_cpu.h | 16 ++++++-- linux-user/sparc64/syscall.h | 7 ++++ linux-user/syscall.c | 82 +++++++++++++------------------------- 20 files changed, 110 insertions(+), 162 deletions(-)--
1.7.9.5