diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 04:27:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:05 -0400 |
commit | ba180fd437156f7fd8cfb2fdd021d949eeef08d6 (patch) | |
tree | b9f38b9cdd7a5b1aacf00341d1948314663c5871 /arch/um/os-Linux/skas/process.c | |
parent | 77bf4400319db9d2a8af6b00c2be6faa0f3d07cb (diff) |
uml: style fixes pass 3
Formatting changes in the files which have been changed in the course
of folding foo_skas functions into their callers. These include:
copyright updates
header file trimming
style fixes
adding severity to printks
These changes should be entirely non-functional.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/os-Linux/skas/process.c')
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 229 |
1 files changed, 117 insertions, 112 deletions
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index eb027673f357..e12d18cc77da 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -1,48 +1,38 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002- 2004 Jeff Dike (jdike@addtoit.com) | 2 | * Copyright (C) 2002- 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <string.h> | ||
8 | #include <unistd.h> | 7 | #include <unistd.h> |
9 | #include <errno.h> | ||
10 | #include <signal.h> | ||
11 | #include <sched.h> | 8 | #include <sched.h> |
12 | #include "ptrace_user.h" | 9 | #include <errno.h> |
13 | #include <sys/wait.h> | 10 | #include <string.h> |
14 | #include <sys/mman.h> | 11 | #include <sys/mman.h> |
15 | #include <sys/user.h> | 12 | #include <sys/ptrace.h> |
16 | #include <sys/time.h> | 13 | #include <sys/wait.h> |
17 | #include <sys/syscall.h> | 14 | #include <asm/unistd.h> |
18 | #include <asm/types.h> | 15 | #include "as-layout.h" |
19 | #include "user.h" | ||
20 | #include "sysdep/ptrace.h" | ||
21 | #include "kern_util.h" | ||
22 | #include "skas.h" | ||
23 | #include "stub-data.h" | ||
24 | #include "mm_id.h" | ||
25 | #include "sysdep/sigcontext.h" | ||
26 | #include "sysdep/stub.h" | ||
27 | #include "os.h" | ||
28 | #include "proc_mm.h" | ||
29 | #include "skas_ptrace.h" | ||
30 | #include "chan_user.h" | 16 | #include "chan_user.h" |
31 | #include "registers.h" | 17 | #include "kern_constants.h" |
32 | #include "mem.h" | 18 | #include "mem.h" |
33 | #include "uml-config.h" | 19 | #include "os.h" |
34 | #include "process.h" | 20 | #include "process.h" |
35 | #include "longjmp.h" | 21 | #include "proc_mm.h" |
36 | #include "kern_constants.h" | 22 | #include "ptrace_user.h" |
37 | #include "as-layout.h" | 23 | #include "registers.h" |
24 | #include "skas.h" | ||
25 | #include "skas_ptrace.h" | ||
26 | #include "user.h" | ||
27 | #include "sysdep/stub.h" | ||
38 | 28 | ||
39 | int is_skas_winch(int pid, int fd, void *data) | 29 | int is_skas_winch(int pid, int fd, void *data) |
40 | { | 30 | { |
41 | if(pid != os_getpgrp()) | 31 | if (pid != os_getpgrp()) |
42 | return(0); | 32 | return 0; |
43 | 33 | ||
44 | register_winch_irq(-1, fd, -1, data, 0); | 34 | register_winch_irq(-1, fd, -1, data, 0); |
45 | return(1); | 35 | return 1; |
46 | } | 36 | } |
47 | 37 | ||
48 | static int ptrace_dump_regs(int pid) | 38 | static int ptrace_dump_regs(int pid) |
@@ -50,13 +40,12 @@ static int ptrace_dump_regs(int pid) | |||
50 | unsigned long regs[MAX_REG_NR]; | 40 | unsigned long regs[MAX_REG_NR]; |
51 | int i; | 41 | int i; |
52 | 42 | ||
53 | if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) | 43 | if (ptrace(PTRACE_GETREGS, pid, 0, regs) < 0) |
54 | return -errno; | 44 | return -errno; |
55 | else { | 45 | |
56 | printk("Stub registers -\n"); | 46 | printk(UM_KERN_ERR "Stub registers -\n"); |
57 | for(i = 0; i < ARRAY_SIZE(regs); i++) | 47 | for (i = 0; i < ARRAY_SIZE(regs); i++) |
58 | printk("\t%d - %lx\n", i, regs[i]); | 48 | printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]); |
59 | } | ||
60 | 49 | ||
61 | return 0; | 50 | return 0; |
62 | } | 51 | } |
@@ -74,27 +63,28 @@ void wait_stub_done(int pid) | |||
74 | { | 63 | { |
75 | int n, status, err; | 64 | int n, status, err; |
76 | 65 | ||
77 | while(1){ | 66 | while (1) { |
78 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 67 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
79 | if((n < 0) || !WIFSTOPPED(status)) | 68 | if ((n < 0) || !WIFSTOPPED(status)) |
80 | goto bad_wait; | 69 | goto bad_wait; |
81 | 70 | ||
82 | if(((1 << WSTOPSIG(status)) & STUB_SIG_MASK) == 0) | 71 | if (((1 << WSTOPSIG(status)) & STUB_SIG_MASK) == 0) |
83 | break; | 72 | break; |
84 | 73 | ||
85 | err = ptrace(PTRACE_CONT, pid, 0, 0); | 74 | err = ptrace(PTRACE_CONT, pid, 0, 0); |
86 | if(err) | 75 | if (err) |
87 | panic("wait_stub_done : continue failed, errno = %d\n", | 76 | panic("wait_stub_done : continue failed, errno = %d\n", |
88 | errno); | 77 | errno); |
89 | } | 78 | } |
90 | 79 | ||
91 | if(((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) | 80 | if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) |
92 | return; | 81 | return; |
93 | 82 | ||
94 | bad_wait: | 83 | bad_wait: |
95 | err = ptrace_dump_regs(pid); | 84 | err = ptrace_dump_regs(pid); |
96 | if(err) | 85 | if (err) |
97 | printk("Failed to get registers from stub, errno = %d\n", -err); | 86 | printk(UM_KERN_ERR "Failed to get registers from stub, " |
87 | "errno = %d\n", -err); | ||
98 | panic("wait_stub_done : failed to wait for SIGUSR1/SIGTRAP, pid = %d, " | 88 | panic("wait_stub_done : failed to wait for SIGUSR1/SIGTRAP, pid = %d, " |
99 | "n = %d, errno = %d, status = 0x%x\n", pid, n, errno, status); | 89 | "n = %d, errno = %d, status = 0x%x\n", pid, n, errno, status); |
100 | } | 90 | } |
@@ -105,9 +95,9 @@ void get_skas_faultinfo(int pid, struct faultinfo * fi) | |||
105 | { | 95 | { |
106 | int err; | 96 | int err; |
107 | 97 | ||
108 | if(ptrace_faultinfo){ | 98 | if (ptrace_faultinfo) { |
109 | err = ptrace(PTRACE_FAULTINFO, pid, 0, fi); | 99 | err = ptrace(PTRACE_FAULTINFO, pid, 0, fi); |
110 | if(err) | 100 | if (err) |
111 | panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, " | 101 | panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, " |
112 | "errno = %d\n", errno); | 102 | "errno = %d\n", errno); |
113 | 103 | ||
@@ -119,12 +109,13 @@ void get_skas_faultinfo(int pid, struct faultinfo * fi) | |||
119 | } | 109 | } |
120 | else { | 110 | else { |
121 | err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV); | 111 | err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV); |
122 | if(err) | 112 | if (err) |
123 | panic("Failed to continue stub, pid = %d, errno = %d\n", | 113 | panic("Failed to continue stub, pid = %d, errno = %d\n", |
124 | pid, errno); | 114 | pid, errno); |
125 | wait_stub_done(pid); | 115 | wait_stub_done(pid); |
126 | 116 | ||
127 | /* faultinfo is prepared by the stub-segv-handler at start of | 117 | /* |
118 | * faultinfo is prepared by the stub-segv-handler at start of | ||
128 | * the stub stack page. We just have to copy it. | 119 | * the stub stack page. We just have to copy it. |
129 | */ | 120 | */ |
130 | memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); | 121 | memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); |
@@ -137,8 +128,12 @@ static void handle_segv(int pid, struct uml_pt_regs * regs) | |||
137 | segv(regs->faultinfo, 0, 1, NULL); | 128 | segv(regs->faultinfo, 0, 1, NULL); |
138 | } | 129 | } |
139 | 130 | ||
140 | /*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/ | 131 | /* |
141 | static void handle_trap(int pid, struct uml_pt_regs *regs, int local_using_sysemu) | 132 | * To use the same value of using_sysemu as the caller, ask it that value |
133 | * (in local_using_sysemu | ||
134 | */ | ||
135 | static void handle_trap(int pid, struct uml_pt_regs *regs, | ||
136 | int local_using_sysemu) | ||
142 | { | 137 | { |
143 | int err, status; | 138 | int err, status; |
144 | 139 | ||
@@ -149,22 +144,22 @@ static void handle_trap(int pid, struct uml_pt_regs *regs, int local_using_sysem | |||
149 | { | 144 | { |
150 | err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, | 145 | err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, |
151 | __NR_getpid); | 146 | __NR_getpid); |
152 | if(err < 0) | 147 | if (err < 0) |
153 | panic("handle_trap - nullifying syscall failed errno = %d\n", | 148 | panic("handle_trap - nullifying syscall failed, " |
154 | errno); | 149 | "errno = %d\n", errno); |
155 | 150 | ||
156 | err = ptrace(PTRACE_SYSCALL, pid, 0, 0); | 151 | err = ptrace(PTRACE_SYSCALL, pid, 0, 0); |
157 | if(err < 0) | 152 | if (err < 0) |
158 | panic("handle_trap - continuing to end of syscall failed, " | 153 | panic("handle_trap - continuing to end of syscall " |
159 | "errno = %d\n", errno); | 154 | "failed, errno = %d\n", errno); |
160 | 155 | ||
161 | CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); | 156 | CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); |
162 | if((err < 0) || !WIFSTOPPED(status) || | 157 | if ((err < 0) || !WIFSTOPPED(status) || |
163 | (WSTOPSIG(status) != SIGTRAP + 0x80)){ | 158 | (WSTOPSIG(status) != SIGTRAP + 0x80)) { |
164 | err = ptrace_dump_regs(pid); | 159 | err = ptrace_dump_regs(pid); |
165 | if(err) | 160 | if (err) |
166 | printk("Failed to get registers from process, " | 161 | printk(UM_KERN_ERR "Failed to get registers " |
167 | "errno = %d\n", -err); | 162 | "from process, errno = %d\n", -err); |
168 | panic("handle_trap - failed to wait at end of syscall, " | 163 | panic("handle_trap - failed to wait at end of syscall, " |
169 | "errno = %d, status = %d\n", errno, status); | 164 | "errno = %d, status = %d\n", errno, status); |
170 | } | 165 | } |
@@ -184,38 +179,39 @@ static int userspace_tramp(void *stack) | |||
184 | 179 | ||
185 | init_new_thread_signals(); | 180 | init_new_thread_signals(); |
186 | err = set_interval(1); | 181 | err = set_interval(1); |
187 | if(err) | 182 | if (err) |
188 | panic("userspace_tramp - setting timer failed, errno = %d\n", | 183 | panic("userspace_tramp - setting timer failed, errno = %d\n", |
189 | err); | 184 | err); |
190 | 185 | ||
191 | if(!proc_mm){ | 186 | if (!proc_mm) { |
192 | /* This has a pte, but it can't be mapped in with the usual | 187 | /* |
188 | * This has a pte, but it can't be mapped in with the usual | ||
193 | * tlb_flush mechanism because this is part of that mechanism | 189 | * tlb_flush mechanism because this is part of that mechanism |
194 | */ | 190 | */ |
195 | int fd; | 191 | int fd; |
196 | __u64 offset; | 192 | unsigned long long offset; |
197 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); | 193 | fd = phys_mapping(to_phys(&__syscall_stub_start), &offset); |
198 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, UM_KERN_PAGE_SIZE, | 194 | addr = mmap64((void *) UML_CONFIG_STUB_CODE, UM_KERN_PAGE_SIZE, |
199 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); | 195 | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, fd, offset); |
200 | if(addr == MAP_FAILED){ | 196 | if (addr == MAP_FAILED) { |
201 | printk("mapping mmap stub failed, errno = %d\n", | 197 | printk(UM_KERN_ERR "mapping mmap stub failed, " |
202 | errno); | 198 | "errno = %d\n", errno); |
203 | exit(1); | 199 | exit(1); |
204 | } | 200 | } |
205 | 201 | ||
206 | if(stack != NULL){ | 202 | if (stack != NULL) { |
207 | fd = phys_mapping(to_phys(stack), &offset); | 203 | fd = phys_mapping(to_phys(stack), &offset); |
208 | addr = mmap((void *) UML_CONFIG_STUB_DATA, | 204 | addr = mmap((void *) UML_CONFIG_STUB_DATA, |
209 | UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, | 205 | UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
210 | MAP_FIXED | MAP_SHARED, fd, offset); | 206 | MAP_FIXED | MAP_SHARED, fd, offset); |
211 | if(addr == MAP_FAILED){ | 207 | if (addr == MAP_FAILED) { |
212 | printk("mapping segfault stack failed, " | 208 | printk(UM_KERN_ERR "mapping segfault stack " |
213 | "errno = %d\n", errno); | 209 | "failed, errno = %d\n", errno); |
214 | exit(1); | 210 | exit(1); |
215 | } | 211 | } |
216 | } | 212 | } |
217 | } | 213 | } |
218 | if(!ptrace_faultinfo && (stack != NULL)){ | 214 | if (!ptrace_faultinfo && (stack != NULL)) { |
219 | struct sigaction sa; | 215 | struct sigaction sa; |
220 | 216 | ||
221 | unsigned long v = UML_CONFIG_STUB_CODE + | 217 | unsigned long v = UML_CONFIG_STUB_CODE + |
@@ -232,13 +228,13 @@ static int userspace_tramp(void *stack) | |||
232 | sa.sa_flags = SA_ONSTACK; | 228 | sa.sa_flags = SA_ONSTACK; |
233 | sa.sa_handler = (void *) v; | 229 | sa.sa_handler = (void *) v; |
234 | sa.sa_restorer = NULL; | 230 | sa.sa_restorer = NULL; |
235 | if(sigaction(SIGSEGV, &sa, NULL) < 0) | 231 | if (sigaction(SIGSEGV, &sa, NULL) < 0) |
236 | panic("userspace_tramp - setting SIGSEGV handler " | 232 | panic("userspace_tramp - setting SIGSEGV handler " |
237 | "failed - errno = %d\n", errno); | 233 | "failed - errno = %d\n", errno); |
238 | } | 234 | } |
239 | 235 | ||
240 | os_stop_process(os_getpid()); | 236 | os_stop_process(os_getpid()); |
241 | return(0); | 237 | return 0; |
242 | } | 238 | } |
243 | 239 | ||
244 | /* Each element set once, and only accessed by a single processor anyway */ | 240 | /* Each element set once, and only accessed by a single processor anyway */ |
@@ -255,35 +251,38 @@ int start_userspace(unsigned long stub_stack) | |||
255 | stack = mmap(NULL, UM_KERN_PAGE_SIZE, | 251 | stack = mmap(NULL, UM_KERN_PAGE_SIZE, |
256 | PROT_READ | PROT_WRITE | PROT_EXEC, | 252 | PROT_READ | PROT_WRITE | PROT_EXEC, |
257 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 253 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
258 | if(stack == MAP_FAILED) | 254 | if (stack == MAP_FAILED) |
259 | panic("start_userspace : mmap failed, errno = %d", errno); | 255 | panic("start_userspace : mmap failed, errno = %d", errno); |
260 | sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); | 256 | sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *); |
261 | 257 | ||
262 | flags = CLONE_FILES | SIGCHLD; | 258 | flags = CLONE_FILES | SIGCHLD; |
263 | if(proc_mm) flags |= CLONE_VM; | 259 | if (proc_mm) |
260 | flags |= CLONE_VM; | ||
261 | |||
264 | pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); | 262 | pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack); |
265 | if(pid < 0) | 263 | if (pid < 0) |
266 | panic("start_userspace : clone failed, errno = %d", errno); | 264 | panic("start_userspace : clone failed, errno = %d", errno); |
267 | 265 | ||
268 | do { | 266 | do { |
269 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); | 267 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); |
270 | if(n < 0) | 268 | if (n < 0) |
271 | panic("start_userspace : wait failed, errno = %d", | 269 | panic("start_userspace : wait failed, errno = %d", |
272 | errno); | 270 | errno); |
273 | } while(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM)); | 271 | } while (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGVTALRM)); |
274 | 272 | ||
275 | if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) | 273 | if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) |
276 | panic("start_userspace : expected SIGSTOP, got status = %d", | 274 | panic("start_userspace : expected SIGSTOP, got status = %d", |
277 | status); | 275 | status); |
278 | 276 | ||
279 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL, (void *)PTRACE_O_TRACESYSGOOD) < 0) | 277 | if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL, |
280 | panic("start_userspace : PTRACE_OLDSETOPTIONS failed, errno=%d\n", | 278 | (void *) PTRACE_O_TRACESYSGOOD) < 0) |
281 | errno); | 279 | panic("start_userspace : PTRACE_OLDSETOPTIONS failed, " |
280 | "errno = %d\n", errno); | ||
282 | 281 | ||
283 | if(munmap(stack, UM_KERN_PAGE_SIZE) < 0) | 282 | if (munmap(stack, UM_KERN_PAGE_SIZE) < 0) |
284 | panic("start_userspace : munmap failed, errno = %d\n", errno); | 283 | panic("start_userspace : munmap failed, errno = %d\n", errno); |
285 | 284 | ||
286 | return(pid); | 285 | return pid; |
287 | } | 286 | } |
288 | 287 | ||
289 | void userspace(struct uml_pt_regs *regs) | 288 | void userspace(struct uml_pt_regs *regs) |
@@ -292,7 +291,7 @@ void userspace(struct uml_pt_regs *regs) | |||
292 | /* To prevent races if using_sysemu changes under us.*/ | 291 | /* To prevent races if using_sysemu changes under us.*/ |
293 | int local_using_sysemu; | 292 | int local_using_sysemu; |
294 | 293 | ||
295 | while(1){ | 294 | while (1) { |
296 | restore_registers(pid, regs); | 295 | restore_registers(pid, regs); |
297 | 296 | ||
298 | /* Now we set local_using_sysemu to be used for one loop */ | 297 | /* Now we set local_using_sysemu to be used for one loop */ |
@@ -302,13 +301,13 @@ void userspace(struct uml_pt_regs *regs) | |||
302 | singlestepping(NULL)); | 301 | singlestepping(NULL)); |
303 | 302 | ||
304 | err = ptrace(op, pid, 0, 0); | 303 | err = ptrace(op, pid, 0, 0); |
305 | if(err) | 304 | if (err) |
306 | panic("userspace - could not resume userspace process, " | 305 | panic("userspace - could not resume userspace process, " |
307 | "pid=%d, ptrace operation = %d, errno = %d\n", | 306 | "pid=%d, ptrace operation = %d, errno = %d\n", |
308 | pid, op, errno); | 307 | pid, op, errno); |
309 | 308 | ||
310 | CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); | 309 | CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); |
311 | if(err < 0) | 310 | if (err < 0) |
312 | panic("userspace - waitpid failed, errno = %d\n", | 311 | panic("userspace - waitpid failed, errno = %d\n", |
313 | errno); | 312 | errno); |
314 | 313 | ||
@@ -316,12 +315,14 @@ void userspace(struct uml_pt_regs *regs) | |||
316 | save_registers(pid, regs); | 315 | save_registers(pid, regs); |
317 | UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */ | 316 | UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */ |
318 | 317 | ||
319 | if(WIFSTOPPED(status)){ | 318 | if (WIFSTOPPED(status)) { |
320 | int sig = WSTOPSIG(status); | 319 | int sig = WSTOPSIG(status); |
321 | switch(sig){ | 320 | switch(sig) { |
322 | case SIGSEGV: | 321 | case SIGSEGV: |
323 | if(PTRACE_FULL_FAULTINFO || !ptrace_faultinfo){ | 322 | if (PTRACE_FULL_FAULTINFO || |
324 | get_skas_faultinfo(pid, ®s->faultinfo); | 323 | !ptrace_faultinfo) { |
324 | get_skas_faultinfo(pid, | ||
325 | ®s->faultinfo); | ||
325 | (*sig_info[SIGSEGV])(SIGSEGV, regs); | 326 | (*sig_info[SIGSEGV])(SIGSEGV, regs); |
326 | } | 327 | } |
327 | else handle_segv(pid, regs); | 328 | else handle_segv(pid, regs); |
@@ -343,14 +344,14 @@ void userspace(struct uml_pt_regs *regs) | |||
343 | unblock_signals(); | 344 | unblock_signals(); |
344 | break; | 345 | break; |
345 | default: | 346 | default: |
346 | printk("userspace - child stopped with signal " | 347 | printk(UM_KERN_ERR "userspace - child stopped " |
347 | "%d\n", sig); | 348 | "with signal %d\n", sig); |
348 | } | 349 | } |
349 | pid = userspace_pid[0]; | 350 | pid = userspace_pid[0]; |
350 | interrupt_end(); | 351 | interrupt_end(); |
351 | 352 | ||
352 | /* Avoid -ERESTARTSYS handling in host */ | 353 | /* Avoid -ERESTARTSYS handling in host */ |
353 | if(PT_SYSCALL_NR_OFFSET != PT_SYSCALL_RET_OFFSET) | 354 | if (PT_SYSCALL_NR_OFFSET != PT_SYSCALL_RET_OFFSET) |
354 | PT_SYSCALL_NR(regs->regs) = -1; | 355 | PT_SYSCALL_NR(regs->regs) = -1; |
355 | } | 356 | } |
356 | } | 357 | } |
@@ -384,7 +385,8 @@ int copy_context_skas0(unsigned long new_stack, int pid) | |||
384 | __u64 new_offset; | 385 | __u64 new_offset; |
385 | int new_fd = phys_mapping(to_phys((void *)new_stack), &new_offset); | 386 | int new_fd = phys_mapping(to_phys((void *)new_stack), &new_offset); |
386 | 387 | ||
387 | /* prepare offset and fd of child's stack as argument for parent's | 388 | /* |
389 | * prepare offset and fd of child's stack as argument for parent's | ||
388 | * and child's mmap2 calls | 390 | * and child's mmap2 calls |
389 | */ | 391 | */ |
390 | *data = ((struct stub_data) { .offset = MMAP_OFFSET(new_offset), | 392 | *data = ((struct stub_data) { .offset = MMAP_OFFSET(new_offset), |
@@ -393,28 +395,30 @@ int copy_context_skas0(unsigned long new_stack, int pid) | |||
393 | { { 0, 1000000 / hz() }, | 395 | { { 0, 1000000 / hz() }, |
394 | { 0, 1000000 / hz() }})}); | 396 | { 0, 1000000 / hz() }})}); |
395 | err = ptrace_setregs(pid, thread_regs); | 397 | err = ptrace_setregs(pid, thread_regs); |
396 | if(err < 0) | 398 | if (err < 0) |
397 | panic("copy_context_skas0 : PTRACE_SETREGS failed, " | 399 | panic("copy_context_skas0 : PTRACE_SETREGS failed, " |
398 | "pid = %d, errno = %d\n", pid, -err); | 400 | "pid = %d, errno = %d\n", pid, -err); |
399 | 401 | ||
400 | /* set a well known return code for detection of child write failure */ | 402 | /* set a well known return code for detection of child write failure */ |
401 | child_data->err = 12345678; | 403 | child_data->err = 12345678; |
402 | 404 | ||
403 | /* Wait, until parent has finished its work: read child's pid from | 405 | /* |
406 | * Wait, until parent has finished its work: read child's pid from | ||
404 | * parent's stack, and check, if bad result. | 407 | * parent's stack, and check, if bad result. |
405 | */ | 408 | */ |
406 | err = ptrace(PTRACE_CONT, pid, 0, 0); | 409 | err = ptrace(PTRACE_CONT, pid, 0, 0); |
407 | if(err) | 410 | if (err) |
408 | panic("Failed to continue new process, pid = %d, " | 411 | panic("Failed to continue new process, pid = %d, " |
409 | "errno = %d\n", pid, errno); | 412 | "errno = %d\n", pid, errno); |
410 | wait_stub_done(pid); | 413 | wait_stub_done(pid); |
411 | 414 | ||
412 | pid = data->err; | 415 | pid = data->err; |
413 | if(pid < 0) | 416 | if (pid < 0) |
414 | panic("copy_context_skas0 - stub-parent reports error %d\n", | 417 | panic("copy_context_skas0 - stub-parent reports error %d\n", |
415 | -pid); | 418 | -pid); |
416 | 419 | ||
417 | /* Wait, until child has finished too: read child's result from | 420 | /* |
421 | * Wait, until child has finished too: read child's result from | ||
418 | * child's stack and check it. | 422 | * child's stack and check it. |
419 | */ | 423 | */ |
420 | wait_stub_done(pid); | 424 | wait_stub_done(pid); |
@@ -455,15 +459,16 @@ void map_stub_pages(int fd, unsigned long code, | |||
455 | .offset = code_offset | 459 | .offset = code_offset |
456 | } } }); | 460 | } } }); |
457 | CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop))); | 461 | CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop))); |
458 | if(n != sizeof(mmop)){ | 462 | if (n != sizeof(mmop)) { |
459 | n = errno; | 463 | n = errno; |
460 | printk("mmap args - addr = 0x%lx, fd = %d, offset = %llx\n", | 464 | printk(UM_KERN_ERR "mmap args - addr = 0x%lx, fd = %d, " |
461 | code, code_fd, (unsigned long long) code_offset); | 465 | "offset = %llx\n", code, code_fd, |
466 | (unsigned long long) code_offset); | ||
462 | panic("map_stub_pages : /proc/mm map for code failed, " | 467 | panic("map_stub_pages : /proc/mm map for code failed, " |
463 | "err = %d\n", n); | 468 | "err = %d\n", n); |
464 | } | 469 | } |
465 | 470 | ||
466 | if ( stack ) { | 471 | if (stack) { |
467 | __u64 map_offset; | 472 | __u64 map_offset; |
468 | int map_fd = phys_mapping(to_phys((void *)stack), &map_offset); | 473 | int map_fd = phys_mapping(to_phys((void *)stack), &map_offset); |
469 | mmop = ((struct proc_mm_op) | 474 | mmop = ((struct proc_mm_op) |
@@ -478,7 +483,7 @@ void map_stub_pages(int fd, unsigned long code, | |||
478 | .offset = map_offset | 483 | .offset = map_offset |
479 | } } }); | 484 | } } }); |
480 | CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop))); | 485 | CATCH_EINTR(n = write(fd, &mmop, sizeof(mmop))); |
481 | if(n != sizeof(mmop)) | 486 | if (n != sizeof(mmop)) |
482 | panic("map_stub_pages : /proc/mm map for data failed, " | 487 | panic("map_stub_pages : /proc/mm map for data failed, " |
483 | "err = %d\n", errno); | 488 | "err = %d\n", errno); |
484 | } | 489 | } |
@@ -498,7 +503,7 @@ void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)) | |||
498 | 503 | ||
499 | void switch_threads(jmp_buf *me, jmp_buf *you) | 504 | void switch_threads(jmp_buf *me, jmp_buf *you) |
500 | { | 505 | { |
501 | if(UML_SETJMP(me) == 0) | 506 | if (UML_SETJMP(me) == 0) |
502 | UML_LONGJMP(you, 1); | 507 | UML_LONGJMP(you, 1); |
503 | } | 508 | } |
504 | 509 | ||
@@ -526,7 +531,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf) | |||
526 | * after returning to the jumper. | 531 | * after returning to the jumper. |
527 | */ | 532 | */ |
528 | n = setjmp(initial_jmpbuf); | 533 | n = setjmp(initial_jmpbuf); |
529 | switch(n){ | 534 | switch(n) { |
530 | case INIT_JMP_NEW_THREAD: | 535 | case INIT_JMP_NEW_THREAD: |
531 | (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler; | 536 | (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler; |
532 | (*switch_buf)[0].JB_SP = (unsigned long) stack + | 537 | (*switch_buf)[0].JB_SP = (unsigned long) stack + |
@@ -538,10 +543,10 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf) | |||
538 | break; | 543 | break; |
539 | case INIT_JMP_HALT: | 544 | case INIT_JMP_HALT: |
540 | kmalloc_ok = 0; | 545 | kmalloc_ok = 0; |
541 | return(0); | 546 | return 0; |
542 | case INIT_JMP_REBOOT: | 547 | case INIT_JMP_REBOOT: |
543 | kmalloc_ok = 0; | 548 | kmalloc_ok = 0; |
544 | return(1); | 549 | return 1; |
545 | default: | 550 | default: |
546 | panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); | 551 | panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); |
547 | } | 552 | } |
@@ -557,7 +562,7 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) | |||
557 | cb_back = &here; | 562 | cb_back = &here; |
558 | 563 | ||
559 | block_signals(); | 564 | block_signals(); |
560 | if(UML_SETJMP(&here) == 0) | 565 | if (UML_SETJMP(&here) == 0) |
561 | UML_LONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK); | 566 | UML_LONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK); |
562 | unblock_signals(); | 567 | unblock_signals(); |
563 | 568 | ||
@@ -583,10 +588,10 @@ void __switch_mm(struct mm_id *mm_idp) | |||
583 | int err; | 588 | int err; |
584 | 589 | ||
585 | /* FIXME: need cpu pid in __switch_mm */ | 590 | /* FIXME: need cpu pid in __switch_mm */ |
586 | if(proc_mm){ | 591 | if (proc_mm) { |
587 | err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0, | 592 | err = ptrace(PTRACE_SWITCH_MM, userspace_pid[0], 0, |
588 | mm_idp->u.mm_fd); | 593 | mm_idp->u.mm_fd); |
589 | if(err) | 594 | if (err) |
590 | panic("__switch_mm - PTRACE_SWITCH_MM failed, " | 595 | panic("__switch_mm - PTRACE_SWITCH_MM failed, " |
591 | "errno = %d\n", errno); | 596 | "errno = %d\n", errno); |
592 | } | 597 | } |