aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/kernel/acpi/boot.c2
-rw-r--r--arch/ppc/Kconfig2
-rw-r--r--arch/ppc64/Kconfig1
-rw-r--r--arch/um/include/user_util.h1
-rw-r--r--arch/um/kernel/Makefile6
-rw-r--r--arch/um/kernel/process_kern.c20
-rw-r--r--arch/um/kernel/ptrace.c79
-rw-r--r--arch/um/kernel/skas/include/mode_kern-skas.h1
-rw-r--r--arch/um/kernel/skas/include/uaccess-skas.h4
-rw-r--r--arch/um/kernel/skas/process.c35
-rw-r--r--arch/um/kernel/skas/process_kern.c4
-rw-r--r--arch/um/kernel/skas/uaccess.c7
-rw-r--r--arch/um/kernel/syscall_kern.c1
-rw-r--r--arch/um/kernel/trap_kern.c2
-rw-r--r--arch/um/kernel/tt/include/mode_kern-tt.h1
-rw-r--r--arch/um/kernel/tt/include/uaccess-tt.h4
-rw-r--r--arch/um/kernel/tt/mem.c8
-rw-r--r--arch/um/kernel/tt/process_kern.c20
-rw-r--r--arch/um/kernel/tt/syscall_user.c4
-rw-r--r--arch/um/kernel/um_arch.c7
-rw-r--r--arch/um/sys-i386/ptrace.c40
-rw-r--r--arch/um/sys-ppc/ptrace.c40
-rw-r--r--arch/um/sys-x86_64/ptrace.c44
-rw-r--r--arch/um/sys-x86_64/signal.c2
-rw-r--r--arch/um/sys-x86_64/syscalls.c2
25 files changed, 222 insertions, 115 deletions
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 53eb5cfd5b63..848bb97af7ca 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -650,7 +650,7 @@ acpi_find_rsdp (void)
650 */ 650 */
651 rsdp_phys = acpi_scan_rsdp (0, 0x400); 651 rsdp_phys = acpi_scan_rsdp (0, 0x400);
652 if (!rsdp_phys) 652 if (!rsdp_phys)
653 rsdp_phys = acpi_scan_rsdp (0xE0000, 0xFFFFF); 653 rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000);
654 654
655 return rsdp_phys; 655 return rsdp_phys;
656} 656}
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index d0d94e56b90b..600f23d7fd33 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -77,9 +77,11 @@ config 44x
77 bool "44x" 77 bool "44x"
78 78
79config POWER3 79config POWER3
80 select PPC_FPU
80 bool "POWER3" 81 bool "POWER3"
81 82
82config POWER4 83config POWER4
84 select PPC_FPU
83 bool "POWER4 and 970 (G5)" 85 bool "POWER4 and 970 (G5)"
84 86
85config 8xx 87config 8xx
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index 257ff66d83cf..5cb343883e4d 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -262,6 +262,7 @@ config PPC_RTAS
262config RTAS_PROC 262config RTAS_PROC
263 bool "Proc interface to RTAS" 263 bool "Proc interface to RTAS"
264 depends on PPC_RTAS 264 depends on PPC_RTAS
265 default y
265 266
266config RTAS_FLASH 267config RTAS_FLASH
267 tristate "Firmware flash interface" 268 tristate "Firmware flash interface"
diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h
index 103cd320386c..b8c5b8a95250 100644
--- a/arch/um/include/user_util.h
+++ b/arch/um/include/user_util.h
@@ -67,7 +67,6 @@ extern void *um_kmalloc(int size);
67extern int switcheroo(int fd, int prot, void *from, void *to, int size); 67extern int switcheroo(int fd, int prot, void *from, void *to, int size);
68extern void setup_machinename(char *machine_out); 68extern void setup_machinename(char *machine_out);
69extern void setup_hostinfo(void); 69extern void setup_hostinfo(void);
70extern void add_arg(char *arg);
71extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); 70extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
72extern void init_new_thread_signals(int altstack); 71extern void init_new_thread_signals(int altstack);
73extern void do_exec(int old_pid, int new_pid); 72extern void do_exec(int old_pid, int new_pid);
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index dca654263857..9736ca27c5f0 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -23,14 +23,10 @@ obj-$(CONFIG_SYSCALL_DEBUG) += syscall_user.o
23obj-$(CONFIG_MODE_TT) += tt/ 23obj-$(CONFIG_MODE_TT) += tt/
24obj-$(CONFIG_MODE_SKAS) += skas/ 24obj-$(CONFIG_MODE_SKAS) += skas/
25 25
26# This needs be compiled with frame pointers regardless of how the rest of the
27# kernel is built.
28CFLAGS_frame.o := -fno-omit-frame-pointer
29
30user-objs-$(CONFIG_TTY_LOG) += tty_log.o 26user-objs-$(CONFIG_TTY_LOG) += tty_log.o
31 27
32USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \ 28USER_OBJS := $(user-objs-y) config.o helper.o main.o process.o tempfile.o \
33 time.o tty_log.o umid.o user_util.o frame.o 29 time.o tty_log.o umid.o user_util.o
34 30
35include arch/um/scripts/Makefile.rules 31include arch/um/scripts/Makefile.rules
36 32
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index 7a943696f950..c1adf7ba3fd1 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -115,16 +115,6 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
115 return(pid); 115 return(pid);
116} 116}
117 117
118void switch_mm(struct mm_struct *prev, struct mm_struct *next,
119 struct task_struct *tsk)
120{
121 int cpu = smp_processor_id();
122
123 if (prev != next)
124 cpu_clear(cpu, prev->cpu_vm_mask);
125 cpu_set(cpu, next->cpu_vm_mask);
126}
127
128void set_current(void *t) 118void set_current(void *t)
129{ 119{
130 struct task_struct *task = t; 120 struct task_struct *task = t;
@@ -152,7 +142,6 @@ void release_thread(struct task_struct *task)
152 142
153void exit_thread(void) 143void exit_thread(void)
154{ 144{
155 CHOOSE_MODE(exit_thread_tt(), exit_thread_skas());
156 unprotect_stack((unsigned long) current_thread); 145 unprotect_stack((unsigned long) current_thread);
157} 146}
158 147
@@ -476,12 +465,21 @@ int singlestepping(void * t)
476 return 2; 465 return 2;
477} 466}
478 467
468/*
469 * Only x86 and x86_64 have an arch_align_stack().
470 * All other arches have "#define arch_align_stack(x) (x)"
471 * in their asm/system.h
472 * As this is included in UML from asm-um/system-generic.h,
473 * we can use it to behave as the subarch does.
474 */
475#ifndef arch_align_stack
479unsigned long arch_align_stack(unsigned long sp) 476unsigned long arch_align_stack(unsigned long sp)
480{ 477{
481 if (randomize_va_space) 478 if (randomize_va_space)
482 sp -= get_random_int() % 8192; 479 sp -= get_random_int() % 8192;
483 return sp & ~0xf; 480 return sp & ~0xf;
484} 481}
482#endif
485 483
486 484
487/* 485/*
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 3efa59a941a4..2b75d8d9ba73 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -19,15 +19,30 @@
19#include "skas_ptrace.h" 19#include "skas_ptrace.h"
20#include "sysdep/ptrace.h" 20#include "sysdep/ptrace.h"
21 21
22static inline void set_singlestepping(struct task_struct *child, int on)
23{
24 if (on)
25 child->ptrace |= PT_DTRACE;
26 else
27 child->ptrace &= ~PT_DTRACE;
28 child->thread.singlestep_syscall = 0;
29
30#ifdef SUBARCH_SET_SINGLESTEPPING
31 SUBARCH_SET_SINGLESTEPPING(child, on)
32#endif
33 }
34
22/* 35/*
23 * Called by kernel/ptrace.c when detaching.. 36 * Called by kernel/ptrace.c when detaching..
24 */ 37 */
25void ptrace_disable(struct task_struct *child) 38void ptrace_disable(struct task_struct *child)
26{ 39{
27 child->ptrace &= ~PT_DTRACE; 40 set_singlestepping(child,0);
28 child->thread.singlestep_syscall = 0;
29} 41}
30 42
43extern int peek_user(struct task_struct * child, long addr, long data);
44extern int poke_user(struct task_struct * child, long addr, long data);
45
31long sys_ptrace(long request, long pid, long addr, long data) 46long sys_ptrace(long request, long pid, long addr, long data)
32{ 47{
33 struct task_struct *child; 48 struct task_struct *child;
@@ -67,6 +82,10 @@ long sys_ptrace(long request, long pid, long addr, long data)
67 goto out_tsk; 82 goto out_tsk;
68 } 83 }
69 84
85#ifdef SUBACH_PTRACE_SPECIAL
86 SUBARCH_PTRACE_SPECIAL(child,request,addr,data)
87#endif
88
70 ret = ptrace_check_attach(child, request == PTRACE_KILL); 89 ret = ptrace_check_attach(child, request == PTRACE_KILL);
71 if (ret < 0) 90 if (ret < 0)
72 goto out_tsk; 91 goto out_tsk;
@@ -87,28 +106,9 @@ long sys_ptrace(long request, long pid, long addr, long data)
87 } 106 }
88 107
89 /* read the word at location addr in the USER area. */ 108 /* read the word at location addr in the USER area. */
90 case PTRACE_PEEKUSR: { 109 case PTRACE_PEEKUSR:
91 unsigned long tmp; 110 ret = peek_user(child, addr, data);
92 111 break;
93 ret = -EIO;
94 if ((addr & 3) || addr < 0)
95 break;
96
97 tmp = 0; /* Default return condition */
98 if(addr < MAX_REG_OFFSET){
99 tmp = getreg(child, addr);
100 }
101#if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
102 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
103 (addr <= offsetof(struct user, u_debugreg[7]))){
104 addr -= offsetof(struct user, u_debugreg[0]);
105 addr = addr >> 2;
106 tmp = child->thread.arch.debugregs[addr];
107 }
108#endif
109 ret = put_user(tmp, (unsigned long __user *) data);
110 break;
111 }
112 112
113 /* when I and D space are separate, this will have to be fixed. */ 113 /* when I and D space are separate, this will have to be fixed. */
114 case PTRACE_POKETEXT: /* write the word at location addr. */ 114 case PTRACE_POKETEXT: /* write the word at location addr. */
@@ -121,26 +121,8 @@ long sys_ptrace(long request, long pid, long addr, long data)
121 break; 121 break;
122 122
123 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 123 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
124 ret = -EIO; 124 ret = poke_user(child, addr, data);
125 if ((addr & 3) || addr < 0) 125 break;
126 break;
127
128 if (addr < MAX_REG_OFFSET) {
129 ret = putreg(child, addr, data);
130 break;
131 }
132#if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
133 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
134 (addr <= offsetof(struct user, u_debugreg[7]))){
135 addr -= offsetof(struct user, u_debugreg[0]);
136 addr = addr >> 2;
137 if((addr == 4) || (addr == 5)) break;
138 child->thread.arch.debugregs[addr] = data;
139 ret = 0;
140 }
141#endif
142
143 break;
144 126
145 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 127 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
146 case PTRACE_CONT: { /* restart after signal. */ 128 case PTRACE_CONT: { /* restart after signal. */
@@ -148,8 +130,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
148 if (!valid_signal(data)) 130 if (!valid_signal(data))
149 break; 131 break;
150 132
151 child->ptrace &= ~PT_DTRACE; 133 set_singlestepping(child, 0);
152 child->thread.singlestep_syscall = 0;
153 if (request == PTRACE_SYSCALL) { 134 if (request == PTRACE_SYSCALL) {
154 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 135 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
155 } 136 }
@@ -172,8 +153,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
172 if (child->exit_state == EXIT_ZOMBIE) /* already dead */ 153 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
173 break; 154 break;
174 155
175 child->ptrace &= ~PT_DTRACE; 156 set_singlestepping(child, 0);
176 child->thread.singlestep_syscall = 0;
177 child->exit_code = SIGKILL; 157 child->exit_code = SIGKILL;
178 wake_up_process(child); 158 wake_up_process(child);
179 break; 159 break;
@@ -184,8 +164,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
184 if (!valid_signal(data)) 164 if (!valid_signal(data))
185 break; 165 break;
186 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 166 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
187 child->ptrace |= PT_DTRACE; 167 set_singlestepping(child, 1);
188 child->thread.singlestep_syscall = 0;
189 child->exit_code = data; 168 child->exit_code = data;
190 /* give it a chance to run. */ 169 /* give it a chance to run. */
191 wake_up_process(child); 170 wake_up_process(child);
diff --git a/arch/um/kernel/skas/include/mode_kern-skas.h b/arch/um/kernel/skas/include/mode_kern-skas.h
index 94c564962378..e48490028111 100644
--- a/arch/um/kernel/skas/include/mode_kern-skas.h
+++ b/arch/um/kernel/skas/include/mode_kern-skas.h
@@ -18,7 +18,6 @@ extern int copy_thread_skas(int nr, unsigned long clone_flags,
18 unsigned long sp, unsigned long stack_top, 18 unsigned long sp, unsigned long stack_top,
19 struct task_struct *p, struct pt_regs *regs); 19 struct task_struct *p, struct pt_regs *regs);
20extern void release_thread_skas(struct task_struct *task); 20extern void release_thread_skas(struct task_struct *task);
21extern void exit_thread_skas(void);
22extern void initial_thread_cb_skas(void (*proc)(void *), void *arg); 21extern void initial_thread_cb_skas(void (*proc)(void *), void *arg);
23extern void init_idle_skas(void); 22extern void init_idle_skas(void);
24extern void flush_tlb_kernel_range_skas(unsigned long start, 23extern void flush_tlb_kernel_range_skas(unsigned long start,
diff --git a/arch/um/kernel/skas/include/uaccess-skas.h b/arch/um/kernel/skas/include/uaccess-skas.h
index c35620385da0..cd6c280482cb 100644
--- a/arch/um/kernel/skas/include/uaccess-skas.h
+++ b/arch/um/kernel/skas/include/uaccess-skas.h
@@ -18,8 +18,8 @@
18 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ 18 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
19 ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))) 19 ((unsigned long) (addr) + (size) >= (unsigned long)(addr))))
20 20
21static inline int __deprecated verify_area_skas(int type, const void * addr, 21static inline int verify_area_skas(int type, const void * addr,
22 unsigned long size) 22 unsigned long size)
23{ 23{
24 return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); 24 return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
25} 25}
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index 4dc13bc8cfd8..773cd2b525fc 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -201,6 +201,11 @@ void userspace(union uml_pt_regs *regs)
201 } 201 }
202 } 202 }
203} 203}
204#define INIT_JMP_NEW_THREAD 0
205#define INIT_JMP_REMOVE_SIGSTACK 1
206#define INIT_JMP_CALLBACK 2
207#define INIT_JMP_HALT 3
208#define INIT_JMP_REBOOT 4
204 209
205void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, 210void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr,
206 void (*handler)(int)) 211 void (*handler)(int))
@@ -236,7 +241,7 @@ void thread_wait(void *sw, void *fb)
236 *switch_buf = &buf; 241 *switch_buf = &buf;
237 fork_buf = fb; 242 fork_buf = fb;
238 if(sigsetjmp(buf, 1) == 0) 243 if(sigsetjmp(buf, 1) == 0)
239 siglongjmp(*fork_buf, 1); 244 siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK);
240} 245}
241 246
242void switch_threads(void *me, void *next) 247void switch_threads(void *me, void *next)
@@ -266,21 +271,25 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
266 271
267 *fork_buf_ptr = &initial_jmpbuf; 272 *fork_buf_ptr = &initial_jmpbuf;
268 n = sigsetjmp(initial_jmpbuf, 1); 273 n = sigsetjmp(initial_jmpbuf, 1);
269 if(n == 0) 274 switch(n){
270 new_thread_proc((void *) stack, new_thread_handler); 275 case INIT_JMP_NEW_THREAD:
271 else if(n == 1) 276 new_thread_proc((void *) stack, new_thread_handler);
272 remove_sigstack(); 277 break;
273 else if(n == 2){ 278 case INIT_JMP_REMOVE_SIGSTACK:
279 remove_sigstack();
280 break;
281 case INIT_JMP_CALLBACK:
274 (*cb_proc)(cb_arg); 282 (*cb_proc)(cb_arg);
275 siglongjmp(*cb_back, 1); 283 siglongjmp(*cb_back, 1);
276 } 284 break;
277 else if(n == 3){ 285 case INIT_JMP_HALT:
278 kmalloc_ok = 0; 286 kmalloc_ok = 0;
279 return(0); 287 return(0);
280 } 288 case INIT_JMP_REBOOT:
281 else if(n == 4){
282 kmalloc_ok = 0; 289 kmalloc_ok = 0;
283 return(1); 290 return(1);
291 default:
292 panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
284 } 293 }
285 siglongjmp(**switch_buf, 1); 294 siglongjmp(**switch_buf, 1);
286} 295}
@@ -305,7 +314,7 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
305 314
306 block_signals(); 315 block_signals();
307 if(sigsetjmp(here, 1) == 0) 316 if(sigsetjmp(here, 1) == 0)
308 siglongjmp(initial_jmpbuf, 2); 317 siglongjmp(initial_jmpbuf, INIT_JMP_CALLBACK);
309 unblock_signals(); 318 unblock_signals();
310 319
311 cb_proc = NULL; 320 cb_proc = NULL;
@@ -316,13 +325,13 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg)
316void halt_skas(void) 325void halt_skas(void)
317{ 326{
318 block_signals(); 327 block_signals();
319 siglongjmp(initial_jmpbuf, 3); 328 siglongjmp(initial_jmpbuf, INIT_JMP_HALT);
320} 329}
321 330
322void reboot_skas(void) 331void reboot_skas(void)
323{ 332{
324 block_signals(); 333 block_signals();
325 siglongjmp(initial_jmpbuf, 4); 334 siglongjmp(initial_jmpbuf, INIT_JMP_REBOOT);
326} 335}
327 336
328void switch_mm_skas(int mm_fd) 337void switch_mm_skas(int mm_fd)
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index 5d096ea63b97..ab5d3271da0b 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -83,10 +83,6 @@ void release_thread_skas(struct task_struct *task)
83{ 83{
84} 84}
85 85
86void exit_thread_skas(void)
87{
88}
89
90void fork_handler(int sig) 86void fork_handler(int sig)
91{ 87{
92 change_sig(SIGUSR1, 1); 88 change_sig(SIGUSR1, 1);
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index f7da9d027672..75195281081e 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -29,9 +29,12 @@ static unsigned long maybe_map(unsigned long virt, int is_write)
29 if(IS_ERR(phys) || (is_write && !pte_write(pte))){ 29 if(IS_ERR(phys) || (is_write && !pte_write(pte))){
30 err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); 30 err = handle_page_fault(virt, 0, is_write, 1, &dummy_code);
31 if(err) 31 if(err)
32 return(0); 32 return(-1UL);
33 phys = um_virt_to_phys(current, virt, NULL); 33 phys = um_virt_to_phys(current, virt, NULL);
34 } 34 }
35 if(IS_ERR(phys))
36 phys = (void *) -1;
37
35 return((unsigned long) phys); 38 return((unsigned long) phys);
36} 39}
37 40
@@ -42,7 +45,7 @@ static int do_op(unsigned long addr, int len, int is_write,
42 int n; 45 int n;
43 46
44 addr = maybe_map(addr, is_write); 47 addr = maybe_map(addr, is_write);
45 if(addr == -1) 48 if(addr == -1UL)
46 return(-1); 49 return(-1);
47 50
48 page = phys_to_page(addr); 51 page = phys_to_page(addr);
diff --git a/arch/um/kernel/syscall_kern.c b/arch/um/kernel/syscall_kern.c
index 42731e04f50f..b7a55251e897 100644
--- a/arch/um/kernel/syscall_kern.c
+++ b/arch/um/kernel/syscall_kern.c
@@ -17,7 +17,6 @@
17#include "linux/utime.h" 17#include "linux/utime.h"
18#include "asm/mman.h" 18#include "asm/mman.h"
19#include "asm/uaccess.h" 19#include "asm/uaccess.h"
20#include "asm/ipc.h"
21#include "kern_util.h" 20#include "kern_util.h"
22#include "user_util.h" 21#include "user_util.h"
23#include "sysdep/syscalls.h" 22#include "sysdep/syscalls.h"
diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
index 54e2ec33a43c..5fca2c61eb98 100644
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -48,7 +48,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
48 goto good_area; 48 goto good_area;
49 else if(!(vma->vm_flags & VM_GROWSDOWN)) 49 else if(!(vma->vm_flags & VM_GROWSDOWN))
50 goto out; 50 goto out;
51 else if(!ARCH_IS_STACKGROW(address)) 51 else if(is_user && !ARCH_IS_STACKGROW(address))
52 goto out; 52 goto out;
53 else if(expand_stack(vma, address)) 53 else if(expand_stack(vma, address))
54 goto out; 54 goto out;
diff --git a/arch/um/kernel/tt/include/mode_kern-tt.h b/arch/um/kernel/tt/include/mode_kern-tt.h
index 28aaab3448fa..e0ca0e0b2516 100644
--- a/arch/um/kernel/tt/include/mode_kern-tt.h
+++ b/arch/um/kernel/tt/include/mode_kern-tt.h
@@ -19,7 +19,6 @@ extern int copy_thread_tt(int nr, unsigned long clone_flags, unsigned long sp,
19 unsigned long stack_top, struct task_struct *p, 19 unsigned long stack_top, struct task_struct *p,
20 struct pt_regs *regs); 20 struct pt_regs *regs);
21extern void release_thread_tt(struct task_struct *task); 21extern void release_thread_tt(struct task_struct *task);
22extern void exit_thread_tt(void);
23extern void initial_thread_cb_tt(void (*proc)(void *), void *arg); 22extern void initial_thread_cb_tt(void (*proc)(void *), void *arg);
24extern void init_idle_tt(void); 23extern void init_idle_tt(void);
25extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end); 24extern void flush_tlb_kernel_range_tt(unsigned long start, unsigned long end);
diff --git a/arch/um/kernel/tt/include/uaccess-tt.h b/arch/um/kernel/tt/include/uaccess-tt.h
index bb69d6b7d022..3fbb5fe26f49 100644
--- a/arch/um/kernel/tt/include/uaccess-tt.h
+++ b/arch/um/kernel/tt/include/uaccess-tt.h
@@ -33,8 +33,8 @@ extern unsigned long uml_physmem;
33 (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \ 33 (((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) && \
34 (under_task_size(addr, size) || is_stack(addr, size)))) 34 (under_task_size(addr, size) || is_stack(addr, size))))
35 35
36static inline int __deprecated verify_area_tt(int type, const void * addr, 36static inline int verify_area_tt(int type, const void * addr,
37 unsigned long size) 37 unsigned long size)
38{ 38{
39 return(access_ok_tt(type, addr, size) ? 0 : -EFAULT); 39 return(access_ok_tt(type, addr, size) ? 0 : -EFAULT);
40} 40}
diff --git a/arch/um/kernel/tt/mem.c b/arch/um/kernel/tt/mem.c
index 74346a04a2b2..bcb8796c3cb1 100644
--- a/arch/um/kernel/tt/mem.c
+++ b/arch/um/kernel/tt/mem.c
@@ -21,14 +21,8 @@ void before_mem_tt(unsigned long brk_start)
21 remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1); 21 remap_data(UML_ROUND_DOWN(&__bss_start), UML_ROUND_UP(&_end), 1);
22} 22}
23 23
24#ifdef CONFIG_HOST_2G_2G
25#define TOP 0x80000000
26#else
27#define TOP 0xc0000000
28#endif
29
30#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000) 24#define SIZE ((CONFIG_NEST_LEVEL + CONFIG_KERNEL_HALF_GIGS) * 0x20000000)
31#define START (TOP - SIZE) 25#define START (CONFIG_TOP_ADDR - SIZE)
32 26
33unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out, 27unsigned long set_task_sizes_tt(int arg, unsigned long *host_size_out,
34 unsigned long *task_size_out) 28 unsigned long *task_size_out)
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index f19f7c18febe..df810ca8fc12 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -65,8 +65,7 @@ void *switch_to_tt(void *prev, void *next, void *last)
65 panic("write of switch_pipe failed, err = %d", -err); 65 panic("write of switch_pipe failed, err = %d", -err);
66 66
67 reading = 1; 67 reading = 1;
68 if((from->exit_state == EXIT_ZOMBIE) || 68 if(from->thread.mode.tt.switch_pipe[0] == -1)
69 (from->exit_state == EXIT_DEAD))
70 os_kill_process(os_getpid(), 0); 69 os_kill_process(os_getpid(), 0);
71 70
72 err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c)); 71 err = os_read_file(from->thread.mode.tt.switch_pipe[0], &c, sizeof(c));
@@ -81,8 +80,7 @@ void *switch_to_tt(void *prev, void *next, void *last)
81 * in case it has not already killed itself. 80 * in case it has not already killed itself.
82 */ 81 */
83 prev_sched = current->thread.prev_sched; 82 prev_sched = current->thread.prev_sched;
84 if((prev_sched->exit_state == EXIT_ZOMBIE) || 83 if(prev_sched->thread.mode.tt.switch_pipe[0] == -1)
85 (prev_sched->exit_state == EXIT_DEAD))
86 os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1); 84 os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1);
87 85
88 change_sig(SIGVTALRM, vtalrm); 86 change_sig(SIGVTALRM, vtalrm);
@@ -101,14 +99,18 @@ void release_thread_tt(struct task_struct *task)
101{ 99{
102 int pid = task->thread.mode.tt.extern_pid; 100 int pid = task->thread.mode.tt.extern_pid;
103 101
102 /*
103 * We first have to kill the other process, before
104 * closing its switch_pipe. Else it might wake up
105 * and receive "EOF" before we could kill it.
106 */
104 if(os_getpid() != pid) 107 if(os_getpid() != pid)
105 os_kill_process(pid, 0); 108 os_kill_process(pid, 0);
106}
107 109
108void exit_thread_tt(void) 110 os_close_file(task->thread.mode.tt.switch_pipe[0]);
109{ 111 os_close_file(task->thread.mode.tt.switch_pipe[1]);
110 os_close_file(current->thread.mode.tt.switch_pipe[0]); 112 /* use switch_pipe as flag: thread is released */
111 os_close_file(current->thread.mode.tt.switch_pipe[1]); 113 task->thread.mode.tt.switch_pipe[0] = -1;
112} 114}
113 115
114void suspend_new_thread(int fd) 116void suspend_new_thread(int fd)
diff --git a/arch/um/kernel/tt/syscall_user.c b/arch/um/kernel/tt/syscall_user.c
index e4e7e9c2224c..b218316cfdb2 100644
--- a/arch/um/kernel/tt/syscall_user.c
+++ b/arch/um/kernel/tt/syscall_user.c
@@ -63,6 +63,10 @@ void do_syscall(void *task, int pid, int local_using_sysemu)
63 63
64 UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs); 64 UPT_SYSCALL_NR(TASK_REGS(task)) = PT_SYSCALL_NR(proc_regs);
65 65
66#ifdef UPT_ORIGGPR2
67 UPT_ORIGGPR2(TASK_REGS(task)) = REGS_ORIGGPR2(proc_regs);
68#endif
69
66 if(((unsigned long *) PT_IP(proc_regs) >= &_stext) && 70 if(((unsigned long *) PT_IP(proc_regs) >= &_stext) &&
67 ((unsigned long *) PT_IP(proc_regs) <= &_etext)) 71 ((unsigned long *) PT_IP(proc_regs) <= &_etext))
68 tracer_panic("I'm tracing myself and I can't get out"); 72 tracer_panic("I'm tracing myself and I can't get out");
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 5c49d88eed3d..4d10ec372a67 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -23,6 +23,7 @@
23#include "asm/ptrace.h" 23#include "asm/ptrace.h"
24#include "asm/elf.h" 24#include "asm/elf.h"
25#include "asm/user.h" 25#include "asm/user.h"
26#include "asm/setup.h"
26#include "ubd_user.h" 27#include "ubd_user.h"
27#include "asm/current.h" 28#include "asm/current.h"
28#include "asm/setup.h" 29#include "asm/setup.h"
@@ -42,9 +43,9 @@
42#define DEFAULT_COMMAND_LINE "root=98:0" 43#define DEFAULT_COMMAND_LINE "root=98:0"
43 44
44/* Changed in linux_main and setup_arch, which run before SMP is started */ 45/* Changed in linux_main and setup_arch, which run before SMP is started */
45char command_line[COMMAND_LINE_SIZE] = { 0 }; 46static char command_line[COMMAND_LINE_SIZE] = { 0 };
46 47
47void add_arg(char *arg) 48static void add_arg(char *arg)
48{ 49{
49 if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) { 50 if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
50 printf("add_arg: Too many command line arguments!\n"); 51 printf("add_arg: Too many command line arguments!\n");
@@ -449,7 +450,7 @@ void __init setup_arch(char **cmdline_p)
449{ 450{
450 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier); 451 notifier_chain_register(&panic_notifier_list, &panic_exit_notifier);
451 paging_init(); 452 paging_init();
452 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 453 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
453 *cmdline_p = command_line; 454 *cmdline_p = command_line;
454 setup_hostinfo(); 455 setup_hostinfo();
455} 456}
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index e470d28cdf84..e839ce65ad28 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -73,6 +73,25 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
73 return 0; 73 return 0;
74} 74}
75 75
76int poke_user(struct task_struct *child, long addr, long data)
77{
78 if ((addr & 3) || addr < 0)
79 return -EIO;
80
81 if (addr < MAX_REG_OFFSET)
82 return putreg(child, addr, data);
83
84 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
85 (addr <= offsetof(struct user, u_debugreg[7]))){
86 addr -= offsetof(struct user, u_debugreg[0]);
87 addr = addr >> 2;
88 if((addr == 4) || (addr == 5)) return -EIO;
89 child->thread.arch.debugregs[addr] = data;
90 return 0;
91 }
92 return -EIO;
93}
94
76unsigned long getreg(struct task_struct *child, int regno) 95unsigned long getreg(struct task_struct *child, int regno)
77{ 96{
78 unsigned long retval = ~0UL; 97 unsigned long retval = ~0UL;
@@ -93,6 +112,27 @@ unsigned long getreg(struct task_struct *child, int regno)
93 return retval; 112 return retval;
94} 113}
95 114
115int peek_user(struct task_struct *child, long addr, long data)
116{
117/* read the word at location addr in the USER area. */
118 unsigned long tmp;
119
120 if ((addr & 3) || addr < 0)
121 return -EIO;
122
123 tmp = 0; /* Default return condition */
124 if(addr < MAX_REG_OFFSET){
125 tmp = getreg(child, addr);
126 }
127 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
128 (addr <= offsetof(struct user, u_debugreg[7]))){
129 addr -= offsetof(struct user, u_debugreg[0]);
130 addr = addr >> 2;
131 tmp = child->thread.arch.debugregs[addr];
132 }
133 return put_user(tmp, (unsigned long *) data);
134}
135
96struct i387_fxsave_struct { 136struct i387_fxsave_struct {
97 unsigned short cwd; 137 unsigned short cwd;
98 unsigned short swd; 138 unsigned short swd;
diff --git a/arch/um/sys-ppc/ptrace.c b/arch/um/sys-ppc/ptrace.c
index a971366d3277..8e71b47f2b8e 100644
--- a/arch/um/sys-ppc/ptrace.c
+++ b/arch/um/sys-ppc/ptrace.c
@@ -8,6 +8,25 @@ int putreg(struct task_struct *child, unsigned long regno,
8 return 0; 8 return 0;
9} 9}
10 10
11int poke_user(struct task_struct *child, long addr, long data)
12{
13 if ((addr & 3) || addr < 0)
14 return -EIO;
15
16 if (addr < MAX_REG_OFFSET)
17 return putreg(child, addr, data);
18
19 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
20 (addr <= offsetof(struct user, u_debugreg[7]))){
21 addr -= offsetof(struct user, u_debugreg[0]);
22 addr = addr >> 2;
23 if((addr == 4) || (addr == 5)) return -EIO;
24 child->thread.arch.debugregs[addr] = data;
25 return 0;
26 }
27 return -EIO;
28}
29
11unsigned long getreg(struct task_struct *child, unsigned long regno) 30unsigned long getreg(struct task_struct *child, unsigned long regno)
12{ 31{
13 unsigned long retval = ~0UL; 32 unsigned long retval = ~0UL;
@@ -16,6 +35,27 @@ unsigned long getreg(struct task_struct *child, unsigned long regno)
16 return retval; 35 return retval;
17} 36}
18 37
38int peek_user(struct task_struct *child, long addr, long data)
39{
40 /* read the word at location addr in the USER area. */
41 unsigned long tmp;
42
43 if ((addr & 3) || addr < 0)
44 return -EIO;
45
46 tmp = 0; /* Default return condition */
47 if(addr < MAX_REG_OFFSET){
48 tmp = getreg(child, addr);
49 }
50 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
51 (addr <= offsetof(struct user, u_debugreg[7]))){
52 addr -= offsetof(struct user, u_debugreg[0]);
53 addr = addr >> 2;
54 tmp = child->thread.arch.debugregs[addr];
55 }
56 return put_user(tmp, (unsigned long *) data);
57}
58
19/* 59/*
20 * Overrides for Emacs so that we follow Linus's tabbing style. 60 * Overrides for Emacs so that we follow Linus's tabbing style.
21 * Emacs will notice this stuff at the end of the file and automatically 61 * Emacs will notice this stuff at the end of the file and automatically
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index 8c146b2a1e00..b593bb256f2c 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -62,6 +62,27 @@ int putreg(struct task_struct *child, int regno, unsigned long value)
62 return 0; 62 return 0;
63} 63}
64 64
65int poke_user(struct task_struct *child, long addr, long data)
66{
67 if ((addr & 3) || addr < 0)
68 return -EIO;
69
70 if (addr < MAX_REG_OFFSET)
71 return putreg(child, addr, data);
72
73#if 0 /* Need x86_64 debugregs handling */
74 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
75 (addr <= offsetof(struct user, u_debugreg[7]))){
76 addr -= offsetof(struct user, u_debugreg[0]);
77 addr = addr >> 2;
78 if((addr == 4) || (addr == 5)) return -EIO;
79 child->thread.arch.debugregs[addr] = data;
80 return 0;
81 }
82#endif
83 return -EIO;
84}
85
65unsigned long getreg(struct task_struct *child, int regno) 86unsigned long getreg(struct task_struct *child, int regno)
66{ 87{
67 unsigned long retval = ~0UL; 88 unsigned long retval = ~0UL;
@@ -84,6 +105,29 @@ unsigned long getreg(struct task_struct *child, int regno)
84 return retval; 105 return retval;
85} 106}
86 107
108int peek_user(struct task_struct *child, long addr, long data)
109{
110 /* read the word at location addr in the USER area. */
111 unsigned long tmp;
112
113 if ((addr & 3) || addr < 0)
114 return -EIO;
115
116 tmp = 0; /* Default return condition */
117 if(addr < MAX_REG_OFFSET){
118 tmp = getreg(child, addr);
119 }
120#if 0 /* Need x86_64 debugregs handling */
121 else if((addr >= offsetof(struct user, u_debugreg[0])) &&
122 (addr <= offsetof(struct user, u_debugreg[7]))){
123 addr -= offsetof(struct user, u_debugreg[0]);
124 addr = addr >> 2;
125 tmp = child->thread.arch.debugregs[addr];
126 }
127#endif
128 return put_user(tmp, (unsigned long *) data);
129}
130
87void arch_switch(void) 131void arch_switch(void)
88{ 132{
89/* XXX 133/* XXX
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index b740177066a0..73a7926f7370 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -168,7 +168,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
168 168
169 frame = (struct rt_sigframe __user *) 169 frame = (struct rt_sigframe __user *)
170 round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8; 170 round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8;
171 frame -= 128; 171 ((unsigned char *) frame) -= 128;
172 172
173 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) 173 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
174 goto out; 174 goto out;
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c
index 2a575ef52bba..dd9914642b8e 100644
--- a/arch/um/sys-x86_64/syscalls.c
+++ b/arch/um/sys-x86_64/syscalls.c
@@ -44,6 +44,8 @@ long sys_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
44#ifdef CONFIG_MODE_SKAS 44#ifdef CONFIG_MODE_SKAS
45extern int userspace_pid[]; 45extern int userspace_pid[];
46 46
47#include "skas_ptrace.h"
48
47long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount) 49long sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
48{ 50{
49 struct ptrace_ldt ldt; 51 struct ptrace_ldt ldt;