aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/include/shared/os.h5
-rw-r--r--arch/um/os-Linux/Makefile4
-rw-r--r--arch/um/os-Linux/tls.c35
-rw-r--r--arch/x86/um/os-Linux/tls.c34
-rw-r--r--arch/x86/um/shared/sysdep/tls.h3
5 files changed, 38 insertions, 43 deletions
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index caa66619a9b4..89b686c1a3ea 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
@@ -10,7 +10,6 @@
10#include "irq_user.h" 10#include "irq_user.h"
11#include "longjmp.h" 11#include "longjmp.h"
12#include "mm_id.h" 12#include "mm_id.h"
13#include "sysdep/tls.h"
14 13
15#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR)) 14#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))
16 15
@@ -212,10 +211,6 @@ extern int run_helper_thread(int (*proc)(void *), void *arg,
212extern int helper_wait(int pid); 211extern int helper_wait(int pid);
213 212
214 213
215/* tls.c */
216extern int os_set_thread_area(user_desc_t *info, int pid);
217extern int os_get_thread_area(user_desc_t *info, int pid);
218
219/* umid.c */ 214/* umid.c */
220extern int umid_file_name(char *name, char *buf, int len); 215extern int umid_file_name(char *name, char *buf, int len);
221extern int set_umid(char *name); 216extern int set_umid(char *name);
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index 015d00057663..dd764101e488 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -5,13 +5,13 @@
5 5
6obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ 6obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
7 registers.o sigio.o signal.o start_up.o time.o tty.o \ 7 registers.o sigio.o signal.o start_up.o time.o tty.o \
8 umid.o tls.o user_syms.o util.o drivers/ skas/ 8 umid.o user_syms.o util.o drivers/ skas/
9 9
10obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o 10obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o
11 11
12USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ 12USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
13 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ 13 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \
14 tty.o tls.o umid.o util.o 14 tty.o umid.o util.o
15 15
16CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) 16CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
17 17
diff --git a/arch/um/os-Linux/tls.c b/arch/um/os-Linux/tls.c
deleted file mode 100644
index 73277801ef14..000000000000
--- a/arch/um/os-Linux/tls.c
+++ /dev/null
@@ -1,35 +0,0 @@
1#include <errno.h>
2#include <sys/ptrace.h>
3#include "sysdep/tls.h"
4
5/* TLS support - we basically rely on the host's one.*/
6
7#ifndef PTRACE_GET_THREAD_AREA
8#define PTRACE_GET_THREAD_AREA 25
9#endif
10
11#ifndef PTRACE_SET_THREAD_AREA
12#define PTRACE_SET_THREAD_AREA 26
13#endif
14
15int os_set_thread_area(user_desc_t *info, int pid)
16{
17 int ret;
18
19 ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
20 (unsigned long) info);
21 if (ret < 0)
22 ret = -errno;
23 return ret;
24}
25
26int os_get_thread_area(user_desc_t *info, int pid)
27{
28 int ret;
29
30 ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
31 (unsigned long) info);
32 if (ret < 0)
33 ret = -errno;
34 return ret;
35}
diff --git a/arch/x86/um/os-Linux/tls.c b/arch/x86/um/os-Linux/tls.c
index 281e83ecce3d..82276b6071af 100644
--- a/arch/x86/um/os-Linux/tls.c
+++ b/arch/x86/um/os-Linux/tls.c
@@ -1,15 +1,25 @@
1#include <errno.h> 1#include <errno.h>
2#include <linux/unistd.h> 2#include <linux/unistd.h>
3 3
4#include <sys/ptrace.h>
4#include <sys/syscall.h> 5#include <sys/syscall.h>
5#include <unistd.h> 6#include <unistd.h>
6 7
7#include "sysdep/tls.h" 8#include "sysdep/tls.h"
8 9
10#ifndef PTRACE_GET_THREAD_AREA
11#define PTRACE_GET_THREAD_AREA 25
12#endif
13
14#ifndef PTRACE_SET_THREAD_AREA
15#define PTRACE_SET_THREAD_AREA 26
16#endif
17
9/* Checks whether host supports TLS, and sets *tls_min according to the value 18/* Checks whether host supports TLS, and sets *tls_min according to the value
10 * valid on the host. 19 * valid on the host.
11 * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */ 20 * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
12void check_host_supports_tls(int *supports_tls, int *tls_min) { 21void check_host_supports_tls(int *supports_tls, int *tls_min)
22{
13 /* Values for x86 and x86_64.*/ 23 /* Values for x86 and x86_64.*/
14 int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64}; 24 int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64};
15 int i; 25 int i;
@@ -33,3 +43,25 @@ void check_host_supports_tls(int *supports_tls, int *tls_min) {
33 43
34 *supports_tls = 0; 44 *supports_tls = 0;
35} 45}
46
47int os_set_thread_area(user_desc_t *info, int pid)
48{
49 int ret;
50
51 ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
52 (unsigned long) info);
53 if (ret < 0)
54 ret = -errno;
55 return ret;
56}
57
58int os_get_thread_area(user_desc_t *info, int pid)
59{
60 int ret;
61
62 ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
63 (unsigned long) info);
64 if (ret < 0)
65 ret = -errno;
66 return ret;
67}
diff --git a/arch/x86/um/shared/sysdep/tls.h b/arch/x86/um/shared/sysdep/tls.h
index db2ae9c12e23..f2f30bd67b9b 100644
--- a/arch/x86/um/shared/sysdep/tls.h
+++ b/arch/x86/um/shared/sysdep/tls.h
@@ -29,6 +29,9 @@ typedef struct user_desc user_desc_t;
29 29
30# endif /* __KERNEL__ */ 30# endif /* __KERNEL__ */
31 31
32extern int os_set_thread_area(user_desc_t *info, int pid);
33extern int os_get_thread_area(user_desc_t *info, int pid);
34
32#ifdef __i386__ 35#ifdef __i386__
33#define GDT_ENTRY_TLS_MIN_I386 6 36#define GDT_ENTRY_TLS_MIN_I386 6
34#define GDT_ENTRY_TLS_MIN_X86_64 12 37#define GDT_ENTRY_TLS_MIN_X86_64 12