um: don't bother blocking SIGARLM and SIGUSR1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / um / os-Linux / skas / process.c
blob20b34dcb09067b22304111f904c8fe7f91fc82f1
1 /*
2 * Copyright (C) 2002- 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <sched.h>
9 #include <errno.h>
10 #include <string.h>
11 #include <sys/mman.h>
12 #include <sys/ptrace.h>
13 #include <sys/wait.h>
14 #include <asm/unistd.h>
15 #include "as-layout.h"
16 #include "chan_user.h"
17 #include "kern_util.h"
18 #include "mem.h"
19 #include "os.h"
20 #include "process.h"
21 #include "proc_mm.h"
22 #include "ptrace_user.h"
23 #include "registers.h"
24 #include "skas.h"
25 #include "skas_ptrace.h"
26 #include "sysdep/stub.h"
28 int is_skas_winch(int pid, int fd, void *data)
30 if (pid != getpgrp())
31 return 0;
33 register_winch_irq(-1, fd, -1, data, 0);
34 return 1;
37 static int ptrace_dump_regs(int pid)
39 unsigned long regs[MAX_REG_NR];
40 int i;
42 if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
43 return -errno;
45 printk(UM_KERN_ERR "Stub registers -\n");
46 for (i = 0; i < ARRAY_SIZE(regs); i++)
47 printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]);
49 return 0;
53 * Signals that are OK to receive in the stub - we'll just continue it.
54 * SIGWINCH will happen when UML is inside a detached screen.
56 #define STUB_SIG_MASK ((1 << SIGVTALRM) | (1 << SIGWINCH))
58 /* Signals that the stub will finish with - anything else is an error */
59 #define STUB_DONE_MASK (1 << SIGTRAP)
61 void wait_stub_done(int pid)
63 int n, status, err;
65 while (1) {
66 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
67 if ((n < 0) || !WIFSTOPPED(status))
68 goto bad_wait;
70 if (((1 << WSTOPSIG(status)) & STUB_SIG_MASK) == 0)
71 break;
73 err = ptrace(PTRACE_CONT, pid, 0, 0);
74 if (err) {
75 printk(UM_KERN_ERR "wait_stub_done : continue failed, "
76 "errno = %d\n", errno);
77 fatal_sigsegv();
81 if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0)
82 return;
84 bad_wait:
85 err = ptrace_dump_regs(pid);
86 if (err)
87 printk(UM_KERN_ERR "Failed to get registers from stub, "
88 "errno = %d\n", -err);
89 printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, "
90 "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno,
91 status);
92 fatal_sigsegv();
95 extern unsigned long current_stub_stack(void);
97 static void get_skas_faultinfo(int pid, struct faultinfo *fi)
99 int err;
101 if (ptrace_faultinfo) {
102 err = ptrace(PTRACE_FAULTINFO, pid, 0, fi);
103 if (err) {
104 printk(UM_KERN_ERR "get_skas_faultinfo - "
105 "PTRACE_FAULTINFO failed, errno = %d\n", errno);
106 fatal_sigsegv();
109 /* Special handling for i386, which has different structs */
110 if (sizeof(struct ptrace_faultinfo) < sizeof(struct faultinfo))
111 memset((char *)fi + sizeof(struct ptrace_faultinfo), 0,
112 sizeof(struct faultinfo) -
113 sizeof(struct ptrace_faultinfo));
115 else {
116 unsigned long fpregs[FP_SIZE];
118 err = get_fp_registers(pid, fpregs);
119 if (err < 0) {
120 printk(UM_KERN_ERR "save_fp_registers returned %d\n",
121 err);
122 fatal_sigsegv();
124 err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV);
125 if (err) {
126 printk(UM_KERN_ERR "Failed to continue stub, pid = %d, "
127 "errno = %d\n", pid, errno);
128 fatal_sigsegv();
130 wait_stub_done(pid);
133 * faultinfo is prepared by the stub-segv-handler at start of
134 * the stub stack page. We just have to copy it.
136 memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
138 err = put_fp_registers(pid, fpregs);
139 if (err < 0) {
140 printk(UM_KERN_ERR "put_fp_registers returned %d\n",
141 err);
142 fatal_sigsegv();
147 static void handle_segv(int pid, struct uml_pt_regs * regs)
149 get_skas_faultinfo(pid, &regs->faultinfo);
150 segv(regs->faultinfo, 0, 1, NULL);
154 * To use the same value of using_sysemu as the caller, ask it that value
155 * (in local_using_sysemu
157 static void handle_trap(int pid, struct uml_pt_regs *regs,
158 int local_using_sysemu)
160 int err, status;
162 if ((UPT_IP(regs) >= STUB_START) && (UPT_IP(regs) < STUB_END))
163 fatal_sigsegv();
165 /* Mark this as a syscall */
166 UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->gp);
168 if (!local_using_sysemu)
170 err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
171 __NR_getpid);
172 if (err < 0) {
173 printk(UM_KERN_ERR "handle_trap - nullifying syscall "
174 "failed, errno = %d\n", errno);
175 fatal_sigsegv();
178 err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
179 if (err < 0) {
180 printk(UM_KERN_ERR "handle_trap - continuing to end of "
181 "syscall failed, errno = %d\n", errno);
182 fatal_sigsegv();
185 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
186 if ((err < 0) || !WIFSTOPPED(status) ||
187 (WSTOPSIG(status) != SIGTRAP + 0x80)) {
188 err = ptrace_dump_regs(pid);
189 if (err)
190 printk(UM_KERN_ERR "Failed to get registers "
191 "from process, errno = %d\n", -err);
192 printk(UM_KERN_ERR "handle_trap - failed to wait at "
193 "end of syscall, errno = %d, status = %d\n",
194 errno, status);
195 fatal_sigsegv();
199 handle_syscall(regs);
202 extern int __syscall_stub_start;
204 static int userspace_tramp(void *stack)
206 void *addr;
207 int err;
209 ptrace(PTRACE_TRACEME, 0, 0, 0);
211 signal(SIGTERM, SIG_DFL);
212 signal(SIGWINCH, SIG_IGN);
213 err = set_interval();
214 if (err) {
215 printk(UM_KERN_ERR "userspace_tramp - setting timer failed, "
216 "errno = %d\n", err);
217 exit(1);
220 if (!proc_mm) {
222 * This has a pte, but it can't be mapped in with the usual
223 * tlb_flush mechanism because this is part of that mechanism
225 int fd;
226 unsigned long long offset;
227 fd = phys_mapping(to_phys(&__syscall_stub_start), &offset);
228 addr = mmap64((void *) STUB_CODE, UM_KERN_PAGE_SIZE,
229 PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset);
230 if (addr == MAP_FAILED) {
231 printk(UM_KERN_ERR "mapping mmap stub at 0x%lx failed, "
232 "errno = %d\n", STUB_CODE, errno);
233 exit(1);
236 if (stack != NULL) {
237 fd = phys_mapping(to_phys(stack), &offset);
238 addr = mmap((void *) STUB_DATA,
239 UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
240 MAP_FIXED | MAP_SHARED, fd, offset);
241 if (addr == MAP_FAILED) {
242 printk(UM_KERN_ERR "mapping segfault stack "
243 "at 0x%lx failed, errno = %d\n",
244 STUB_DATA, errno);
245 exit(1);
249 if (!ptrace_faultinfo && (stack != NULL)) {
250 struct sigaction sa;
252 unsigned long v = STUB_CODE +
253 (unsigned long) stub_segv_handler -
254 (unsigned long) &__syscall_stub_start;
256 set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE);
257 sigemptyset(&sa.sa_mask);
258 sa.sa_flags = SA_ONSTACK | SA_NODEFER | SA_SIGINFO;
259 sa.sa_sigaction = (void *) v;
260 sa.sa_restorer = NULL;
261 if (sigaction(SIGSEGV, &sa, NULL) < 0) {
262 printk(UM_KERN_ERR "userspace_tramp - setting SIGSEGV "
263 "handler failed - errno = %d\n", errno);
264 exit(1);
268 kill(os_getpid(), SIGSTOP);
269 return 0;
272 /* Each element set once, and only accessed by a single processor anyway */
273 #undef NR_CPUS
274 #define NR_CPUS 1
275 int userspace_pid[NR_CPUS];
277 int start_userspace(unsigned long stub_stack)
279 void *stack;
280 unsigned long sp;
281 int pid, status, n, flags, err;
283 stack = mmap(NULL, UM_KERN_PAGE_SIZE,
284 PROT_READ | PROT_WRITE | PROT_EXEC,
285 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
286 if (stack == MAP_FAILED) {
287 err = -errno;
288 printk(UM_KERN_ERR "start_userspace : mmap failed, "
289 "errno = %d\n", errno);
290 return err;
293 sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
295 flags = CLONE_FILES;
296 if (proc_mm)
297 flags |= CLONE_VM;
298 else
299 flags |= SIGCHLD;
301 pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack);
302 if (pid < 0) {
303 err = -errno;
304 printk(UM_KERN_ERR "start_userspace : clone failed, "
305 "errno = %d\n", errno);
306 return err;
309 do {
310 CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
311 if (n < 0) {
312 err = -errno;
313 printk(UM_KERN_ERR "start_userspace : wait failed, "
314 "errno = %d\n", errno);
315 goto out_kill;
317 } while (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM));
319 if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) {
320 err = -EINVAL;
321 printk(UM_KERN_ERR "start_userspace : expected SIGSTOP, got "
322 "status = %d\n", status);
323 goto out_kill;
326 if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
327 (void *) PTRACE_O_TRACESYSGOOD) < 0) {
328 err = -errno;
329 printk(UM_KERN_ERR "start_userspace : PTRACE_OLDSETOPTIONS "
330 "failed, errno = %d\n", errno);
331 goto out_kill;
334 if (munmap(stack, UM_KERN_PAGE_SIZE) < 0) {
335 err = -errno;
336 printk(UM_KERN_ERR "start_userspace : munmap failed, "
337 "errno = %d\n", errno);
338 goto out_kill;
341 return pid;
343 out_kill:
344 os_kill_ptraced_process(pid, 1);
345 return err;
348 void userspace(struct uml_pt_regs *regs)
350 struct itimerval timer;
351 unsigned long long nsecs, now;
352 int err, status, op, pid = userspace_pid[0];
353 /* To prevent races if using_sysemu changes under us.*/
354 int local_using_sysemu;
356 if (getitimer(ITIMER_VIRTUAL, &timer))
357 printk(UM_KERN_ERR "Failed to get itimer, errno = %d\n", errno);
358 nsecs = timer.it_value.tv_sec * UM_NSEC_PER_SEC +
359 timer.it_value.tv_usec * UM_NSEC_PER_USEC;
360 nsecs += os_nsecs();
362 while (1) {
364 * This can legitimately fail if the process loads a
365 * bogus value into a segment register. It will
366 * segfault and PTRACE_GETREGS will read that value
367 * out of the process. However, PTRACE_SETREGS will
368 * fail. In this case, there is nothing to do but
369 * just kill the process.
371 if (ptrace(PTRACE_SETREGS, pid, 0, regs->gp))
372 fatal_sigsegv();
374 if (put_fp_registers(pid, regs->fp))
375 fatal_sigsegv();
377 /* Now we set local_using_sysemu to be used for one loop */
378 local_using_sysemu = get_using_sysemu();
380 op = SELECT_PTRACE_OPERATION(local_using_sysemu,
381 singlestepping(NULL));
383 if (ptrace(op, pid, 0, 0)) {
384 printk(UM_KERN_ERR "userspace - ptrace continue "
385 "failed, op = %d, errno = %d\n", op, errno);
386 fatal_sigsegv();
389 CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
390 if (err < 0) {
391 printk(UM_KERN_ERR "userspace - wait failed, "
392 "errno = %d\n", errno);
393 fatal_sigsegv();
396 regs->is_user = 1;
397 if (ptrace(PTRACE_GETREGS, pid, 0, regs->gp)) {
398 printk(UM_KERN_ERR "userspace - PTRACE_GETREGS failed, "
399 "errno = %d\n", errno);
400 fatal_sigsegv();
403 if (get_fp_registers(pid, regs->fp)) {
404 printk(UM_KERN_ERR "userspace - get_fp_registers failed, "
405 "errno = %d\n", errno);
406 fatal_sigsegv();
409 UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */
411 if (WIFSTOPPED(status)) {
412 int sig = WSTOPSIG(status);
413 switch (sig) {
414 case SIGSEGV:
415 if (PTRACE_FULL_FAULTINFO ||
416 !ptrace_faultinfo) {
417 get_skas_faultinfo(pid,
418 &regs->faultinfo);
419 (*sig_info[SIGSEGV])(SIGSEGV, regs);
421 else handle_segv(pid, regs);
422 break;
423 case SIGTRAP + 0x80:
424 handle_trap(pid, regs, local_using_sysemu);
425 break;
426 case SIGTRAP:
427 relay_signal(SIGTRAP, regs);
428 break;
429 case SIGVTALRM:
430 now = os_nsecs();
431 if (now < nsecs)
432 break;
433 block_signals();
434 (*sig_info[sig])(sig, regs);
435 unblock_signals();
436 nsecs = timer.it_value.tv_sec *
437 UM_NSEC_PER_SEC +
438 timer.it_value.tv_usec *
439 UM_NSEC_PER_USEC;
440 nsecs += os_nsecs();
441 break;
442 case SIGIO:
443 case SIGILL:
444 case SIGBUS:
445 case SIGFPE:
446 case SIGWINCH:
447 block_signals();
448 (*sig_info[sig])(sig, regs);
449 unblock_signals();
450 break;
451 default:
452 printk(UM_KERN_ERR "userspace - child stopped "
453 "with signal %d\n", sig);
454 fatal_sigsegv();
456 pid = userspace_pid[0];
457 interrupt_end();
459 /* Avoid -ERESTARTSYS handling in host */
460 if (PT_SYSCALL_NR_OFFSET != PT_SYSCALL_RET_OFFSET)
461 PT_SYSCALL_NR(regs->gp) = -1;
466 static unsigned long thread_regs[MAX_REG_NR];
467 static unsigned long thread_fp_regs[FP_SIZE];
469 static int __init init_thread_regs(void)
471 get_safe_registers(thread_regs, thread_fp_regs);
472 /* Set parent's instruction pointer to start of clone-stub */
473 thread_regs[REGS_IP_INDEX] = STUB_CODE +
474 (unsigned long) stub_clone_handler -
475 (unsigned long) &__syscall_stub_start;
476 thread_regs[REGS_SP_INDEX] = STUB_DATA + UM_KERN_PAGE_SIZE -
477 sizeof(void *);
478 #ifdef __SIGNAL_FRAMESIZE
479 thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE;
480 #endif
481 return 0;
484 __initcall(init_thread_regs);
486 int copy_context_skas0(unsigned long new_stack, int pid)
488 struct timeval tv = { .tv_sec = 0, .tv_usec = UM_USEC_PER_SEC / UM_HZ };
489 int err;
490 unsigned long current_stack = current_stub_stack();
491 struct stub_data *data = (struct stub_data *) current_stack;
492 struct stub_data *child_data = (struct stub_data *) new_stack;
493 unsigned long long new_offset;
494 int new_fd = phys_mapping(to_phys((void *)new_stack), &new_offset);
497 * prepare offset and fd of child's stack as argument for parent's
498 * and child's mmap2 calls
500 *data = ((struct stub_data) { .offset = MMAP_OFFSET(new_offset),
501 .fd = new_fd,
502 .timer = ((struct itimerval)
503 { .it_value = tv,
504 .it_interval = tv }) });
506 err = ptrace_setregs(pid, thread_regs);
507 if (err < 0) {
508 err = -errno;
509 printk(UM_KERN_ERR "copy_context_skas0 : PTRACE_SETREGS "
510 "failed, pid = %d, errno = %d\n", pid, -err);
511 return err;
514 err = put_fp_registers(pid, thread_fp_regs);
515 if (err < 0) {
516 printk(UM_KERN_ERR "copy_context_skas0 : put_fp_registers "
517 "failed, pid = %d, err = %d\n", pid, err);
518 return err;
521 /* set a well known return code for detection of child write failure */
522 child_data->err = 12345678;
525 * Wait, until parent has finished its work: read child's pid from
526 * parent's stack, and check, if bad result.
528 err = ptrace(PTRACE_CONT, pid, 0, 0);
529 if (err) {
530 err = -errno;
531 printk(UM_KERN_ERR "Failed to continue new process, pid = %d, "
532 "errno = %d\n", pid, errno);
533 return err;
536 wait_stub_done(pid);
538 pid = data->err;
539 if (pid < 0) {
540 printk(UM_KERN_ERR "copy_context_skas0 - stub-parent reports "
541 "error %d\n", -pid);
542 return pid;
546 * Wait, until child has finished too: read child's result from
547 * child's stack and check it.
549 wait_stub_done(pid);
550 if (child_data->err != STUB_DATA) {
551 printk(UM_KERN_ERR "copy_context_skas0 - stub-child reports "
552 "error %ld\n", child_data->err);
553 err = child_data->err;
554 goto out_kill;
557 if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL,
558 (void *)PTRACE_O_TRACESYSGOOD) < 0) {
559 err = -errno;
560 printk(UM_KERN_ERR "copy_context_skas0 : PTRACE_OLDSETOPTIONS "
561 "failed, errno = %d\n", errno);
562 goto out_kill;
565 return pid;
567 out_kill:
568 os_kill_ptraced_process(pid, 1);
569 return err;
573 * This is used only, if stub pages are needed, while proc_mm is
574 * available. Opening /proc/mm creates a new mm_context, which lacks
575 * the stub-pages. Thus, we map them using /proc/mm-fd
577 int map_stub_pages(int fd, unsigned long code, unsigned long data,
578 unsigned long stack)
580 struct proc_mm_op mmop;
581 int n;
582 unsigned long long code_offset;
583 int code_fd = phys_mapping(to_phys((void *) &__syscall_stub_start),
584 &code_offset);
586 mmop = ((struct proc_mm_op) { .op = MM_MMAP,
587 .u =
588 { .mmap =
589 { .addr = code,
590 .len = UM_KERN_PAGE_SIZE,
591 .prot = PROT_EXEC,
592 .flags = MAP_FIXED | MAP_PRIVATE,
593 .fd = code_fd,
594 .offset = code_offset
595 } } });
596 CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
597 if (n != sizeof(mmop)) {
598 n = errno;
599 printk(UM_KERN_ERR "mmap args - addr = 0x%lx, fd = %d, "
600 "offset = %llx\n", code, code_fd,
601 (unsigned long long) code_offset);
602 printk(UM_KERN_ERR "map_stub_pages : /proc/mm map for code "
603 "failed, err = %d\n", n);
604 return -n;
607 if (stack) {
608 unsigned long long map_offset;
609 int map_fd = phys_mapping(to_phys((void *)stack), &map_offset);
610 mmop = ((struct proc_mm_op)
611 { .op = MM_MMAP,
612 .u =
613 { .mmap =
614 { .addr = data,
615 .len = UM_KERN_PAGE_SIZE,
616 .prot = PROT_READ | PROT_WRITE,
617 .flags = MAP_FIXED | MAP_SHARED,
618 .fd = map_fd,
619 .offset = map_offset
620 } } });
621 CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
622 if (n != sizeof(mmop)) {
623 n = errno;
624 printk(UM_KERN_ERR "map_stub_pages : /proc/mm map for "
625 "data failed, err = %d\n", n);
626 return -n;
630 return 0;
633 void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
635 (*buf)[0].JB_IP = (unsigned long) handler;
636 (*buf)[0].JB_SP = (unsigned long) stack + UM_THREAD_SIZE -
637 sizeof(void *);
640 #define INIT_JMP_NEW_THREAD 0
641 #define INIT_JMP_CALLBACK 1
642 #define INIT_JMP_HALT 2
643 #define INIT_JMP_REBOOT 3
645 void switch_threads(jmp_buf *me, jmp_buf *you)
647 if (UML_SETJMP(me) == 0)
648 UML_LONGJMP(you, 1);
651 static jmp_buf initial_jmpbuf;
653 /* XXX Make these percpu */
654 static void (*cb_proc)(void *arg);
655 static void *cb_arg;
656 static jmp_buf *cb_back;
658 int start_idle_thread(void *stack, jmp_buf *switch_buf)
660 int n;
662 set_handler(SIGWINCH, (__sighandler_t) sig_handler,
663 SA_ONSTACK | SA_RESTART, SIGIO, SIGVTALRM, -1);
666 * Can't use UML_SETJMP or UML_LONGJMP here because they save
667 * and restore signals, with the possible side-effect of
668 * trying to handle any signals which came when they were
669 * blocked, which can't be done on this stack.
670 * Signals must be blocked when jumping back here and restored
671 * after returning to the jumper.
673 n = setjmp(initial_jmpbuf);
674 switch (n) {
675 case INIT_JMP_NEW_THREAD:
676 (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler;
677 (*switch_buf)[0].JB_SP = (unsigned long) stack +
678 UM_THREAD_SIZE - sizeof(void *);
679 break;
680 case INIT_JMP_CALLBACK:
681 (*cb_proc)(cb_arg);
682 longjmp(*cb_back, 1);
683 break;
684 case INIT_JMP_HALT:
685 kmalloc_ok = 0;
686 return 0;
687 case INIT_JMP_REBOOT:
688 kmalloc_ok = 0;
689 return 1;
690 default:
691 printk(UM_KERN_ERR "Bad sigsetjmp return in "
692 "start_idle_thread - %d\n", n);
693 fatal_sigsegv();
695 longjmp(*switch_buf, 1);
698 void initial_thread_cb_skas(void (*proc)(void *), void *arg)
700 jmp_buf here;
702 cb_proc = proc;
703 cb_arg = arg;
704 cb_back = &here;
706 block_signals();
707 if (UML_SETJMP(&here) == 0)
708 UML_LONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK);
709 unblock_signals();
711 cb_proc = NULL;
712 cb_arg = NULL;
713 cb_back = NULL;
716 void halt_skas(void)
718 block_signals();
719 UML_LONGJMP(&initial_jmpbuf, INIT_JMP_HALT);
722 void reboot_skas(void)
724 block_signals();
725 UML_LONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT);
728 void __switch_mm(struct mm_id *mm_idp)
730 int err;
732 /* FIXME: need cpu pid in __switch_mm */
733 if (proc_mm) {
734 err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0,
735 mm_idp->u.mm_fd);
736 if (err) {
737 printk(UM_KERN_ERR "__switch_mm - PTRACE_SWITCH_MM "
738 "failed, errno = %d\n", errno);
739 fatal_sigsegv();
742 else userspace_pid[0] = mm_idp->u.pid;