diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-09-27 04:50:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-27 11:26:16 -0400 |
commit | 3c9173509985b957bea692ea887a8a0e5055cfe8 (patch) | |
tree | 9406fb650d6085f992b6d2a0a3fd8763b045cc35 /include/asm-um | |
parent | 0915ee38c7db57ff41a7a68bcc02d0dd3b7b849b (diff) |
[PATCH] uml: thread creation tidying
fork on UML has always somewhat subtle. The underlying cause has been the
need to initialize a stack for the new process. The only portable way to
initialize a new stack is to set it as the alternate signal stack and take a
signal. The signal handler does whatever initialization is needed and jumps
back to the original stack, where the fork processing is finished. The basic
context switching mechanism is a jmp_buf for each process. You switch to a
new process by longjmping to its jmp_buf.
Now that UML has its own implementation of setjmp and longjmp, and I can poke
around inside a jmp_buf without fear that libc will change the structure, a
much simpler mechanism is possible. The jmpbuf can simply be initialized by
hand.
This eliminates -
the need to set up and remove the alternate signal stack
sending and handling a signal
the signal blocking needed around the stack switching, since
there is no stack switching
setting up the jmp_buf needed to jump back to the original
stack after the new one is set up
In addition, since jmp_buf is now defined by UML, and not by libc, it can be
embedded in the thread struct. This makes it unnecessary to have it exist on
the stack, where it used to be. It also simplifies interfaces, since the
switch jmp_buf used to be a void * inside the thread struct, and functions
which took it as an argument needed to define a jmp_buf variable and assign it
from the void *.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-um')
-rw-r--r-- | include/asm-um/processor-generic.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/asm-um/processor-generic.h b/include/asm-um/processor-generic.h index afa4fe1ca9f1..d99bbddffdb9 100644 --- a/include/asm-um/processor-generic.h +++ b/include/asm-um/processor-generic.h | |||
@@ -13,6 +13,7 @@ struct task_struct; | |||
13 | #include "asm/ptrace.h" | 13 | #include "asm/ptrace.h" |
14 | #include "choose-mode.h" | 14 | #include "choose-mode.h" |
15 | #include "registers.h" | 15 | #include "registers.h" |
16 | #include "sysdep/archsetjmp.h" | ||
16 | 17 | ||
17 | struct mm_struct; | 18 | struct mm_struct; |
18 | 19 | ||
@@ -43,8 +44,7 @@ struct thread_struct { | |||
43 | #endif | 44 | #endif |
44 | #ifdef CONFIG_MODE_SKAS | 45 | #ifdef CONFIG_MODE_SKAS |
45 | struct { | 46 | struct { |
46 | void *switch_buf; | 47 | jmp_buf switch_buf; |
47 | void *fork_buf; | ||
48 | int mm_count; | 48 | int mm_count; |
49 | } skas; | 49 | } skas; |
50 | #endif | 50 | #endif |
@@ -138,7 +138,7 @@ extern struct cpuinfo_um cpu_data[]; | |||
138 | 138 | ||
139 | #ifdef CONFIG_MODE_SKAS | 139 | #ifdef CONFIG_MODE_SKAS |
140 | #define KSTK_REG(tsk, reg) \ | 140 | #define KSTK_REG(tsk, reg) \ |
141 | get_thread_reg(reg, tsk->thread.mode.skas.switch_buf) | 141 | get_thread_reg(reg, &tsk->thread.mode.skas.switch_buf) |
142 | #else | 142 | #else |
143 | #define KSTK_REG(tsk, reg) (0xbadbabe) | 143 | #define KSTK_REG(tsk, reg) (0xbadbabe) |
144 | #endif | 144 | #endif |