uml: don't try to handle signals on initial process stack
[powerpc.git] / arch / um / os-Linux / skas / process.c
index 41bf8d1..1f39f2b 100644 (file)
@@ -409,7 +409,7 @@ int copy_context_skas0(unsigned long new_stack, int pid)
 
 /*
  * This is used only, if stub pages are needed, while proc_mm is
- * availabl. Opening /proc/mm creates a new mm_context, which lacks
+ * available. Opening /proc/mm creates a new mm_context, which lacks
  * the stub-pages. Thus, we map them using /proc/mm-fd
  */
 void map_stub_pages(int fd, unsigned long code,
@@ -431,12 +431,13 @@ void map_stub_pages(int fd, unsigned long code,
                                          .fd      = code_fd,
                                          .offset  = code_offset
        } } });
-       n = os_write_file(fd, &mmop, sizeof(mmop));
+       CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
        if(n != sizeof(mmop)){
+               n = errno;
                printk("mmap args - addr = 0x%lx, fd = %d, offset = %llx\n",
                       code, code_fd, (unsigned long long) code_offset);
                panic("map_stub_pages : /proc/mm map for code failed, "
-                     "err = %d\n", -n);
+                     "err = %d\n", n);
        }
 
        if ( stack ) {
@@ -453,10 +454,10 @@ void map_stub_pages(int fd, unsigned long code,
                                      .fd      = map_fd,
                                      .offset  = map_offset
                } } });
-               n = os_write_file(fd, &mmop, sizeof(mmop));
+               CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop)));
                if(n != sizeof(mmop))
                        panic("map_stub_pages : /proc/mm map for data failed, "
-                             "err = %d\n", -n);
+                             "err = %d\n", errno);
        }
 }
 
@@ -493,7 +494,15 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
                    SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM,
                    SIGVTALRM, -1);
 
-       n = UML_SETJMP(&initial_jmpbuf);
+       /*
+        * Can't use UML_SETJMP or UML_LONGJMP here because they save
+        * and restore signals, with the possible side-effect of
+        * trying to handle any signals which came when they were
+        * blocked, which can't be done on this stack.
+        * Signals must be blocked when jumping back here and restored
+        * after returning to the jumper.
+        */
+       n = setjmp(initial_jmpbuf);
        switch(n){
        case INIT_JMP_NEW_THREAD:
                (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler;
@@ -503,7 +512,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
                break;
        case INIT_JMP_CALLBACK:
                (*cb_proc)(cb_arg);
-               UML_LONGJMP(cb_back, 1);
+               longjmp(*cb_back, 1);
                break;
        case INIT_JMP_HALT:
                kmalloc_ok = 0;
@@ -514,7 +523,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
        default:
                panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
        }
-       UML_LONGJMP(switch_buf, 1);
+       longjmp(*switch_buf, 1);
 }
 
 void initial_thread_cb_skas(void (*proc)(void *), void *arg)