All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86
@ 2013-07-12 20:12 Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 1/8] configure: Flip default of target_nptl Peter Maydell
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

This patchset enables NPTL on all linux-user targets except i386 and
x86-64; this is a change for m68k, mipsn32, mipsn32el, mips64, mips64el,
or32, ppc64, ppc46abi32, sparc, sparc32plus, sparc64, unicore32
(but not plain ppc or plain mips). The first four patches have
been on list before and reviewed; the last four are new.

(i386 is addressed by Alex's patch; x86-64 I need to investigate
more closely to figure out how it's supposed to work; then we can
commit a patch which rips out CONFIG_USE_NPTL completely.)

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.

Peter Maydell (8):
  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

 configure                        |   13 +++----------
 linux-user/m68k/target_cpu.h     |    6 +++++-
 linux-user/openrisc/target_cpu.h |    9 +++++++--
 linux-user/qemu.h                |   10 ++++++++--
 linux-user/sparc/target_cpu.h    |   16 ++++++++++++----
 linux-user/syscall.c             |   10 ++++++++++
 6 files changed, 45 insertions(+), 19 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 1/8] configure: Flip default of target_nptl
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 2/8] configure: Don't say target_nptl="no" if there is no linux-user target Peter Maydell
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
 configure |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index cb0f870..ae9519c 100755
--- a/configure
+++ b/configure
@@ -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"
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 2/8] configure: Don't say target_nptl="no" if there is no linux-user target
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 1/8] configure: Flip default of target_nptl Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 3/8] configure: Enable threading on all ppc and mips linux-user targets Peter Maydell
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

For 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).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
 configure |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/configure b/configure
index ae9519c..c159f34 100755
--- a/configure
+++ b/configure
@@ -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"
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 3/8] configure: Enable threading on all ppc and mips linux-user targets
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 1/8] configure: Flip default of target_nptl Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 2/8] configure: Don't say target_nptl="no" if there is no linux-user target Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 4/8] configure: Enable threading for unicore32-linux-user Peter Maydell
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

Though 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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
 configure |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/configure b/configure
index c159f34..84bcbdc 100755
--- a/configure
+++ b/configure
@@ -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
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 4/8] configure: Enable threading for unicore32-linux-user
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
                   ` (2 preceding siblings ...)
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 3/8] configure: Enable threading on all ppc and mips linux-user targets Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h Peter Maydell
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

unicore32-linux-user provides cpu_set_tls(), so the failure
to enable target_nptl was presumably an oversight. Enable it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
---
 configure |    1 -
 1 file changed, 1 deletion(-)

diff --git a/configure b/configure
index 84bcbdc..4a241e0 100755
--- a/configure
+++ b/configure
@@ -4272,7 +4272,6 @@ case "$target_name" in
   s390x)
   ;;
   unicore32)
-    target_nptl="no"
   ;;
   xtensa|xtensaeb)
     TARGET_ARCH=xtensa
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
                   ` (3 preceding siblings ...)
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 4/8] configure: Enable threading for unicore32-linux-user Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-13 21:01   ` Richard Henderson
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC Peter Maydell
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

The 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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/qemu.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 6569608..8c420da 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -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 */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
                   ` (4 preceding siblings ...)
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-13  7:40   ` Jia Liu
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 7/8] linux-user: Enable NPTL for SPARC targets Peter Maydell
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k Peter Maydell
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

The 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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 configure                        |    1 -
 linux-user/openrisc/target_cpu.h |    9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 4a241e0..3848c1c 100755
--- a/configure
+++ b/configure
@@ -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"
diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h
index 501fb81..32a46ac 100644
--- a/linux-user/openrisc/target_cpu.h
+++ b/linux-user/openrisc/target_cpu.h
@@ -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
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 7/8] linux-user: Enable NPTL for SPARC targets
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
                   ` (5 preceding siblings ...)
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-13 21:01   ` Richard Henderson
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k Peter Maydell
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

Provide 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.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 configure                     |    3 ---
 linux-user/sparc/target_cpu.h |   16 ++++++++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 3848c1c..117191e 100755
--- a/configure
+++ b/configure
@@ -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)
   ;;
diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h
index 5a620a2..4944d46 100644
--- a/linux-user/sparc/target_cpu.h
+++ b/linux-user/sparc/target_cpu.h
@@ -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
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k
  2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
                   ` (6 preceding siblings ...)
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 7/8] linux-user: Enable NPTL for SPARC targets Peter Maydell
@ 2013-07-12 20:12 ` Peter Maydell
  2013-07-13 10:28   ` Laurent Vivier
  7 siblings, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2013-07-12 20:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

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 <peter.maydell@linaro.org>
---
 configure                    |    1 -
 linux-user/m68k/target_cpu.h |    6 +++++-
 linux-user/qemu.h            |    1 +
 linux-user/syscall.c         |   10 ++++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 117191e..67e6437 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h
index 8a2a305..cad9c90 100644
--- a/linux-user/m68k/target_cpu.h
+++ b/linux-user/m68k/target_cpu.h
@@ -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
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 8c420da..1ff0fa8 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -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.  */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 00a0390..c580793 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8558,6 +8558,11 @@ 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;
+      }
 #else
       goto unimplemented_nowarn;
 #endif
@@ -8566,6 +8571,11 @@ 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;
+            ts->tp_value = arg1;
+        }
 #else
         goto unimplemented_nowarn;
 #endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC Peter Maydell
@ 2013-07-13  7:40   ` Jia Liu
  2013-07-13  8:04     ` Peter Maydell
  0 siblings, 1 reply; 15+ messages in thread
From: Jia Liu @ 2013-07-13  7:40 UTC (permalink / raw)
  To: Peter Maydell
  Cc: patches, Riku Voipio, Alexander Graf, qemu-devel, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

Hi Peter,

On Sat, Jul 13, 2013 at 4:12 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> The 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.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  configure                        |    1 -
>  linux-user/openrisc/target_cpu.h |    9 +++++++--
>  2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 4a241e0..3848c1c 100755
> --- a/configure
> +++ b/configure
> @@ -4229,7 +4229,6 @@ case "$target_name" in
>    or32)
>      TARGET_ARCH=openrisc
>      TARGET_BASE_ARCH=openrisc
> -    target_nptl="no"
>    ;;

I noticed configure have no this line.

>    ppc)
>      gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
> diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h
> index 501fb81..32a46ac 100644
> --- a/linux-user/openrisc/target_cpu.h
> +++ b/linux-user/openrisc/target_cpu.h
> @@ -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.
> +     */
> +}

Thanks for fix. It looks good to me.

I need to reply here a Reviewed-by: Jia Liu <proljc@gmail.com> , yes?

>
>  #endif
> --
> 1.7.9.5
>

Regards,
Jia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC
  2013-07-13  7:40   ` Jia Liu
@ 2013-07-13  8:04     ` Peter Maydell
  0 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-13  8:04 UTC (permalink / raw)
  To: Jia Liu
  Cc: patches, Riku Voipio, Alexander Graf, qemu-devel, Blue Swirl,
	Paul Brook, Guan Xuetao, Aurelien Jarno

On 13 July 2013 08:40, Jia Liu <proljc@gmail.com> wrote:
> Hi Peter,
>
> On Sat, Jul 13, 2013 at 4:12 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> The 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.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  configure                        |    1 -
>>  linux-user/openrisc/target_cpu.h |    9 +++++++--
>>  2 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 4a241e0..3848c1c 100755
>> --- a/configure
>> +++ b/configure
>> @@ -4229,7 +4229,6 @@ case "$target_name" in
>>    or32)
>>      TARGET_ARCH=openrisc
>>      TARGET_BASE_ARCH=openrisc
>> -    target_nptl="no"
>>    ;;
>
> I noticed configure have no this line.

An earlier patch in the series rearranges this bit of
configure so targets have to say "no" (and the default
is "yes"), rather than the default being "no" and targets
having to say "yes".

>>    ppc)
>>      gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
>> diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h
>> index 501fb81..32a46ac 100644
>> --- a/linux-user/openrisc/target_cpu.h
>> +++ b/linux-user/openrisc/target_cpu.h
>> @@ -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.
>> +     */
>> +}
>
> Thanks for fix. It looks good to me.
>
> I need to reply here a Reviewed-by: Jia Liu <proljc@gmail.com> , yes?

Yes.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k Peter Maydell
@ 2013-07-13 10:28   ` Laurent Vivier
  2013-07-13 11:35     ` Peter Maydell
  0 siblings, 1 reply; 15+ messages in thread
From: Laurent Vivier @ 2013-07-13 10:28 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, qemu-devel,
	Blue Swirl, Paul Brook, Guan Xuetao, Aurelien Jarno

Le 12/07/2013 22:12, Peter Maydell a écrit :
> 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 <peter.maydell@linaro.org>

tp_value is never read : is it really used ?

> ---
>   configure                    |    1 -
>   linux-user/m68k/target_cpu.h |    6 +++++-
>   linux-user/qemu.h            |    1 +
>   linux-user/syscall.c         |   10 ++++++++++
>   4 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index 117191e..67e6437 100755
> --- a/configure
> +++ b/configure
> @@ -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
> diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h
> index 8a2a305..cad9c90 100644
> --- a/linux-user/m68k/target_cpu.h
> +++ b/linux-user/m68k/target_cpu.h
> @@ -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
> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
> index 8c420da..1ff0fa8 100644
> --- a/linux-user/qemu.h
> +++ b/linux-user/qemu.h
> @@ -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.  */
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 00a0390..c580793 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -8558,6 +8558,11 @@ 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;
> +      }
Seems a "break" is missing here ?
>   #else
>         goto unimplemented_nowarn;
>   #endif
> @@ -8566,6 +8571,11 @@ 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;
> +            ts->tp_value = arg1;
perhaps "ret = ts->tp_value;" ?
> +        }
>   #else
>           goto unimplemented_nowarn;
>   #endif

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k
  2013-07-13 10:28   ` Laurent Vivier
@ 2013-07-13 11:35     ` Peter Maydell
  0 siblings, 0 replies; 15+ messages in thread
From: Peter Maydell @ 2013-07-13 11:35 UTC (permalink / raw)
  To: Laurent Vivier
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, qemu-devel,
	Blue Swirl, Paul Brook, Guan Xuetao, Aurelien Jarno

On 13 July 2013 11:28, Laurent Vivier <Laurent@vivier.eu> wrote:
> Le 12/07/2013 22:12, Peter Maydell a écrit :
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -8558,6 +8558,11 @@ 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;
>> +      }
>
> Seems a "break" is missing here ?

Yes.

>>   #else
>>         goto unimplemented_nowarn;
>>   #endif
>> @@ -8566,6 +8571,11 @@ 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;
>> +            ts->tp_value = arg1;
>
> perhaps "ret = ts->tp_value;" ?

Yes, silly cut-n-paste mistake. As I say I couldn't
test m68k.

Also I notice that both this and the existing i386
case are missing the 'break' and will fall through
to the next syscall.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h Peter Maydell
@ 2013-07-13 21:01   ` Richard Henderson
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2013-07-13 21:01 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, qemu-devel,
	Blue Swirl, Paul Brook, Guan Xuetao, Aurelien Jarno

On 07/12/2013 01:12 PM, Peter Maydell wrote:
> The 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH 7/8] linux-user: Enable NPTL for SPARC targets
  2013-07-12 20:12 ` [Qemu-devel] [PATCH 7/8] linux-user: Enable NPTL for SPARC targets Peter Maydell
@ 2013-07-13 21:01   ` Richard Henderson
  0 siblings, 0 replies; 15+ messages in thread
From: Richard Henderson @ 2013-07-13 21:01 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Jia Liu, patches, Riku Voipio, Alexander Graf, qemu-devel,
	Blue Swirl, Paul Brook, Guan Xuetao, Aurelien Jarno

On 07/12/2013 01:12 PM, Peter Maydell wrote:
> Provide 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.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-07-13 21:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-12 20:12 [Qemu-devel] [PATCH 0/8] linux-user: enable NPTL on everything but x86 Peter Maydell
2013-07-12 20:12 ` [Qemu-devel] [PATCH 1/8] configure: Flip default of target_nptl Peter Maydell
2013-07-12 20:12 ` [Qemu-devel] [PATCH 2/8] configure: Don't say target_nptl="no" if there is no linux-user target Peter Maydell
2013-07-12 20:12 ` [Qemu-devel] [PATCH 3/8] configure: Enable threading on all ppc and mips linux-user targets Peter Maydell
2013-07-12 20:12 ` [Qemu-devel] [PATCH 4/8] configure: Enable threading for unicore32-linux-user Peter Maydell
2013-07-12 20:12 ` [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h Peter Maydell
2013-07-13 21:01   ` Richard Henderson
2013-07-12 20:12 ` [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC Peter Maydell
2013-07-13  7:40   ` Jia Liu
2013-07-13  8:04     ` Peter Maydell
2013-07-12 20:12 ` [Qemu-devel] [PATCH 7/8] linux-user: Enable NPTL for SPARC targets Peter Maydell
2013-07-13 21:01   ` Richard Henderson
2013-07-12 20:12 ` [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k Peter Maydell
2013-07-13 10:28   ` Laurent Vivier
2013-07-13 11:35     ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.