Wed Dec 14 12:29:59 2011 UTC ()
only need to setup altstack after fork, not in lwp tramp


(jmcneill)
diff -r1.51 -r1.52 src/sys/arch/usermode/dev/cpu.c
diff -r1.77 -r1.78 src/sys/arch/usermode/usermode/pmap.c

cvs diff -r1.51 -r1.52 src/sys/arch/usermode/dev/cpu.c (expand / switch to unified diff)

--- src/sys/arch/usermode/dev/cpu.c 2011/12/14 04:12:22 1.51
+++ src/sys/arch/usermode/dev/cpu.c 2011/12/14 12:29:59 1.52
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.c,v 1.51 2011/12/14 04:12:22 jmcneill Exp $ */ 1/* $NetBSD: cpu.c,v 1.52 2011/12/14 12:29:59 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include "opt_cpu.h" 29#include "opt_cpu.h"
30#include "opt_hz.h" 30#include "opt_hz.h"
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.51 2011/12/14 04:12:22 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.52 2011/12/14 12:29:59 jmcneill Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/conf.h> 36#include <sys/conf.h>
37#include <sys/proc.h> 37#include <sys/proc.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/device.h> 39#include <sys/device.h>
40#include <sys/reboot.h> 40#include <sys/reboot.h>
41#include <sys/lwp.h> 41#include <sys/lwp.h>
42#include <sys/cpu.h> 42#include <sys/cpu.h>
43#include <sys/mbuf.h> 43#include <sys/mbuf.h>
44#include <sys/msgbuf.h> 44#include <sys/msgbuf.h>
45 45
46#include <dev/cons.h> 46#include <dev/cons.h>
@@ -292,27 +292,26 @@ cpu_lwp_free2(struct lwp *l) @@ -292,27 +292,26 @@ cpu_lwp_free2(struct lwp *l)
292} 292}
293 293
294static void 294static void
295cpu_lwp_trampoline(ucontext_t *ucp, void (*func)(void *), void *arg) 295cpu_lwp_trampoline(ucontext_t *ucp, void (*func)(void *), void *arg)
296{ 296{
297#ifdef CPU_DEBUG 297#ifdef CPU_DEBUG
298 dprintf_debug("cpu_lwp_trampoline called with func %p, arg %p\n", (void *) func, arg); 298 dprintf_debug("cpu_lwp_trampoline called with func %p, arg %p\n", (void *) func, arg);
299#endif 299#endif
300 /* init lwp */ 300 /* init lwp */
301 lwp_startup(curcpu()->ci_stash, curlwp); 301 lwp_startup(curcpu()->ci_stash, curlwp);
302 302
303 /* actual jump */ 303 /* actual jump */
304 thunk_makecontext(ucp, (void (*)(void)) func, 1, arg, NULL, NULL); 304 thunk_makecontext(ucp, (void (*)(void)) func, 1, arg, NULL, NULL);
305 thunk_sigaltstack(usermode_signal_stack(), NULL); 
306 thunk_setcontext(ucp); 305 thunk_setcontext(ucp);
307} 306}
308 307
309void 308void
310cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize, 309cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
311 void (*func)(void *), void *arg) 310 void (*func)(void *), void *arg)
312{ 311{
313 struct pcb *pcb1 = lwp_getpcb(l1); 312 struct pcb *pcb1 = lwp_getpcb(l1);
314 struct pcb *pcb2 = lwp_getpcb(l2); 313 struct pcb *pcb2 = lwp_getpcb(l2);
315 void *stack_ucp, *stack_syscall_ucp, *stack_pagefault_ucp; 314 void *stack_ucp, *stack_syscall_ucp, *stack_pagefault_ucp;
316 315
317#ifdef CPU_DEBUG 316#ifdef CPU_DEBUG
318 dprintf_debug("cpu_lwp_fork [%s/%p] -> [%s/%p] stack=%p stacksize=%d\n", 317 dprintf_debug("cpu_lwp_fork [%s/%p] -> [%s/%p] stack=%p stacksize=%d\n",

cvs diff -r1.77 -r1.78 src/sys/arch/usermode/usermode/pmap.c (expand / switch to unified diff)

--- src/sys/arch/usermode/usermode/pmap.c 2011/12/13 15:43:55 1.77
+++ src/sys/arch/usermode/usermode/pmap.c 2011/12/14 12:29:59 1.78
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.77 2011/12/13 15:43:55 reinoud Exp $ */ 1/* $NetBSD: pmap.c,v 1.78 2011/12/14 12:29:59 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2011 Reinoud Zandijk <reinoud@NetBSD.org> 4 * Copyright (c) 2011 Reinoud Zandijk <reinoud@NetBSD.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,38 +17,39 @@ @@ -17,38 +17,39 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77 2011/12/13 15:43:55 reinoud Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.78 2011/12/14 12:29:59 jmcneill Exp $");
31 31
32#include "opt_memsize.h" 32#include "opt_memsize.h"
33#include "opt_kmempages.h" 33#include "opt_kmempages.h"
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/mutex.h> 37#include <sys/mutex.h>
38#include <sys/buf.h> 38#include <sys/buf.h>
39#include <sys/malloc.h> 39#include <sys/malloc.h>
40#include <sys/pool.h> 40#include <sys/pool.h>
41#include <machine/thunk.h> 41#include <machine/thunk.h>
 42#include <machine/machdep.h>
42 43
43#include <uvm/uvm.h> 44#include <uvm/uvm.h>
44 45
45struct pv_entry { 46struct pv_entry {
46 struct pv_entry *pv_next; 47 struct pv_entry *pv_next;
47 pmap_t pv_pmap; 48 pmap_t pv_pmap;
48 uintptr_t pv_ppn; /* physical page number */ 49 uintptr_t pv_ppn; /* physical page number */
49 uintptr_t pv_lpn; /* logical page number */ 50 uintptr_t pv_lpn; /* logical page number */
50 vm_prot_t pv_prot; /* logical protection */ 51 vm_prot_t pv_prot; /* logical protection */
51 int pv_mmap_ppl; /* programmed protection */ 52 int pv_mmap_ppl; /* programmed protection */
52 uint8_t pv_vflags; /* per mapping flags */ 53 uint8_t pv_vflags; /* per mapping flags */
53#define PV_WIRED 0x01 /* wired mapping */ 54#define PV_WIRED 0x01 /* wired mapping */
54#define PV_UNMANAGED 0x02 /* entered by pmap_kenter_ */ 55#define PV_UNMANAGED 0x02 /* entered by pmap_kenter_ */
@@ -359,27 +360,28 @@ pmap_bootstrap(void) @@ -359,27 +360,28 @@ pmap_bootstrap(void)
359 360
360 aprint_verbose("leaving pmap_bootstrap:\n"); 361 aprint_verbose("leaving pmap_bootstrap:\n");
361 aprint_verbose("\t%"PRIu64" MB of physical pages left\n", 362 aprint_verbose("\t%"PRIu64" MB of physical pages left\n",
362 (uint64_t) (free_end - (free_start + fpos))/1024/1024); 363 (uint64_t) (free_end - (free_start + fpos))/1024/1024);
363 aprint_verbose("\t%"PRIu64" MB of kmem left\n", 364 aprint_verbose("\t%"PRIu64" MB of kmem left\n",
364 (uint64_t) (kmem_ext_end - kmem_ext_cur_end)/1024/1024); 365 (uint64_t) (kmem_ext_end - kmem_ext_cur_end)/1024/1024);
365 366
366 setup_signal_handlers(); 367 setup_signal_handlers();
367} 368}
368 369
369void 370void
370pmap_init(void) 371pmap_init(void)
371{ 372{
372 /* All deferred to pmap_create, because malloc() is nice. */ 373 /* ensure signal stack is setup after urkelvisor fork */
 374 thunk_sigaltstack(usermode_signal_stack(), NULL);
373} 375}
374 376
375/* return kernel space start and end (including growth) */ 377/* return kernel space start and end (including growth) */
376void 378void
377pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp) 379pmap_virtual_space(vaddr_t *vstartp, vaddr_t *vendp)
378{ 380{
379 *vstartp = kmem_ext_cur_start; /* min to map in */ 381 *vstartp = kmem_ext_cur_start; /* min to map in */
380 *vendp = kmem_ext_end; /* max available */ 382 *vendp = kmem_ext_end; /* max available */
381} 383}
382 384
383static void 385static void
384pmap_deferred_init(void) 386pmap_deferred_init(void)
385{ 387{