Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#include <errno.h>
2#include <unistd.h>
3#include <sys/ptrace.h>
4#include <sys/syscall.h>
5#include <asm/ldt.h>
6#include "sysdep/tls.h"
7#include "uml-config.h"
8
9/* TLS support - we basically rely on the host's one.*/
10
11/* In TT mode, this should be called only by the tracing thread, and makes sense
12 * only for PTRACE_SET_THREAD_AREA. In SKAS mode, it's used normally.
13 *
14 */
15
16#ifndef PTRACE_GET_THREAD_AREA
17#define PTRACE_GET_THREAD_AREA 25
18#endif
19
20#ifndef PTRACE_SET_THREAD_AREA
21#define PTRACE_SET_THREAD_AREA 26
22#endif
23
24int os_set_thread_area(user_desc_t *info, int pid)
25{
26 int ret;
27
28 ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
29 (unsigned long) info);
30 if (ret < 0)
31 ret = -errno;
32 return ret;
33}
34
35#ifdef UML_CONFIG_MODE_SKAS
36
37int os_get_thread_area(user_desc_t *info, int pid)
38{
39 int ret;
40
41 ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
42 (unsigned long) info);
43 if (ret < 0)
44 ret = -errno;
45 return ret;
46}
47
48#endif
49
50#ifdef UML_CONFIG_MODE_TT
51#include "linux/unistd.h"
52
53int do_set_thread_area_tt(user_desc_t *info)
54{
55 int ret;
56
57 ret = syscall(__NR_set_thread_area,info);
58 if (ret < 0) {
59 ret = -errno;
60 }
61 return ret;
62}
63
64int do_get_thread_area_tt(user_desc_t *info)
65{
66 int ret;
67
68 ret = syscall(__NR_get_thread_area,info);
69 if (ret < 0) {
70 ret = -errno;
71 }
72 return ret;
73}
74
75#endif /* UML_CONFIG_MODE_TT */