diff options
Diffstat (limited to 'arch/um/os-Linux/sys-i386')
-rw-r--r-- | arch/um/os-Linux/sys-i386/Makefile | 10 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-i386/registers.c | 91 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-i386/signal.c | 13 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-i386/task_size.c | 139 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-i386/tls.c | 36 |
5 files changed, 0 insertions, 289 deletions
diff --git a/arch/um/os-Linux/sys-i386/Makefile b/arch/um/os-Linux/sys-i386/Makefile deleted file mode 100644 index b4bc6ac4f30b..000000000000 --- a/arch/um/os-Linux/sys-i386/Makefile +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | # | ||
2 | # Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | # Licensed under the GPL | ||
4 | # | ||
5 | |||
6 | obj-y = registers.o signal.o task_size.o tls.o | ||
7 | |||
8 | USER_OBJS := $(obj-y) | ||
9 | |||
10 | include arch/um/scripts/Makefile.rules | ||
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c deleted file mode 100644 index 229f7a53d8da..000000000000 --- a/arch/um/os-Linux/sys-i386/registers.c +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 PathScale, Inc | ||
3 | * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <errno.h> | ||
8 | #include <sys/ptrace.h> | ||
9 | #include <sys/user.h> | ||
10 | #include "kern_constants.h" | ||
11 | #include "longjmp.h" | ||
12 | #include "user.h" | ||
13 | #include "sysdep/ptrace_user.h" | ||
14 | |||
15 | int save_fp_registers(int pid, unsigned long *fp_regs) | ||
16 | { | ||
17 | if (ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0) | ||
18 | return -errno; | ||
19 | return 0; | ||
20 | } | ||
21 | |||
22 | int restore_fp_registers(int pid, unsigned long *fp_regs) | ||
23 | { | ||
24 | if (ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0) | ||
25 | return -errno; | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | int save_fpx_registers(int pid, unsigned long *fp_regs) | ||
30 | { | ||
31 | if (ptrace(PTRACE_GETFPXREGS, pid, 0, fp_regs) < 0) | ||
32 | return -errno; | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | int restore_fpx_registers(int pid, unsigned long *fp_regs) | ||
37 | { | ||
38 | if (ptrace(PTRACE_SETFPXREGS, pid, 0, fp_regs) < 0) | ||
39 | return -errno; | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | unsigned long get_thread_reg(int reg, jmp_buf *buf) | ||
44 | { | ||
45 | switch (reg) { | ||
46 | case EIP: | ||
47 | return buf[0]->__eip; | ||
48 | case UESP: | ||
49 | return buf[0]->__esp; | ||
50 | case EBP: | ||
51 | return buf[0]->__ebp; | ||
52 | default: | ||
53 | printk(UM_KERN_ERR "get_thread_regs - unknown register %d\n", | ||
54 | reg); | ||
55 | return 0; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | int have_fpx_regs = 1; | ||
60 | |||
61 | int get_fp_registers(int pid, unsigned long *regs) | ||
62 | { | ||
63 | if (have_fpx_regs) | ||
64 | return save_fpx_registers(pid, regs); | ||
65 | else | ||
66 | return save_fp_registers(pid, regs); | ||
67 | } | ||
68 | |||
69 | int put_fp_registers(int pid, unsigned long *regs) | ||
70 | { | ||
71 | if (have_fpx_regs) | ||
72 | return restore_fpx_registers(pid, regs); | ||
73 | else | ||
74 | return restore_fp_registers(pid, regs); | ||
75 | } | ||
76 | |||
77 | void arch_init_registers(int pid) | ||
78 | { | ||
79 | struct user_fpxregs_struct fpx_regs; | ||
80 | int err; | ||
81 | |||
82 | err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs); | ||
83 | if (!err) | ||
84 | return; | ||
85 | |||
86 | if (errno != EIO) | ||
87 | panic("check_ptrace : PTRACE_GETFPXREGS failed, errno = %d", | ||
88 | errno); | ||
89 | |||
90 | have_fpx_regs = 0; | ||
91 | } | ||
diff --git a/arch/um/os-Linux/sys-i386/signal.c b/arch/um/os-Linux/sys-i386/signal.c deleted file mode 100644 index f311609f93da..000000000000 --- a/arch/um/os-Linux/sys-i386/signal.c +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <signal.h> | ||
7 | |||
8 | extern void handle_signal(int sig, struct sigcontext *sc); | ||
9 | |||
10 | void hard_handler(int sig) | ||
11 | { | ||
12 | handle_signal(sig, (struct sigcontext *) (&sig + 1)); | ||
13 | } | ||
diff --git a/arch/um/os-Linux/sys-i386/task_size.c b/arch/um/os-Linux/sys-i386/task_size.c deleted file mode 100644 index be04c1e183bf..000000000000 --- a/arch/um/os-Linux/sys-i386/task_size.c +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <signal.h> | ||
4 | #include <sys/mman.h> | ||
5 | #include "longjmp.h" | ||
6 | #include "kern_constants.h" | ||
7 | |||
8 | static jmp_buf buf; | ||
9 | |||
10 | static void segfault(int sig) | ||
11 | { | ||
12 | longjmp(buf, 1); | ||
13 | } | ||
14 | |||
15 | static int page_ok(unsigned long page) | ||
16 | { | ||
17 | unsigned long *address = (unsigned long *) (page << UM_KERN_PAGE_SHIFT); | ||
18 | unsigned long n = ~0UL; | ||
19 | void *mapped = NULL; | ||
20 | int ok = 0; | ||
21 | |||
22 | /* | ||
23 | * First see if the page is readable. If it is, it may still | ||
24 | * be a VDSO, so we go on to see if it's writable. If not | ||
25 | * then try mapping memory there. If that fails, then we're | ||
26 | * still in the kernel area. As a sanity check, we'll fail if | ||
27 | * the mmap succeeds, but gives us an address different from | ||
28 | * what we wanted. | ||
29 | */ | ||
30 | if (setjmp(buf) == 0) | ||
31 | n = *address; | ||
32 | else { | ||
33 | mapped = mmap(address, UM_KERN_PAGE_SIZE, | ||
34 | PROT_READ | PROT_WRITE, | ||
35 | MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | ||
36 | if (mapped == MAP_FAILED) | ||
37 | return 0; | ||
38 | if (mapped != address) | ||
39 | goto out; | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * Now, is it writeable? If so, then we're in user address | ||
44 | * space. If not, then try mprotecting it and try the write | ||
45 | * again. | ||
46 | */ | ||
47 | if (setjmp(buf) == 0) { | ||
48 | *address = n; | ||
49 | ok = 1; | ||
50 | goto out; | ||
51 | } else if (mprotect(address, UM_KERN_PAGE_SIZE, | ||
52 | PROT_READ | PROT_WRITE) != 0) | ||
53 | goto out; | ||
54 | |||
55 | if (setjmp(buf) == 0) { | ||
56 | *address = n; | ||
57 | ok = 1; | ||
58 | } | ||
59 | |||
60 | out: | ||
61 | if (mapped != NULL) | ||
62 | munmap(mapped, UM_KERN_PAGE_SIZE); | ||
63 | return ok; | ||
64 | } | ||
65 | |||
66 | unsigned long os_get_top_address(void) | ||
67 | { | ||
68 | struct sigaction sa, old; | ||
69 | unsigned long bottom = 0; | ||
70 | /* | ||
71 | * A 32-bit UML on a 64-bit host gets confused about the VDSO at | ||
72 | * 0xffffe000. It is mapped, is readable, can be reprotected writeable | ||
73 | * and written. However, exec discovers later that it can't be | ||
74 | * unmapped. So, just set the highest address to be checked to just | ||
75 | * below it. This might waste some address space on 4G/4G 32-bit | ||
76 | * hosts, but shouldn't hurt otherwise. | ||
77 | */ | ||
78 | unsigned long top = 0xffffd000 >> UM_KERN_PAGE_SHIFT; | ||
79 | unsigned long test, original; | ||
80 | |||
81 | printf("Locating the bottom of the address space ... "); | ||
82 | fflush(stdout); | ||
83 | |||
84 | /* | ||
85 | * We're going to be longjmping out of the signal handler, so | ||
86 | * SA_DEFER needs to be set. | ||
87 | */ | ||
88 | sa.sa_handler = segfault; | ||
89 | sigemptyset(&sa.sa_mask); | ||
90 | sa.sa_flags = SA_NODEFER; | ||
91 | if (sigaction(SIGSEGV, &sa, &old)) { | ||
92 | perror("os_get_top_address"); | ||
93 | exit(1); | ||
94 | } | ||
95 | |||
96 | /* Manually scan the address space, bottom-up, until we find | ||
97 | * the first valid page (or run out of them). | ||
98 | */ | ||
99 | for (bottom = 0; bottom < top; bottom++) { | ||
100 | if (page_ok(bottom)) | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | /* If we've got this far, we ran out of pages. */ | ||
105 | if (bottom == top) { | ||
106 | fprintf(stderr, "Unable to determine bottom of address " | ||
107 | "space.\n"); | ||
108 | exit(1); | ||
109 | } | ||
110 | |||
111 | printf("0x%x\n", bottom << UM_KERN_PAGE_SHIFT); | ||
112 | printf("Locating the top of the address space ... "); | ||
113 | fflush(stdout); | ||
114 | |||
115 | original = bottom; | ||
116 | |||
117 | /* This could happen with a 4G/4G split */ | ||
118 | if (page_ok(top)) | ||
119 | goto out; | ||
120 | |||
121 | do { | ||
122 | test = bottom + (top - bottom) / 2; | ||
123 | if (page_ok(test)) | ||
124 | bottom = test; | ||
125 | else | ||
126 | top = test; | ||
127 | } while (top - bottom > 1); | ||
128 | |||
129 | out: | ||
130 | /* Restore the old SIGSEGV handling */ | ||
131 | if (sigaction(SIGSEGV, &old, NULL)) { | ||
132 | perror("os_get_top_address"); | ||
133 | exit(1); | ||
134 | } | ||
135 | top <<= UM_KERN_PAGE_SHIFT; | ||
136 | printf("0x%x\n", top); | ||
137 | |||
138 | return top; | ||
139 | } | ||
diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c deleted file mode 100644 index 32ed41ec1a3d..000000000000 --- a/arch/um/os-Linux/sys-i386/tls.c +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | #include <errno.h> | ||
2 | #include <linux/unistd.h> | ||
3 | |||
4 | #include <sys/syscall.h> | ||
5 | #include <unistd.h> | ||
6 | |||
7 | #include "sysdep/tls.h" | ||
8 | #include "user.h" | ||
9 | |||
10 | /* Checks whether host supports TLS, and sets *tls_min according to the value | ||
11 | * valid on the host. | ||
12 | * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */ | ||
13 | void check_host_supports_tls(int *supports_tls, int *tls_min) { | ||
14 | /* Values for x86 and x86_64.*/ | ||
15 | int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64}; | ||
16 | int i; | ||
17 | |||
18 | for (i = 0; i < ARRAY_SIZE(val); i++) { | ||
19 | user_desc_t info; | ||
20 | info.entry_number = val[i]; | ||
21 | |||
22 | if (syscall(__NR_get_thread_area, &info) == 0) { | ||
23 | *tls_min = val[i]; | ||
24 | *supports_tls = 1; | ||
25 | return; | ||
26 | } else { | ||
27 | if (errno == EINVAL) | ||
28 | continue; | ||
29 | else if (errno == ENOSYS) | ||
30 | *supports_tls = 0; | ||
31 | return; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | *supports_tls = 0; | ||
36 | } | ||