Skip to contentSkip to conversation

linux-user: enable NPTL on everything but x86

PATCH Superseded Peter Maydell 4 participants 15 messages Jul 12, 2013 – Jul 13, 2013

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover linux-user: enable NPTL on everything but x86

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(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/8 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
index cb0f870..ae9519c 100755
@@ -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
#2 lore raw

PATCH 2/8 configure: Don't say target_nptl="no" if there is no linux-user target

In reply to Peter Maydell

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

---
 configure |    3 ---
 1 file changed, 3 deletions(-)
configure +0 -3
index ae9519c..c159f34 100755
@@ -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
#3 lore raw

PATCH 3/8 configure: Enable threading on all ppc and mips linux-user targets

In reply to Peter Maydell

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.

---
 configure |    4 ----
 1 file changed, 4 deletions(-)
configure +0 -4
index c159f34..84bcbdc 100755
@@ -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
#4 lore raw

PATCH 4/8 configure: Enable threading for unicore32-linux-user

In reply to Peter Maydell

unicore32-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
index 84bcbdc..4a241e0 100755
@@ -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
#5 lore raw

PATCH 5/8 linux-user: Move includes of target-specific headers to end of qemu.h

In reply to Peter Maydell

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.

---
 linux-user/qemu.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
linux-user/qemu.h +7 -2
index 6569608..8c420da 100644
@@ -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
Reviewed-by on v1 5/8
#6 lore raw

Re: [Qemu-devel] [PATCH 5/8] linux-user: Move includes of target-specific headers to end of qemu.h

Quoted 6 lines · Peter Maydell

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.

r~

#7 lore raw

PATCH 6/8 linux-user: Enable NPTL for OpenRISC

In reply to Peter Maydell

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.

---
 configure                        |    1 -
 linux-user/openrisc/target_cpu.h |    9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
configure +0 -1
index 4a241e0..3848c1c 100755
@@ -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
index 501fb81..32a46ac 100644
@@ -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
#8 lore raw

Re: [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC

Hi Peter,

Quoted 17 lines · Peter Maydell

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.

---
 configure                        |    1 -
 linux-user/openrisc/target_cpu.h |    9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
configure +0 -0
index 4a241e0..3848c1c 100755

configure case "$target_name" in · line 4232

Quoted 5 lines
configure +0 -1
@@ -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.

Quoted 11 lines
configure +0 -0
   ppc)
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
linux-user/openrisc/target_cpu.h +0 -1
index 501fb81..32a46ac 100644
@@ -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;

linux-user/openrisc/target_cpu.h static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp) · line 36

Quoted 10 lines
linux-user/openrisc/target_cpu.h +7 -1
+    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 <[email protected]> , yes?

Quoted 5 lines
linux-user/openrisc/target_cpu.h +0 -1
 #endif
--

1.7.9.5

Regards,
Jia

#9 lore raw

Re: [Qemu-devel] [PATCH 6/8] linux-user: Enable NPTL for OpenRISC

Quoted 15 lines · Jia Liu

Hi Peter,

Quoted 12 lines · Peter Maydell

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.

---
 configure                        |    1 -
 linux-user/openrisc/target_cpu.h |    9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
Quoted 12 lines

configure case "$target_name" in · line 4232

Quoted 10 lines
configure +0 -1
index 4a241e0..3848c1c 100755
@@ -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".

Quoted 24 lines
Quoted 11 lines
configure +0 -0
   ppc)
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
linux-user/openrisc/target_cpu.h +0 -1
index 501fb81..32a46ac 100644
@@ -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;

linux-user/openrisc/target_cpu.h static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp) · line 36

Quoted 10 lines
linux-user/openrisc/target_cpu.h +7 -1
+    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.

Quoted 1 line

I need to reply here a Reviewed-by: Jia Liu <[email protected]> , yes?

Yes.

thanks
-- PMM

#10 lore raw

PATCH 7/8 linux-user: Enable NPTL for SPARC targets

In reply to Peter Maydell

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.

---
 configure                     |    3 ---
 linux-user/sparc/target_cpu.h |   16 ++++++++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)
configure +0 -3
index 3848c1c..117191e 100755
@@ -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
index 5a620a2..4944d46 100644
@@ -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
#12 lore raw

PATCH 8/8 linux-user: Enable NPTL for m68k

In reply to 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.

---
 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(-)
configure +0 -1
index 117191e..67e6437 100755
@@ -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
index 8a2a305..cad9c90 100644
@@ -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
index 8c420da..1ff0fa8 100644
@@ -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 +10 -0
index 00a0390..c580793 100644
@@ -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
Signature · 1 line
1.7.9.5
#13 lore raw

Re: [Qemu-devel] [PATCH 8/8] 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.

tp_value is never read : is it really used ?

Quoted 52 lines
---
  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(-)
configure +0 -1
index 117191e..67e6437 100755
@@ -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
index 8a2a305..cad9c90 100644
@@ -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
index 8c420da..1ff0fa8 100644
@@ -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 +0 -0
index 00a0390..c580793 100644

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8565

Quoted 8 lines
linux-user/syscall.c +5 -0
@@ -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 ?

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8577

Quoted 11 lines
linux-user/syscall.c +4 -0
  #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;" ?

Quoted 4 lines
linux-user/syscall.c +1 -0
+        }
  #else
          goto unimplemented_nowarn;
  #endif
#14 lore raw

Re: [Qemu-devel] [PATCH 8/8] linux-user: Enable NPTL for m68k

Quoted 15 lines · Laurent Vivier

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, · line 8566

Quoted 12 lines · Peter Maydell
linux-user/syscall.c +5 -0
@@ -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.

Quoted 6 lines
Quoted 6 lines
linux-user/syscall.c +0 -0
  #else
        goto unimplemented_nowarn;
  #endif
linux-user/syscall.c +0 -0
@@ -8566,6 +8571,11 @@ abi_long do_syscall(void *cpu_env, int num,
 abi_long arg1,
      case TARGET_NR_get_thread_area:
Quoted 8 lines

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 8577

Quoted 6 lines
linux-user/syscall.c +4 -0
  #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