diff mbox

[8/8] linux-user: Enable NPTL for m68k

Message ID 1373659973-23289-9-git-send-email-peter.maydell@linaro.org
State New
Headers show

Commit Message

Peter Maydell July 12, 2013, 8:12 p.m. UTC
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(-)

Comments

Laurent Vivier July 13, 2013, 10:28 a.m. UTC | #1
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
Peter Maydell July 13, 2013, 11:35 a.m. UTC | #2
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
diff mbox

Patch

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