Skip to content

Commit

Permalink
um: merge os-Linux/tls.c into arch/x86/um/os-Linux/tls.c
Browse files Browse the repository at this point in the history
it's i386-specific; moreover, analogs on other targets have
incompatible interface - PTRACE_GET_THREAD_AREA does exist
elsewhere, but struct user_desc does *not*

Signed-off-by: Al Viro <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
Al Viro authored and richardweinberger committed Nov 2, 2011
1 parent c5cc32f commit 1bbd5f2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 43 deletions.
5 changes: 0 additions & 5 deletions arch/um/include/shared/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "irq_user.h"
#include "longjmp.h"
#include "mm_id.h"
#include "sysdep/tls.h"

#define CATCH_EINTR(expr) while ((errno = 0, ((expr) < 0)) && (errno == EINTR))

Expand Down Expand Up @@ -212,10 +211,6 @@ extern int run_helper_thread(int (*proc)(void *), void *arg,
extern int helper_wait(int pid);


/* tls.c */
extern int os_set_thread_area(user_desc_t *info, int pid);
extern int os_get_thread_area(user_desc_t *info, int pid);

/* umid.c */
extern int umid_file_name(char *name, char *buf, int len);
extern int set_umid(char *name);
Expand Down
4 changes: 2 additions & 2 deletions arch/um/os-Linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
registers.o sigio.o signal.o start_up.o time.o tty.o \
umid.o tls.o user_syms.o util.o drivers/ skas/
umid.o user_syms.o util.o drivers/ skas/

obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o

USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \
tty.o tls.o umid.o util.o
tty.o umid.o util.o

CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)

Expand Down
35 changes: 0 additions & 35 deletions arch/um/os-Linux/tls.c

This file was deleted.

34 changes: 33 additions & 1 deletion arch/x86/um/os-Linux/tls.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#include <errno.h>
#include <linux/unistd.h>

#include <sys/ptrace.h>
#include <sys/syscall.h>
#include <unistd.h>

#include "sysdep/tls.h"

#ifndef PTRACE_GET_THREAD_AREA
#define PTRACE_GET_THREAD_AREA 25
#endif

#ifndef PTRACE_SET_THREAD_AREA
#define PTRACE_SET_THREAD_AREA 26
#endif

/* Checks whether host supports TLS, and sets *tls_min according to the value
* valid on the host.
* i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
void check_host_supports_tls(int *supports_tls, int *tls_min) {
void check_host_supports_tls(int *supports_tls, int *tls_min)
{
/* Values for x86 and x86_64.*/
int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64};
int i;
Expand All @@ -33,3 +43,25 @@ void check_host_supports_tls(int *supports_tls, int *tls_min) {

*supports_tls = 0;
}

int os_set_thread_area(user_desc_t *info, int pid)
{
int ret;

ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
(unsigned long) info);
if (ret < 0)
ret = -errno;
return ret;
}

int os_get_thread_area(user_desc_t *info, int pid)
{
int ret;

ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
(unsigned long) info);
if (ret < 0)
ret = -errno;
return ret;
}
3 changes: 3 additions & 0 deletions arch/x86/um/shared/sysdep/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ typedef struct user_desc user_desc_t;

# endif /* __KERNEL__ */

extern int os_set_thread_area(user_desc_t *info, int pid);
extern int os_get_thread_area(user_desc_t *info, int pid);

#ifdef __i386__
#define GDT_ENTRY_TLS_MIN_I386 6
#define GDT_ENTRY_TLS_MIN_X86_64 12
Expand Down

0 comments on commit 1bbd5f2

Please sign in to comment.