diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2006-03-31 05:30:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-31 15:18:52 -0500 |
commit | aa6758d4867cd07bd76105ade6177fe6148e559a (patch) | |
tree | 0053f855c885a6dc322337468a2c45b6b2f8ddd0 /arch/um/kernel | |
parent | 972410b0232e97609fcefc8e408fe3037fcd607b (diff) |
[PATCH] uml: implement {get,set}_thread_area for i386
Implement sys_[gs]et_thread_area and the corresponding ptrace operations for
UML. This is the main chunk, additional parts follow. This implementation is
now well tested and has run reliably for some time, and we've understood all
the previously existing problems.
Their implementation saves the new GDT content and then forwards the call to
the host when appropriate, i.e. immediately when the target process is
running or on context switch otherwise (i.e. on fork and on ptrace() calls).
In SKAS mode, we must switch registers on each context switch (because SKAS
does not switches tls_array together with current->mm).
Also, added get_cpu() locking; this has been done for SKAS mode, since TT does
not need it (it does not use smp_processor_id()).
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r-- | arch/um/kernel/exec_kern.c | 12 | ||||
-rw-r--r-- | arch/um/kernel/process_kern.c | 20 | ||||
-rw-r--r-- | arch/um/kernel/ptrace.c | 10 | ||||
-rw-r--r-- | arch/um/kernel/skas/process_kern.c | 2 |
4 files changed, 31 insertions, 13 deletions
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c index f9b346e05b00..c0cb627bf594 100644 --- a/arch/um/kernel/exec_kern.c +++ b/arch/um/kernel/exec_kern.c | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | void flush_thread(void) | 23 | void flush_thread(void) |
24 | { | 24 | { |
25 | arch_flush_thread(¤t->thread.arch); | ||
25 | CHOOSE_MODE(flush_thread_tt(), flush_thread_skas()); | 26 | CHOOSE_MODE(flush_thread_tt(), flush_thread_skas()); |
26 | } | 27 | } |
27 | 28 | ||
@@ -74,14 +75,3 @@ long sys_execve(char __user *file, char __user *__user *argv, | |||
74 | unlock_kernel(); | 75 | unlock_kernel(); |
75 | return(error); | 76 | return(error); |
76 | } | 77 | } |
77 | |||
78 | /* | ||
79 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
80 | * Emacs will notice this stuff at the end of the file and automatically | ||
81 | * adjust the settings for this buffer only. This must remain at the end | ||
82 | * of the file. | ||
83 | * --------------------------------------------------------------------------- | ||
84 | * Local variables: | ||
85 | * c-file-style: "linux" | ||
86 | * End: | ||
87 | */ | ||
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index ba8a52c1f7ae..f6a5a502120b 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c | |||
@@ -156,9 +156,25 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, | |||
156 | unsigned long stack_top, struct task_struct * p, | 156 | unsigned long stack_top, struct task_struct * p, |
157 | struct pt_regs *regs) | 157 | struct pt_regs *regs) |
158 | { | 158 | { |
159 | int ret; | ||
160 | |||
159 | p->thread = (struct thread_struct) INIT_THREAD; | 161 | p->thread = (struct thread_struct) INIT_THREAD; |
160 | return(CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr, | 162 | ret = CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr, |
161 | clone_flags, sp, stack_top, p, regs)); | 163 | clone_flags, sp, stack_top, p, regs); |
164 | |||
165 | if (ret || !current->thread.forking) | ||
166 | goto out; | ||
167 | |||
168 | clear_flushed_tls(p); | ||
169 | |||
170 | /* | ||
171 | * Set a new TLS for the child thread? | ||
172 | */ | ||
173 | if (clone_flags & CLONE_SETTLS) | ||
174 | ret = arch_copy_tls(p); | ||
175 | |||
176 | out: | ||
177 | return ret; | ||
162 | } | 178 | } |
163 | 179 | ||
164 | void initial_thread_cb(void (*proc)(void *), void *arg) | 180 | void initial_thread_cb(void (*proc)(void *), void *arg) |
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c index 394582202ce6..60d2eda995c1 100644 --- a/arch/um/kernel/ptrace.c +++ b/arch/um/kernel/ptrace.c | |||
@@ -185,6 +185,16 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
185 | ret = set_fpxregs(data, child); | 185 | ret = set_fpxregs(data, child); |
186 | break; | 186 | break; |
187 | #endif | 187 | #endif |
188 | case PTRACE_GET_THREAD_AREA: | ||
189 | ret = ptrace_get_thread_area(child, addr, | ||
190 | (struct user_desc __user *) data); | ||
191 | break; | ||
192 | |||
193 | case PTRACE_SET_THREAD_AREA: | ||
194 | ret = ptrace_set_thread_area(child, addr, | ||
195 | (struct user_desc __user *) data); | ||
196 | break; | ||
197 | |||
188 | case PTRACE_FAULTINFO: { | 198 | case PTRACE_FAULTINFO: { |
189 | /* Take the info from thread->arch->faultinfo, | 199 | /* Take the info from thread->arch->faultinfo, |
190 | * but transfer max. sizeof(struct ptrace_faultinfo). | 200 | * but transfer max. sizeof(struct ptrace_faultinfo). |
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c index 14360ac17f02..38b185370c42 100644 --- a/arch/um/kernel/skas/process_kern.c +++ b/arch/um/kernel/skas/process_kern.c | |||
@@ -111,6 +111,8 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp, | |||
111 | if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp; | 111 | if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp; |
112 | 112 | ||
113 | handler = fork_handler; | 113 | handler = fork_handler; |
114 | |||
115 | arch_copy_thread(¤t->thread.arch, &p->thread.arch); | ||
114 | } | 116 | } |
115 | else { | 117 | else { |
116 | init_thread_registers(&p->thread.regs.regs); | 118 | init_thread_registers(&p->thread.regs.regs); |