diff mbox

[v3,11/13] linux-user: Add i386 TLS setter

Message ID 1373996700-29286-12-git-send-email-peter.maydell@linaro.org
State Accepted
Headers show

Commit Message

Peter Maydell July 16, 2013, 5:44 p.m. UTC
From: Alexander Graf <agraf@suse.de>

We can easily set the TLS on i386. Add code to do so.

Signed-off-by: Alexander Graf <agraf@suse.de>
[PMM: also remove "target_nptl=no" line from configure, for
 consistency with other patches in this series]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 configure                    |    1 -
 linux-user/i386/target_cpu.h |   12 ++++++++++--
 linux-user/syscall.c         |    2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

Comments

Richard Henderson July 16, 2013, 6:38 p.m. UTC | #1
On 07/16/2013 10:44 AM, Peter Maydell wrote:
> From: Alexander Graf <agraf@suse.de>
> 
> We can easily set the TLS on i386. Add code to do so.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> [PMM: also remove "target_nptl=no" line from configure, for
>  consistency with other patches in this series]
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  configure                    |    1 -
>  linux-user/i386/target_cpu.h |   12 ++++++++++--
>  linux-user/syscall.c         |    2 +-
>  3 files changed, 11 insertions(+), 4 deletions(-)

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


r~
diff mbox

Patch

diff --git a/configure b/configure
index 67e6437..8059b2b 100755
--- a/configure
+++ b/configure
@@ -4183,7 +4183,6 @@  TARGET_ABI_DIR=""
 
 case "$target_name" in
   i386)
-    target_nptl="no"
   ;;
   x86_64)
     TARGET_BASE_ARCH=i386
diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h
index abcac79..1170d84 100644
--- a/linux-user/i386/target_cpu.h
+++ b/linux-user/i386/target_cpu.h
@@ -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) */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b167d7f..452b89d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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;