aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:26:50 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:05 -0400
commit42fda66387daa53538ae13a2c858396aaf037158 (patch)
tree77955a91a958fde7be47cb0ff23ac9e1248217db /arch/um/sys-i386
parenta1ff5878d2628bbe1e42821c024c96f48318f683 (diff)
uml: throw out CONFIG_MODE_TT
This patchset throws out tt mode, which has been non-functional for a while. This is done in phases, interspersed with code cleanups on the affected files. The removal is done as follows: remove all code, config options, and files which depend on CONFIG_MODE_TT get rid of the CHOOSE_MODE macro, which decided whether to call tt-mode or skas-mode code, and replace invocations with their skas portions replace all now-trivial procedures with their skas equivalents There are now a bunch of now-redundant pieces of data structures, including mode-specific pieces of the thread structure, pt_regs, and mm_context. These are all replaced with their skas-specific contents. As part of the ongoing style compliance project, I made a style pass over all files that were changed. There are three such patches, one for each phase, covering the files affected by that phase but no later ones. I noticed that we weren't freeing the LDT state associated with a process when it exited, so that's fixed in one of the later patches. The last patch is a tidying patch which I've had for a while, but which caused inexplicable crashes under tt mode. Since that is no longer a problem, this can now go in. This patch: Start getting rid of tt mode support. This patch throws out CONFIG_MODE_TT and all config options, code, and files which depend on it. CONFIG_MODE_SKAS is gone and everything that depends on it is included unconditionally. The few changed lines are in re-written Kconfig help, lines which needed something skas-related removed from them, and a few more which weren't strictly deletions. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/sys-i386')
-rw-r--r--arch/um/sys-i386/Makefile10
-rw-r--r--arch/um/sys-i386/ldt.c67
-rw-r--r--arch/um/sys-i386/ptrace.c120
-rw-r--r--arch/um/sys-i386/ptrace_user.c86
-rw-r--r--arch/um/sys-i386/signal.c58
-rw-r--r--arch/um/sys-i386/tls.c16
-rw-r--r--arch/um/sys-i386/unmap.c25
7 files changed, 2 insertions, 380 deletions
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index a4618b6b85b9..94b6ede5ef6c 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -1,8 +1,6 @@
1obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \ 1obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
2 ptrace_user.o setjmp.o signal.o sigcontext.o syscalls.o sysrq.o \ 2 ptrace_user.o setjmp.o signal.o sigcontext.o stub.o stub_segv.o \
3 sys_call_table.o tls.o 3 syscalls.o sysrq.o sys_call_table.o tls.o
4
5obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
6 4
7subarch-obj-y = lib/bitops_32.o lib/semaphore_32.o lib/string_32.o 5subarch-obj-y = lib/bitops_32.o lib/semaphore_32.o lib/string_32.o
8subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem_32.o 6subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem_32.o
@@ -13,11 +11,7 @@ USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
13USER_OBJS += user-offsets.s 11USER_OBJS += user-offsets.s
14extra-y += user-offsets.s 12extra-y += user-offsets.s
15 13
16extra-$(CONFIG_MODE_TT) += unmap.o
17
18UNPROFILE_OBJS := stub_segv.o 14UNPROFILE_OBJS := stub_segv.o
19CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING) 15CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
20 16
21include arch/um/scripts/Makefile.rules 17include arch/um/scripts/Makefile.rules
22
23$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index a939a7ef0227..762a12aec757 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -19,72 +19,6 @@
19 19
20extern int modify_ldt(int func, void *ptr, unsigned long bytecount); 20extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
21 21
22#ifdef CONFIG_MODE_TT
23
24static long do_modify_ldt_tt(int func, void __user *ptr,
25 unsigned long bytecount)
26{
27 struct user_desc info;
28 int res = 0;
29 void *buf = NULL;
30 void *p = NULL; /* What we pass to host. */
31
32 switch(func){
33 case 1:
34 case 0x11: /* write_ldt */
35 /* Do this check now to avoid overflows. */
36 if (bytecount != sizeof(struct user_desc)) {
37 res = -EINVAL;
38 goto out;
39 }
40
41 if(copy_from_user(&info, ptr, sizeof(info))) {
42 res = -EFAULT;
43 goto out;
44 }
45
46 p = &info;
47 break;
48 case 0:
49 case 2: /* read_ldt */
50
51 /* The use of info avoids kmalloc on the write case, not on the
52 * read one. */
53 buf = kmalloc(bytecount, GFP_KERNEL);
54 if (!buf) {
55 res = -ENOMEM;
56 goto out;
57 }
58 p = buf;
59 break;
60 default:
61 res = -ENOSYS;
62 goto out;
63 }
64
65 res = modify_ldt(func, p, bytecount);
66 if(res < 0)
67 goto out;
68
69 switch(func){
70 case 0:
71 case 2:
72 /* Modify_ldt was for reading and returned the number of read
73 * bytes.*/
74 if(copy_to_user(ptr, p, res))
75 res = -EFAULT;
76 break;
77 }
78
79out:
80 kfree(buf);
81 return res;
82}
83
84#endif
85
86#ifdef CONFIG_MODE_SKAS
87
88#include "skas.h" 22#include "skas.h"
89#include "skas_ptrace.h" 23#include "skas_ptrace.h"
90#include "asm/mmu_context.h" 24#include "asm/mmu_context.h"
@@ -569,7 +503,6 @@ void free_ldt(struct mmu_context_skas * mm)
569 } 503 }
570 mm->ldt.entry_count = 0; 504 mm->ldt.entry_count = 0;
571} 505}
572#endif
573 506
574int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) 507int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
575{ 508{
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index 28bf01150323..572fd504b94b 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -14,12 +14,6 @@
14#include "sysdep/sigcontext.h" 14#include "sysdep/sigcontext.h"
15#include "sysdep/sc.h" 15#include "sysdep/sc.h"
16 16
17void arch_switch_to_tt(struct task_struct *from, struct task_struct *to)
18{
19 update_debugregs(to->thread.arch.debugregs_seq);
20 arch_switch_tls_tt(from, to);
21}
22
23void arch_switch_to_skas(struct task_struct *from, struct task_struct *to) 17void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
24{ 18{
25 int err = arch_switch_tls_skas(from, to); 19 int err = arch_switch_tls_skas(from, to);
@@ -233,79 +227,12 @@ static inline unsigned long twd_fxsr_to_i387( struct i387_fxsave_struct *fxsave
233 return ret; 227 return ret;
234} 228}
235 229
236/*
237 * FXSR floating point environment conversions.
238 */
239
240#ifdef CONFIG_MODE_TT
241static inline int convert_fxsr_to_user_tt(struct _fpstate __user *buf,
242 struct pt_regs *regs)
243{
244 struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
245 unsigned long env[7];
246 struct _fpreg __user *to;
247 struct _fpxreg *from;
248 int i;
249
250 env[0] = (unsigned long)fxsave->cwd | 0xffff0000;
251 env[1] = (unsigned long)fxsave->swd | 0xffff0000;
252 env[2] = twd_fxsr_to_i387(fxsave);
253 env[3] = fxsave->fip;
254 env[4] = fxsave->fcs | ((unsigned long)fxsave->fop << 16);
255 env[5] = fxsave->foo;
256 env[6] = fxsave->fos;
257
258 if ( __copy_to_user( buf, env, 7 * sizeof(unsigned long) ) )
259 return 1;
260
261 to = &buf->_st[0];
262 from = (struct _fpxreg *) &fxsave->st_space[0];
263 for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
264 if ( __copy_to_user( to, from, sizeof(*to) ) )
265 return 1;
266 }
267 return 0;
268}
269#endif
270
271static inline int convert_fxsr_to_user(struct _fpstate __user *buf, 230static inline int convert_fxsr_to_user(struct _fpstate __user *buf,
272 struct pt_regs *regs) 231 struct pt_regs *regs)
273{ 232{
274 return(CHOOSE_MODE(convert_fxsr_to_user_tt(buf, regs), 0)); 233 return(CHOOSE_MODE(convert_fxsr_to_user_tt(buf, regs), 0));
275} 234}
276 235
277#ifdef CONFIG_MODE_TT
278static inline int convert_fxsr_from_user_tt(struct pt_regs *regs,
279 struct _fpstate __user *buf)
280{
281 struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
282 unsigned long env[7];
283 struct _fpxreg *to;
284 struct _fpreg __user *from;
285 int i;
286
287 if ( __copy_from_user( env, buf, 7 * sizeof(long) ) )
288 return 1;
289
290 fxsave->cwd = (unsigned short)(env[0] & 0xffff);
291 fxsave->swd = (unsigned short)(env[1] & 0xffff);
292 fxsave->twd = twd_i387_to_fxsr((unsigned short)(env[2] & 0xffff));
293 fxsave->fip = env[3];
294 fxsave->fop = (unsigned short)((env[4] & 0xffff0000) >> 16);
295 fxsave->fcs = (env[4] & 0xffff);
296 fxsave->foo = env[5];
297 fxsave->fos = env[6];
298
299 to = (struct _fpxreg *) &fxsave->st_space[0];
300 from = &buf->_st[0];
301 for ( i = 0 ; i < 8 ; i++, to++, from++ ) {
302 if ( __copy_from_user( to, from, sizeof(*from) ) )
303 return 1;
304 }
305 return 0;
306}
307#endif
308
309static inline int convert_fxsr_from_user(struct pt_regs *regs, 236static inline int convert_fxsr_from_user(struct pt_regs *regs,
310 struct _fpstate __user *buf) 237 struct _fpstate __user *buf)
311{ 238{
@@ -332,39 +259,11 @@ int set_fpregs(unsigned long buf, struct task_struct *child)
332 else return(0); 259 else return(0);
333} 260}
334 261
335#ifdef CONFIG_MODE_TT
336int get_fpxregs_tt(unsigned long buf, struct task_struct *tsk)
337{
338 struct pt_regs *regs = &tsk->thread.regs;
339 struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
340 int err;
341
342 err = __copy_to_user((void __user *) buf, fxsave,
343 sizeof(struct user_fxsr_struct));
344 if(err) return -EFAULT;
345 else return 0;
346}
347#endif
348
349int get_fpxregs(unsigned long buf, struct task_struct *tsk) 262int get_fpxregs(unsigned long buf, struct task_struct *tsk)
350{ 263{
351 return(CHOOSE_MODE(get_fpxregs_tt(buf, tsk), 0)); 264 return(CHOOSE_MODE(get_fpxregs_tt(buf, tsk), 0));
352} 265}
353 266
354#ifdef CONFIG_MODE_TT
355int set_fpxregs_tt(unsigned long buf, struct task_struct *tsk)
356{
357 struct pt_regs *regs = &tsk->thread.regs;
358 struct i387_fxsave_struct *fxsave = SC_FXSR_ENV(PT_REGS_SC(regs));
359 int err;
360
361 err = __copy_from_user(fxsave, (void __user *) buf,
362 sizeof(struct user_fxsr_struct) );
363 if(err) return -EFAULT;
364 else return 0;
365}
366#endif
367
368int set_fpxregs(unsigned long buf, struct task_struct *tsk) 267int set_fpxregs(unsigned long buf, struct task_struct *tsk)
369{ 268{
370 return(CHOOSE_MODE(set_fpxregs_tt(buf, tsk), 0)); 269 return(CHOOSE_MODE(set_fpxregs_tt(buf, tsk), 0));
@@ -387,25 +286,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
387} 286}
388#endif 287#endif
389 288
390#ifdef CONFIG_MODE_TT
391static inline void copy_fpu_fxsave_tt(struct pt_regs *regs,
392 struct user_i387_struct *buf)
393{
394 struct i387_fxsave_struct *fpu = SC_FXSR_ENV(PT_REGS_SC(regs));
395 unsigned short *to;
396 unsigned short *from;
397 int i;
398
399 memcpy( buf, fpu, 7 * sizeof(long) );
400
401 to = (unsigned short *) &buf->st_space[0];
402 from = (unsigned short *) &fpu->st_space[0];
403 for ( i = 0 ; i < 8 ; i++, to += 5, from += 8 ) {
404 memcpy( to, from, 5 * sizeof(unsigned short) );
405 }
406}
407#endif
408
409static inline void copy_fpu_fxsave(struct pt_regs *regs, 289static inline void copy_fpu_fxsave(struct pt_regs *regs,
410 struct user_i387_struct *buf) 290 struct user_i387_struct *buf)
411{ 291{
diff --git a/arch/um/sys-i386/ptrace_user.c b/arch/um/sys-i386/ptrace_user.c
index 40ff0c831bd0..b68dd230e646 100644
--- a/arch/um/sys-i386/ptrace_user.c
+++ b/arch/um/sys-i386/ptrace_user.c
@@ -43,89 +43,3 @@ int ptrace_setfpregs(long pid, unsigned long *regs)
43 return -errno; 43 return -errno;
44 return 0; 44 return 0;
45} 45}
46
47#ifdef UML_CONFIG_MODE_TT
48
49static void write_debugregs(int pid, unsigned long *regs)
50{
51 struct user *dummy;
52 int nregs, i;
53
54 dummy = NULL;
55 nregs = ARRAY_SIZE(dummy->u_debugreg);
56 for(i = 0; i < nregs; i++){
57 if((i == 4) || (i == 5)) continue;
58 if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
59 regs[i]) < 0)
60 printk("write_debugregs - ptrace failed on "
61 "register %d, value = 0x%lx, errno = %d\n", i,
62 regs[i], errno);
63 }
64}
65
66static void read_debugregs(int pid, unsigned long *regs)
67{
68 struct user *dummy;
69 int nregs, i;
70
71 dummy = NULL;
72 nregs = ARRAY_SIZE(dummy->u_debugreg);
73 for(i = 0; i < nregs; i++){
74 regs[i] = ptrace(PTRACE_PEEKUSR, pid,
75 &dummy->u_debugreg[i], 0);
76 }
77}
78
79/* Accessed only by the tracing thread */
80static unsigned long kernel_debugregs[8] = { [ 0 ... 7 ] = 0 };
81
82void arch_enter_kernel(void *task, int pid)
83{
84 read_debugregs(pid, TASK_DEBUGREGS(task));
85 write_debugregs(pid, kernel_debugregs);
86}
87
88void arch_leave_kernel(void *task, int pid)
89{
90 read_debugregs(pid, kernel_debugregs);
91 write_debugregs(pid, TASK_DEBUGREGS(task));
92}
93
94#ifdef UML_CONFIG_PT_PROXY
95/* Accessed only by the tracing thread */
96static int debugregs_seq;
97
98/* Only called by the ptrace proxy */
99void ptrace_pokeuser(unsigned long addr, unsigned long data)
100{
101 if((addr < offsetof(struct user, u_debugreg[0])) ||
102 (addr > offsetof(struct user, u_debugreg[7])))
103 return;
104 addr -= offsetof(struct user, u_debugreg[0]);
105 addr = addr >> 2;
106 if(kernel_debugregs[addr] == data) return;
107
108 kernel_debugregs[addr] = data;
109 debugregs_seq++;
110}
111
112static void update_debugregs_cb(void *arg)
113{
114 int pid = *((int *) arg);
115
116 write_debugregs(pid, kernel_debugregs);
117}
118
119/* Optimized out in its header when not defined */
120void update_debugregs(int seq)
121{
122 int me;
123
124 if(seq == debugregs_seq) return;
125
126 me = os_getpid();
127 initial_thread_cb(update_debugregs_cb, &me);
128}
129#endif
130
131#endif
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index 1cbf95f6858a..187ea27536bd 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -13,9 +13,6 @@
13#include "sigcontext.h" 13#include "sigcontext.h"
14#include "registers.h" 14#include "registers.h"
15#include "mode.h" 15#include "mode.h"
16
17#ifdef CONFIG_MODE_SKAS
18
19#include "skas.h" 16#include "skas.h"
20 17
21void copy_sc(union uml_pt_regs *regs, void *from) 18void copy_sc(union uml_pt_regs *regs, void *from)
@@ -108,61 +105,6 @@ int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *t
108 return copy_to_user(to, &sc, sizeof(sc)) || 105 return copy_to_user(to, &sc, sizeof(sc)) ||
109 copy_to_user(to_fp, fpregs, sizeof(fpregs)); 106 copy_to_user(to_fp, fpregs, sizeof(fpregs));
110} 107}
111#endif
112
113#ifdef CONFIG_MODE_TT
114
115/* These copy a sigcontext to/from userspace. They copy the fpstate pointer,
116 * blowing away the old, good one. So, that value is saved, and then restored
117 * after the sigcontext copy. In copy_from, the variable holding the saved
118 * fpstate pointer, and the sigcontext that it should be restored to are both
119 * in the kernel, so we can just restore using an assignment. In copy_to, the
120 * saved pointer is in the kernel, but the sigcontext is in userspace, so we
121 * copy_to_user it.
122 */
123int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext __user *from,
124 int fpsize)
125{
126 struct _fpstate *to_fp;
127 struct _fpstate __user *from_fp;
128 unsigned long sigs;
129 int err;
130
131 to_fp = to->fpstate;
132 sigs = to->oldmask;
133 err = copy_from_user(to, from, sizeof(*to));
134 from_fp = to->fpstate;
135 to->oldmask = sigs;
136 to->fpstate = to_fp;
137 if(to_fp != NULL)
138 err |= copy_from_user(to_fp, from_fp, fpsize);
139 return err;
140}
141
142int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp,
143 struct sigcontext *from, int fpsize, unsigned long sp)
144{
145 struct _fpstate __user *to_fp;
146 struct _fpstate *from_fp;
147 int err;
148
149 to_fp = (fp ? fp : (struct _fpstate __user *) (to + 1));
150 from_fp = from->fpstate;
151 err = copy_to_user(to, from, sizeof(*to));
152
153 /* The SP in the sigcontext is the updated one for the signal
154 * delivery. The sp passed in is the original, and this needs
155 * to be restored, so we stick it in separately.
156 */
157 err |= copy_to_user(&SC_SP(to), &sp, sizeof(sp));
158
159 if(from_fp != NULL){
160 err |= copy_to_user(&to->fpstate, &to_fp, sizeof(to->fpstate));
161 err |= copy_to_user(to_fp, from_fp, fpsize);
162 }
163 return err;
164}
165#endif
166 108
167static int copy_sc_from_user(struct pt_regs *to, void __user *from) 109static int copy_sc_from_user(struct pt_regs *to, void __user *from)
168{ 110{
diff --git a/arch/um/sys-i386/tls.c b/arch/um/sys-i386/tls.c
index fea8e5e15cc4..0340b96d101b 100644
--- a/arch/um/sys-i386/tls.c
+++ b/arch/um/sys-i386/tls.c
@@ -18,10 +18,7 @@
18#include "mode_kern.h" 18#include "mode_kern.h"
19#include "os.h" 19#include "os.h"
20#include "mode.h" 20#include "mode.h"
21
22#ifdef CONFIG_MODE_SKAS
23#include "skas.h" 21#include "skas.h"
24#endif
25 22
26/* 23/*
27 * If needed we can detect when it's uninitialized. 24 * If needed we can detect when it's uninitialized.
@@ -31,7 +28,6 @@
31static int host_supports_tls = -1; 28static int host_supports_tls = -1;
32int host_gdt_entry_tls_min; 29int host_gdt_entry_tls_min;
33 30
34#ifdef CONFIG_MODE_SKAS
35int do_set_thread_area_skas(struct user_desc *info) 31int do_set_thread_area_skas(struct user_desc *info)
36{ 32{
37 int ret; 33 int ret;
@@ -53,7 +49,6 @@ int do_get_thread_area_skas(struct user_desc *info)
53 put_cpu(); 49 put_cpu();
54 return ret; 50 return ret;
55} 51}
56#endif
57 52
58/* 53/*
59 * sys_get_thread_area: get a yet unused TLS descriptor index. 54 * sys_get_thread_area: get a yet unused TLS descriptor index.
@@ -187,17 +182,6 @@ int arch_switch_tls_skas(struct task_struct *from, struct task_struct *to)
187 return 0; 182 return 0;
188} 183}
189 184
190int arch_switch_tls_tt(struct task_struct *from, struct task_struct *to)
191{
192 if (!host_supports_tls)
193 return 0;
194
195 if (needs_TLS_update(to))
196 return load_TLS(0, to);
197
198 return 0;
199}
200
201static int set_tls_entry(struct task_struct* task, struct user_desc *info, 185static int set_tls_entry(struct task_struct* task, struct user_desc *info,
202 int idx, int flushed) 186 int idx, int flushed)
203{ 187{
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c
deleted file mode 100644
index 1b0ad0e4adcd..000000000000
--- a/arch/um/sys-i386/unmap.c
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <linux/mman.h>
7#include <asm/unistd.h>
8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
13int switcheroo(int fd, int prot, void *from, void *to, int size)
14{
15 if(munmap(to, size) < 0){
16 return(-1);
17 }
18 if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
19 return(-1);
20 }
21 if(munmap(from, size) < 0){
22 return(-1);
23 }
24 return(0);
25}