aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/skas/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux/skas/process.c')
-rw-r--r--arch/um/os-Linux/skas/process.c281
1 files changed, 186 insertions, 95 deletions
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index e8b7a97e83d3..d36c89c24a45 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -15,6 +15,7 @@
15#include "as-layout.h" 15#include "as-layout.h"
16#include "chan_user.h" 16#include "chan_user.h"
17#include "kern_constants.h" 17#include "kern_constants.h"
18#include "kern_util.h"
18#include "mem.h" 19#include "mem.h"
19#include "os.h" 20#include "os.h"
20#include "process.h" 21#include "process.h"
@@ -37,27 +38,27 @@ int is_skas_winch(int pid, int fd, void *data)
37 38
38static int ptrace_dump_regs(int pid) 39static int ptrace_dump_regs(int pid)
39{ 40{
40 unsigned long regs[MAX_REG_NR]; 41 unsigned long regs[MAX_REG_NR];
41 int i; 42 int i;
42 43
43 if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) 44 if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
44 return -errno; 45 return -errno;
45 46
46 printk(UM_KERN_ERR "Stub registers -\n"); 47 printk(UM_KERN_ERR "Stub registers -\n");
47 for (i = 0; i < ARRAY_SIZE(regs); i++) 48 for (i = 0; i < ARRAY_SIZE(regs); i++)
48 printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]); 49 printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]);
49 50
50 return 0; 51 return 0;
51} 52}
52 53
53/* 54/*
54 * Signals that are OK to receive in the stub - we'll just continue it. 55 * Signals that are OK to receive in the stub - we'll just continue it.
55 * SIGWINCH will happen when UML is inside a detached screen. 56 * SIGWINCH will happen when UML is inside a detached screen.
56 */ 57 */
57#define STUB_SIG_MASK ((1 << SIGVTALRM) | (1 << SIGWINCH)) 58#define STUB_SIG_MASK (1 << SIGVTALRM)
58 59
59/* Signals that the stub will finish with - anything else is an error */ 60/* Signals that the stub will finish with - anything else is an error */
60#define STUB_DONE_MASK ((1 << SIGUSR1) | (1 << SIGTRAP)) 61#define STUB_DONE_MASK (1 << SIGTRAP)
61 62
62void wait_stub_done(int pid) 63void wait_stub_done(int pid)
63{ 64{
@@ -72,9 +73,11 @@ void wait_stub_done(int pid)
72 break; 73 break;
73 74
74 err = ptrace(PTRACE_CONT, pid, 0, 0); 75 err = ptrace(PTRACE_CONT, pid, 0, 0);
75 if (err) 76 if (err) {
76 panic("wait_stub_done : continue failed, errno = %d\n", 77 printk(UM_KERN_ERR "wait_stub_done : continue failed, "
77 errno); 78 "errno = %d\n", errno);
79 fatal_sigsegv();
80 }
78 } 81 }
79 82
80 if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) 83 if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0)
@@ -85,8 +88,10 @@ bad_wait:
85 if (err) 88 if (err)
86 printk(UM_KERN_ERR "Failed to get registers from stub, " 89 printk(UM_KERN_ERR "Failed to get registers from stub, "
87 "errno = %d\n", -err); 90 "errno = %d\n", -err);
88 panic("wait_stub_done : failed to wait for SIGUSR1/SIGTRAP, pid = %d, " 91 printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, "
89 "n = %d, errno = %d, status = 0x%x\n", pid, n, errno, status); 92 "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno,
93 status);
94 fatal_sigsegv();
90} 95}
91 96
92extern unsigned long current_stub_stack(void); 97extern unsigned long current_stub_stack(void);
@@ -97,9 +102,11 @@ void get_skas_faultinfo(int pid, struct faultinfo * fi)
97 102
98 if (ptrace_faultinfo) { 103 if (ptrace_faultinfo) {
99 err = ptrace(PTRACE_FAULTINFO, pid, 0, fi); 104 err = ptrace(PTRACE_FAULTINFO, pid, 0, fi);
100 if (err) 105 if (err) {
101 panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, " 106 printk(UM_KERN_ERR "get_skas_faultinfo - "
102 "errno = %d\n", errno); 107 "PTRACE_FAULTINFO failed, errno = %d\n", errno);
108 fatal_sigsegv();
109 }
103 110
104 /* Special handling for i386, which has different structs */ 111 /* Special handling for i386, which has different structs */
105 if (sizeof(struct ptrace_faultinfo) < sizeof(struct faultinfo)) 112 if (sizeof(struct ptrace_faultinfo) < sizeof(struct faultinfo))
@@ -109,9 +116,11 @@ void get_skas_faultinfo(int pid, struct faultinfo * fi)
109 } 116 }
110 else { 117 else {
111 err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV); 118 err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV);
112 if (err) 119 if (err) {
113 panic("Failed to continue stub, pid = %d, errno = %d\n", 120 printk(UM_KERN_ERR "Failed to continue stub, pid = %d, "
114 pid, errno); 121 "errno = %d\n", pid, errno);
122 fatal_sigsegv();
123 }
115 wait_stub_done(pid); 124 wait_stub_done(pid);
116 125
117 /* 126 /*
@@ -137,6 +146,9 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,
137{ 146{
138 int err, status; 147 int err, status;
139 148
149 if ((UPT_IP(regs) >= STUB_START) && (UPT_IP(regs) < STUB_END))
150 fatal_sigsegv();
151
140 /* Mark this as a syscall */ 152 /* Mark this as a syscall */
141 UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->gp); 153 UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->gp);
142 154
@@ -144,25 +156,31 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,
144 { 156 {
145 err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, 157 err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
146 __NR_getpid); 158 __NR_getpid);
147 if (err < 0) 159 if (err < 0) {
148 panic("handle_trap - nullifying syscall failed, " 160 printk(UM_KERN_ERR "handle_trap - nullifying syscall "
149 "errno = %d\n", errno); 161 "failed, errno = %d\n", errno);
162 fatal_sigsegv();
163 }
150 164
151 err = ptrace(PTRACE_SYSCALL, pid, 0, 0); 165 err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
152 if (err < 0) 166 if (err < 0) {
153 panic("handle_trap - continuing to end of syscall " 167 printk(UM_KERN_ERR "handle_trap - continuing to end of "
154 "failed, errno = %d\n", errno); 168 "syscall failed, errno = %d\n", errno);
169 fatal_sigsegv();
170 }
155 171
156 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL)); 172 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
157 if ((err < 0) || !WIFSTOPPED(status) || 173 if ((err < 0) || !WIFSTOPPED(status) ||
158 (WSTOPSIG(status) != SIGTRAP + 0x80)) { 174 (WSTOPSIG(status) != SIGTRAP + 0x80)) {
159 err = ptrace_dump_regs(pid); 175 err = ptrace_dump_regs(pid);
160 if (err) 176 if (err)
161 printk(UM_KERN_ERR "Failed to get registers " 177 printk(UM_KERN_ERR "Failed to get registers "
162 "from process, errno = %d\n", -err); 178 "from process, errno = %d\n", -err);
163 panic("handle_trap - failed to wait at end of syscall, " 179 printk(UM_KERN_ERR "handle_trap - failed to wait at "
164 "errno = %d, status = %d\n", errno, status); 180 "end of syscall, errno = %d, status = %d\n",
165 } 181 errno, status);
182 fatal_sigsegv();
183 }
166 } 184 }
167 185
168 handle_syscall(regs); 186 handle_syscall(regs);
@@ -178,10 +196,13 @@ static int userspace_tramp(void *stack)
178 ptrace(PTRACE_TRACEME, 0, 0, 0); 196 ptrace(PTRACE_TRACEME, 0, 0, 0);
179 197
180 signal(SIGTERM, SIG_DFL); 198 signal(SIGTERM, SIG_DFL);
199 signal(SIGWINCH, SIG_IGN);
181 err = set_interval(); 200 err = set_interval();
182 if (err) 201 if (err) {
183 panic("userspace_tramp - setting timer failed, errno = %d\n", 202 printk(UM_KERN_ERR "userspace_tramp - setting timer failed, "
184 err); 203 "errno = %d\n", err);
204 exit(1);
205 }
185 206
186 if (!proc_mm) { 207 if (!proc_mm) {
187 /* 208 /*
@@ -221,16 +242,14 @@ static int userspace_tramp(void *stack)
221 242
222 set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE); 243 set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE);
223 sigemptyset(&sa.sa_mask); 244 sigemptyset(&sa.sa_mask);
224 sigaddset(&sa.sa_mask, SIGIO); 245 sa.sa_flags = SA_ONSTACK | SA_NODEFER;
225 sigaddset(&sa.sa_mask, SIGWINCH);
226 sigaddset(&sa.sa_mask, SIGVTALRM);
227 sigaddset(&sa.sa_mask, SIGUSR1);
228 sa.sa_flags = SA_ONSTACK;
229 sa.sa_handler = (void *) v; 246 sa.sa_handler = (void *) v;
230 sa.sa_restorer = NULL; 247 sa.sa_restorer = NULL;
231 if (sigaction(SIGSEGV, &sa, NULL) < 0) 248 if (sigaction(SIGSEGV, &sa, NULL) < 0) {
232 panic("userspace_tramp - setting SIGSEGV handler " 249 printk(UM_KERN_ERR "userspace_tramp - setting SIGSEGV "
233 "failed - errno = %d\n", errno); 250 "handler failed - errno = %d\n", errno);
251 exit(1);
252 }
234 } 253 }
235 254
236 kill(os_getpid(), SIGSTOP); 255 kill(os_getpid(), SIGSTOP);
@@ -246,13 +265,18 @@ int start_userspace(unsigned long stub_stack)
246{ 265{
247 void *stack; 266 void *stack;
248 unsigned long sp; 267 unsigned long sp;
249 int pid, status, n, flags; 268 int pid, status, n, flags, err;
250 269
251 stack = mmap(NULL, UM_KERN_PAGE_SIZE, 270 stack = mmap(NULL, UM_KERN_PAGE_SIZE,
252 PROT_READ | PROT_WRITE | PROT_EXEC, 271 PROT_READ | PROT_WRITE | PROT_EXEC,
253 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 272 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
254 if (stack == MAP_FAILED) 273 if (stack == MAP_FAILED) {
255 panic("start_userspace : mmap failed, errno = %d", errno); 274 err = -errno;
275 printk(UM_KERN_ERR "start_userspace : mmap failed, "
276 "errno = %d\n", errno);
277 return err;
278 }
279
256 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); 280 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
257 281
258 flags = CLONE_FILES; 282 flags = CLONE_FILES;
@@ -262,29 +286,50 @@ int start_userspace(unsigned long stub_stack)
262 flags |= SIGCHLD; 286 flags |= SIGCHLD;
263 287
264 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); 288 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack);
265 if (pid < 0) 289 if (pid < 0) {
266 panic("start_userspace : clone failed, errno = %d", errno); 290 err = -errno;
291 printk(UM_KERN_ERR "start_userspace : clone failed, "
292 "errno = %d\n", errno);
293 return err;
294 }
267 295
268 do { 296 do {
269 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL)); 297 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
270 if (n < 0) 298 if (n < 0) {
271 panic("start_userspace : wait failed, errno = %d", 299 err = -errno;
272 errno); 300 printk(UM_KERN_ERR "start_userspace : wait failed, "
301 "errno = %d\n", errno);
302 goto out_kill;
303 }
273 } while (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM)); 304 } while (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM));
274 305
275 if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) 306 if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) {
276 panic("start_userspace : expected SIGSTOP, got status = %d", 307 err = -EINVAL;
277 status); 308 printk(UM_KERN_ERR "start_userspace : expected SIGSTOP, got "
309 "status = %d\n", status);
310 goto out_kill;
311 }
278 312
279 if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL, 313 if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
280 (void *) PTRACE_O_TRACESYSGOOD) < 0) 314 (void *) PTRACE_O_TRACESYSGOOD) < 0) {
281 panic("start_userspace : PTRACE_OLDSETOPTIONS failed, " 315 err = -errno;
282 "errno = %d\n", errno); 316 printk(UM_KERN_ERR "start_userspace : PTRACE_OLDSETOPTIONS "
317 "failed, errno = %d\n", errno);
318 goto out_kill;
319 }
283 320
284 if (munmap(stack, UM_KERN_PAGE_SIZE) < 0) 321 if (munmap(stack, UM_KERN_PAGE_SIZE) < 0) {
285 panic("start_userspace : munmap failed, errno = %d\n", errno); 322 err = -errno;
323 printk(UM_KERN_ERR "start_userspace : munmap failed, "
324 "errno = %d\n", errno);
325 goto out_kill;
326 }
286 327
287 return pid; 328 return pid;
329
330 out_kill:
331 os_kill_ptraced_process(pid, 1);
332 return err;
288} 333}
289 334
290void userspace(struct uml_pt_regs *regs) 335void userspace(struct uml_pt_regs *regs)
@@ -302,7 +347,16 @@ void userspace(struct uml_pt_regs *regs)
302 nsecs += os_nsecs(); 347 nsecs += os_nsecs();
303 348
304 while (1) { 349 while (1) {
305 restore_registers(pid, regs); 350 /*
351 * This can legitimately fail if the process loads a
352 * bogus value into a segment register. It will
353 * segfault and PTRACE_GETREGS will read that value
354 * out of the process. However, PTRACE_SETREGS will
355 * fail. In this case, there is nothing to do but
356 * just kill the process.
357 */
358 if (ptrace(PTRACE_SETREGS, pid, 0, regs->gp))
359 fatal_sigsegv();
306 360
307 /* Now we set local_using_sysemu to be used for one loop */ 361 /* Now we set local_using_sysemu to be used for one loop */
308 local_using_sysemu = get_using_sysemu(); 362 local_using_sysemu = get_using_sysemu();
@@ -310,19 +364,26 @@ void userspace(struct uml_pt_regs *regs)
310 op = SELECT_PTRACE_OPERATION(local_using_sysemu, 364 op = SELECT_PTRACE_OPERATION(local_using_sysemu,
311 singlestepping(NULL)); 365 singlestepping(NULL));
312 366
313 err = ptrace(op, pid, 0, 0); 367 if (ptrace(op, pid, 0, 0)) {
314 if (err) 368 printk(UM_KERN_ERR "userspace - ptrace continue "
315 panic("userspace - could not resume userspace process, " 369 "failed, op = %d, errno = %d\n", op, errno);
316 "pid=%d, ptrace operation = %d, errno = %d\n", 370 fatal_sigsegv();
317 pid, op, errno); 371 }
318 372
319 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL)); 373 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
320 if (err < 0) 374 if (err < 0) {
321 panic("userspace - waitpid failed, errno = %d\n", 375 printk(UM_KERN_ERR "userspace - wait failed, "
322 errno); 376 "errno = %d\n", errno);
377 fatal_sigsegv();
378 }
323 379
324 regs->is_user = 1; 380 regs->is_user = 1;
325 save_registers(pid, regs); 381 if (ptrace(PTRACE_GETREGS, pid, 0, regs->gp)) {
382 printk(UM_KERN_ERR "userspace - PTRACE_GETREGS failed, "
383 "errno = %d\n", errno);
384 fatal_sigsegv();
385 }
386
326 UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */ 387 UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */
327 388
328 if (WIFSTOPPED(status)) { 389 if (WIFSTOPPED(status)) {
@@ -345,7 +406,7 @@ void userspace(struct uml_pt_regs *regs)
345 break; 406 break;
346 case SIGVTALRM: 407 case SIGVTALRM:
347 now = os_nsecs(); 408 now = os_nsecs();
348 if(now < nsecs) 409 if (now < nsecs)
349 break; 410 break;
350 block_signals(); 411 block_signals();
351 (*sig_info[sig])(sig, regs); 412 (*sig_info[sig])(sig, regs);
@@ -368,6 +429,7 @@ void userspace(struct uml_pt_regs *regs)
368 default: 429 default:
369 printk(UM_KERN_ERR "userspace - child stopped " 430 printk(UM_KERN_ERR "userspace - child stopped "
370 "with signal %d\n", sig); 431 "with signal %d\n", sig);
432 fatal_sigsegv();
371 } 433 }
372 pid = userspace_pid[0]; 434 pid = userspace_pid[0];
373 interrupt_end(); 435 interrupt_end();
@@ -419,9 +481,12 @@ int copy_context_skas0(unsigned long new_stack, int pid)
419 .it_interval = tv }) }); 481 .it_interval = tv }) });
420 482
421 err = ptrace_setregs(pid, thread_regs); 483 err = ptrace_setregs(pid, thread_regs);
422 if (err < 0) 484 if (err < 0) {
423 panic("copy_context_skas0 : PTRACE_SETREGS failed, " 485 err = -errno;
424 "pid = %d, errno = %d\n", pid, -err); 486 printk(UM_KERN_ERR "copy_context_skas0 : PTRACE_SETREGS "
487 "failed, pid = %d, errno = %d\n", pid, -err);
488 return err;
489 }
425 490
426 /* set a well known return code for detection of child write failure */ 491 /* set a well known return code for detection of child write failure */
427 child_data->err = 12345678; 492 child_data->err = 12345678;
@@ -431,31 +496,47 @@ int copy_context_skas0(unsigned long new_stack, int pid)
431 * parent's stack, and check, if bad result. 496 * parent's stack, and check, if bad result.
432 */ 497 */
433 err = ptrace(PTRACE_CONT, pid, 0, 0); 498 err = ptrace(PTRACE_CONT, pid, 0, 0);
434 if (err) 499 if (err) {
435 panic("Failed to continue new process, pid = %d, " 500 err = -errno;
436 "errno = %d\n", pid, errno); 501 printk(UM_KERN_ERR "Failed to continue new process, pid = %d, "
502 "errno = %d\n", pid, errno);
503 return err;
504 }
505
437 wait_stub_done(pid); 506 wait_stub_done(pid);
438 507
439 pid = data->err; 508 pid = data->err;
440 if (pid < 0) 509 if (pid < 0) {
441 panic("copy_context_skas0 - stub-parent reports error %d\n", 510 printk(UM_KERN_ERR "copy_context_skas0 - stub-parent reports "
442 -pid); 511 "error %d\n", -pid);
512 return pid;
513 }
443 514
444 /* 515 /*
445 * Wait, until child has finished too: read child's result from 516 * Wait, until child has finished too: read child's result from
446 * child's stack and check it. 517 * child's stack and check it.
447 */ 518 */
448 wait_stub_done(pid); 519 wait_stub_done(pid);
449 if (child_data->err != STUB_DATA) 520 if (child_data->err != STUB_DATA) {
450 panic("copy_context_skas0 - stub-child reports error %ld\n", 521 printk(UM_KERN_ERR "copy_context_skas0 - stub-child reports "
451 child_data->err); 522 "error %ld\n", child_data->err);
523 err = child_data->err;
524 goto out_kill;
525 }
452 526
453 if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL, 527 if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
454 (void *)PTRACE_O_TRACESYSGOOD) < 0) 528 (void *)PTRACE_O_TRACESYSGOOD) < 0) {
455 panic("copy_context_skas0 : PTRACE_OLDSETOPTIONS failed, " 529 err = -errno;
456 "errno = %d\n", errno); 530 printk(UM_KERN_ERR "copy_context_skas0 : PTRACE_OLDSETOPTIONS "
531 "failed, errno = %d\n", errno);
532 goto out_kill;
533 }
457 534
458 return pid; 535 return pid;
536
537 out_kill:
538 os_kill_ptraced_process(pid, 1);
539 return err;
459} 540}
460 541
461/* 542/*
@@ -463,8 +544,8 @@ int copy_context_skas0(unsigned long new_stack, int pid)
463 * available. Opening /proc/mm creates a new mm_context, which lacks 544 * available. Opening /proc/mm creates a new mm_context, which lacks
464 * the stub-pages. Thus, we map them using /proc/mm-fd 545 * the stub-pages. Thus, we map them using /proc/mm-fd
465 */ 546 */
466void map_stub_pages(int fd, unsigned long code, 547int map_stub_pages(int fd, unsigned long code, unsigned long data,
467 unsigned long data, unsigned long stack) 548 unsigned long stack)
468{ 549{
469 struct proc_mm_op mmop; 550 struct proc_mm_op mmop;
470 int n; 551 int n;
@@ -488,8 +569,9 @@ void map_stub_pages(int fd, unsigned long code,
488 printk(UM_KERN_ERR "mmap args - addr = 0x%lx, fd = %d, " 569 printk(UM_KERN_ERR "mmap args - addr = 0x%lx, fd = %d, "
489 "offset = %llx\n", code, code_fd, 570 "offset = %llx\n", code, code_fd,
490 (unsigned long long) code_offset); 571 (unsigned long long) code_offset);
491 panic("map_stub_pages : /proc/mm map for code failed, " 572 printk(UM_KERN_ERR "map_stub_pages : /proc/mm map for code "
492 "err = %d\n", n); 573 "failed, err = %d\n", n);
574 return -n;
493 } 575 }
494 576
495 if (stack) { 577 if (stack) {
@@ -507,10 +589,15 @@ void map_stub_pages(int fd, unsigned long code,
507 .offset = map_offset 589 .offset = map_offset
508 } } }); 590 } } });
509 CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop))); 591 CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
510 if (n != sizeof(mmop)) 592 if (n != sizeof(mmop)) {
511 panic("map_stub_pages : /proc/mm map for data failed, " 593 n = errno;
512 "err = %d\n", errno); 594 printk(UM_KERN_ERR "map_stub_pages : /proc/mm map for "
595 "data failed, err = %d\n", n);
596 return -n;
597 }
513 } 598 }
599
600 return 0;
514} 601}
515 602
516void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)) 603void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
@@ -571,7 +658,9 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
571 kmalloc_ok = 0; 658 kmalloc_ok = 0;
572 return 1; 659 return 1;
573 default: 660 default:
574 panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); 661 printk(UM_KERN_ERR "Bad sigsetjmp return in "
662 "start_idle_thread - %d\n", n);
663 fatal_sigsegv();
575 } 664 }
576 longjmp(*switch_buf, 1); 665 longjmp(*switch_buf, 1);
577} 666}
@@ -614,9 +703,11 @@ void __switch_mm(struct mm_id *mm_idp)
614 if (proc_mm) { 703 if (proc_mm) {
615 err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0, 704 err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0,
616 mm_idp->u.mm_fd); 705 mm_idp->u.mm_fd);
617 if (err) 706 if (err) {
618 panic("__switch_mm - PTRACE_SWITCH_MM failed, " 707 printk(UM_KERN_ERR "__switch_mm - PTRACE_SWITCH_MM "
619 "errno = %d\n", errno); 708 "failed, errno = %d\n", errno);
709 fatal_sigsegv();
710 }
620 } 711 }
621 else userspace_pid[0] = mm_idp->u.pid; 712 else userspace_pid[0] = mm_idp->u.pid;
622} 713}