Pull up following revision(s) (requested by christos in ticket #458): sys/conf/Makefile.kern.inc: revision 1.121 sys/conf/files: revision 1.940 sys/kern/init_main.c: revision 1.381 sys/kern/kern_ssp.c: revision 1.1 sys/kern/subr_autoconf.c: revision 1.168 sys/sys/device.h: revision 1.116 sys/sys/systm.h: revision 1.233 Unbreak ssp kernels. The issue here that when the ssp_init() call was deferred, it caused the return from the enclosing function to break, as well as the ssp return on i386. To fix both issues, split configure in two pieces the one before calling ssp_init and the one after, and move the ssp_init() call back in main. Put ssp_init() in its own file, and compile this new file with -fno-stack-protector. Tested on amd64. XXX: If we want to have ssp kernels working on 5.0, this change needs to be pulled up.diff -r1.118 -r1.118.4.1 src/sys/conf/Makefile.kern.inc
(snj)
--- src/sys/conf/Makefile.kern.inc 2008/10/25 22:27:38 1.118
+++ src/sys/conf/Makefile.kern.inc 2009/03/15 19:43:48 1.118.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile.kern.inc,v 1.118 2008/10/25 22:27:38 apb Exp $ | 1 | # $NetBSD: Makefile.kern.inc,v 1.118.4.1 2009/03/15 19:43:48 snj Exp $ | |
2 | # | 2 | # | |
3 | # This file contains common `MI' targets and definitions and it is included | 3 | # This file contains common `MI' targets and definitions and it is included | |
4 | # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. | 4 | # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. | |
5 | # | 5 | # | |
6 | # Each target in this file should be protected with `if !target(target)' | 6 | # Each target in this file should be protected with `if !target(target)' | |
7 | # or `if !commands(target)' and each variable should only be conditionally | 7 | # or `if !commands(target)' and each variable should only be conditionally | |
8 | # assigned `VAR ?= VALUE', so that everything can be overriden. | 8 | # assigned `VAR ?= VALUE', so that everything can be overriden. | |
9 | # | 9 | # | |
10 | # DEBUG is set to -g if debugging. | 10 | # DEBUG is set to -g if debugging. | |
11 | # PROF is set to -pg if profiling. | 11 | # PROF is set to -pg if profiling. | |
12 | # | 12 | # | |
13 | # To specify debugging, add the config line: makeoptions DEBUG="-g" | 13 | # To specify debugging, add the config line: makeoptions DEBUG="-g" | |
14 | # A better way is to specify -g only for a few files. | 14 | # A better way is to specify -g only for a few files. | |
@@ -85,26 +85,27 @@ CWARNFLAGS+= -Wextra -Wno-unused-paramet | @@ -85,26 +85,27 @@ CWARNFLAGS+= -Wextra -Wno-unused-paramet | |||
85 | 85 | |||
86 | CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss | 86 | CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss | |
87 | CFLAGS+= ${DEBUG} ${COPTS} | 87 | CFLAGS+= ${DEBUG} ${COPTS} | |
88 | AFLAGS+= -D_LOCORE -Wa,-fatal-warnings | 88 | AFLAGS+= -D_LOCORE -Wa,-fatal-warnings | |
89 | 89 | |||
90 | # XXX | 90 | # XXX | |
91 | .if defined(HAVE_GCC) && ${HAVE_GCC} > 3 | 91 | .if defined(HAVE_GCC) && ${HAVE_GCC} > 3 | |
92 | CFLAGS+= -fno-strict-aliasing | 92 | CFLAGS+= -fno-strict-aliasing | |
93 | .endif | 93 | .endif | |
94 | 94 | |||
95 | .if ${USE_SSP:Uno} == "yes" | 95 | .if ${USE_SSP:Uno} == "yes" | |
96 | CFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1 | 96 | CFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1 | |
97 | LDFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1 | 97 | LDFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1 | |
98 | COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__ | |||
98 | .endif | 99 | .endif | |
99 | 100 | |||
100 | # If we want the bpendtsleep: label in kern_synch.c, we need to use | 101 | # If we want the bpendtsleep: label in kern_synch.c, we need to use | |
101 | # -fno-reorder-blocks. Don't make this a config(1) defflag without | 102 | # -fno-reorder-blocks. Don't make this a config(1) defflag without | |
102 | # making sure this fragment remains valid. | 103 | # making sure this fragment remains valid. | |
103 | .if defined(HAVE_GCC) && ${HAVE_GCC} > 3 && \ | 104 | .if defined(HAVE_GCC) && ${HAVE_GCC} > 3 && \ | |
104 | !empty(${CFLAGS:M-DKERN_SYNCH_BPENDTSLEEP_LABEL}) | 105 | !empty(${CFLAGS:M-DKERN_SYNCH_BPENDTSLEEP_LABEL}) | |
105 | COPTS.kern_synch.c+= -fno-reorder-blocks | 106 | COPTS.kern_synch.c+= -fno-reorder-blocks | |
106 | .endif | 107 | .endif | |
107 | 108 | |||
108 | # Use the per-source COPTS variables to add -g to just those | 109 | # Use the per-source COPTS variables to add -g to just those | |
109 | # files that match the shell patterns given in ${DEBUGLIST} | 110 | # files that match the shell patterns given in ${DEBUGLIST} | |
110 | # | 111 | # |
--- src/sys/conf/files 2008/10/15 06:51:20 1.924
+++ src/sys/conf/files 2009/03/15 19:43:48 1.924.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: files,v 1.924 2008/10/15 06:51:20 wrstuden Exp $ | 1 | # $NetBSD: files,v 1.924.4.1 2009/03/15 19:43:48 snj Exp $ | |
2 | 2 | |||
3 | # @(#)files.newconf 7.5 (Berkeley) 5/10/93 | 3 | # @(#)files.newconf 7.5 (Berkeley) 5/10/93 | |
4 | 4 | |||
5 | version 20080610 | 5 | version 20080610 | |
6 | 6 | |||
7 | # | 7 | # | |
8 | # device classes | 8 | # device classes | |
9 | # | 9 | # | |
10 | devclass disk | 10 | devclass disk | |
11 | devclass tape | 11 | devclass tape | |
12 | devclass ifnet | 12 | devclass ifnet | |
13 | devclass tty | 13 | devclass tty | |
14 | devclass audiodev | 14 | devclass audiodev | |
@@ -1398,26 +1398,27 @@ file kern/kern_ntptime.c | @@ -1398,26 +1398,27 @@ file kern/kern_ntptime.c | |||
1398 | file kern/kern_pax.c pax_mprotect | pax_segvguard | 1398 | file kern/kern_pax.c pax_mprotect | pax_segvguard | |
1399 | file kern/kern_physio.c | 1399 | file kern/kern_physio.c | |
1400 | file kern/kern_pmf.c | 1400 | file kern/kern_pmf.c | |
1401 | file kern/kern_proc.c | 1401 | file kern/kern_proc.c | |
1402 | file kern/kern_prot.c | 1402 | file kern/kern_prot.c | |
1403 | file kern/kern_ras.c | 1403 | file kern/kern_ras.c | |
1404 | file kern/kern_rate.c | 1404 | file kern/kern_rate.c | |
1405 | file kern/kern_resource.c | 1405 | file kern/kern_resource.c | |
1406 | file kern/kern_runq.c | 1406 | file kern/kern_runq.c | |
1407 | file kern/kern_rwlock.c | 1407 | file kern/kern_rwlock.c | |
1408 | file kern/kern_sig.c | 1408 | file kern/kern_sig.c | |
1409 | file kern/kern_sleepq.c | 1409 | file kern/kern_sleepq.c | |
1410 | file kern/kern_softint.c | 1410 | file kern/kern_softint.c | |
1411 | file kern/kern_ssp.c | |||
1411 | file kern/kern_stub.c | 1412 | file kern/kern_stub.c | |
1412 | file kern/kern_subr.c | 1413 | file kern/kern_subr.c | |
1413 | file kern/kern_synch.c | 1414 | file kern/kern_synch.c | |
1414 | file kern/kern_sysctl.c | 1415 | file kern/kern_sysctl.c | |
1415 | file kern/kern_tc.c | 1416 | file kern/kern_tc.c | |
1416 | file kern/kern_time.c | 1417 | file kern/kern_time.c | |
1417 | file kern/kern_timeout.c | 1418 | file kern/kern_timeout.c | |
1418 | file kern/kern_turnstile.c | 1419 | file kern/kern_turnstile.c | |
1419 | file kern/kern_todr.c | 1420 | file kern/kern_todr.c | |
1420 | file kern/kern_uidinfo.c | 1421 | file kern/kern_uidinfo.c | |
1421 | file kern/kern_uuid.c | 1422 | file kern/kern_uuid.c | |
1422 | file kern/kern_xxx.c | 1423 | file kern/kern_xxx.c | |
1423 | file kern/kgdb_stub.c kgdb | 1424 | file kern/kgdb_stub.c kgdb |
--- src/sys/kern/init_main.c 2008/10/28 15:33:10 1.371
+++ src/sys/kern/init_main.c 2009/03/15 19:43:48 1.371.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init_main.c,v 1.371 2008/10/28 15:33:10 tsutsui Exp $ */ | 1 | /* $NetBSD: init_main.c,v 1.371.2.1 2009/03/15 19:43:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | |
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. | |
@@ -87,27 +87,27 @@ | @@ -87,27 +87,27 @@ | |||
87 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 87 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
88 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 88 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
89 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 89 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
90 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 90 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
91 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 91 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
92 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 92 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
93 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 93 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
94 | * SUCH DAMAGE. | 94 | * SUCH DAMAGE. | |
95 | * | 95 | * | |
96 | * @(#)init_main.c 8.16 (Berkeley) 5/14/95 | 96 | * @(#)init_main.c 8.16 (Berkeley) 5/14/95 | |
97 | */ | 97 | */ | |
98 | 98 | |||
99 | #include <sys/cdefs.h> | 99 | #include <sys/cdefs.h> | |
100 | __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.371 2008/10/28 15:33:10 tsutsui Exp $"); | 100 | __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.371.2.1 2009/03/15 19:43:48 snj Exp $"); | |
101 | 101 | |||
102 | #include "opt_ddb.h" | 102 | #include "opt_ddb.h" | |
103 | #include "opt_ipsec.h" | 103 | #include "opt_ipsec.h" | |
104 | #include "opt_ntp.h" | 104 | #include "opt_ntp.h" | |
105 | #include "opt_pipe.h" | 105 | #include "opt_pipe.h" | |
106 | #include "opt_posix.h" | 106 | #include "opt_posix.h" | |
107 | #include "opt_syscall_debug.h" | 107 | #include "opt_syscall_debug.h" | |
108 | #include "opt_sysv.h" | 108 | #include "opt_sysv.h" | |
109 | #include "opt_fileassoc.h" | 109 | #include "opt_fileassoc.h" | |
110 | #include "opt_ktrace.h" | 110 | #include "opt_ktrace.h" | |
111 | #include "opt_pax.h" | 111 | #include "opt_pax.h" | |
112 | #include "opt_wapbl.h" | 112 | #include "opt_wapbl.h" | |
113 | 113 | |||
@@ -242,72 +242,26 @@ struct lwp *curlwp = &lwp0; | @@ -242,72 +242,26 @@ struct lwp *curlwp = &lwp0; | |||
242 | #endif | 242 | #endif | |
243 | struct proc *initproc; | 243 | struct proc *initproc; | |
244 | 244 | |||
245 | struct vnode *rootvp, *swapdev_vp; | 245 | struct vnode *rootvp, *swapdev_vp; | |
246 | int boothowto; | 246 | int boothowto; | |
247 | int cold = 1; /* still working on startup */ | 247 | int cold = 1; /* still working on startup */ | |
248 | struct timeval boottime; /* time at system startup - will only follow settime deltas */ | 248 | struct timeval boottime; /* time at system startup - will only follow settime deltas */ | |
249 | 249 | |||
250 | int start_init_exec; /* semaphore for start_init() */ | 250 | int start_init_exec; /* semaphore for start_init() */ | |
251 | 251 | |||
252 | static void check_console(struct lwp *l); | 252 | static void check_console(struct lwp *l); | |
253 | static void start_init(void *); | 253 | static void start_init(void *); | |
254 | void main(void); | 254 | void main(void); | |
255 | void ssp_init(void); | |||
256 | ||||
257 | #if defined(__SSP__) || defined(__SSP_ALL__) | |||
258 | long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | |||
259 | void __stack_chk_fail(void); | |||
260 | ||||
261 | void | |||
262 | __stack_chk_fail(void) | |||
263 | { | |||
264 | panic("stack overflow detected; terminated"); | |||
265 | } | |||
266 | ||||
267 | void | |||
268 | ssp_init(void) | |||
269 | { | |||
270 | int s; | |||
271 | ||||
272 | #ifdef DIAGNOSTIC | |||
273 | printf("Initializing SSP:"); | |||
274 | #endif | |||
275 | /* | |||
276 | * We initialize ssp here carefully: | |||
277 | * 1. after we got some entropy | |||
278 | * 2. without calling a function | |||
279 | */ | |||
280 | size_t i; | |||
281 | long guard[__arraycount(__stack_chk_guard)]; | |||
282 | ||||
283 | arc4randbytes(guard, sizeof(guard)); | |||
284 | s = splhigh(); | |||
285 | for (i = 0; i < __arraycount(guard); i++) | |||
286 | __stack_chk_guard[i] = guard[i]; | |||
287 | splx(s); | |||
288 | #ifdef DIAGNOSTIC | |||
289 | for (i = 0; i < __arraycount(guard); i++) | |||
290 | printf("%lx ", guard[i]); | |||
291 | printf("\n"); | |||
292 | #endif | |||
293 | } | |||
294 | #else | |||
295 | void | |||
296 | ssp_init(void) | |||
297 | { | |||
298 | ||||
299 | } | |||
300 | #endif | |||
301 | 255 | |||
302 | void __secmodel_none(void); | 256 | void __secmodel_none(void); | |
303 | __weak_alias(secmodel_start,__secmodel_none); | 257 | __weak_alias(secmodel_start,__secmodel_none); | |
304 | void | 258 | void | |
305 | __secmodel_none(void) | 259 | __secmodel_none(void) | |
306 | { | 260 | { | |
307 | return; | 261 | return; | |
308 | } | 262 | } | |
309 | 263 | |||
310 | /* | 264 | /* | |
311 | * System startup; initialize the world, create process 0, mount root | 265 | * System startup; initialize the world, create process 0, mount root | |
312 | * filesystem, and fork to create init and pagedaemon. Most of the | 266 | * filesystem, and fork to create init and pagedaemon. Most of the | |
313 | * hard work is done in the lower-level initialization routines including | 267 | * hard work is done in the lower-level initialization routines including | |
@@ -497,26 +451,30 @@ main(void) | @@ -497,26 +451,30 @@ main(void) | |||
497 | 451 | |||
498 | /* Initialize the buffer cache, part 2. */ | 452 | /* Initialize the buffer cache, part 2. */ | |
499 | bufinit2(); | 453 | bufinit2(); | |
500 | 454 | |||
501 | /* Initialize the disk wedge subsystem. */ | 455 | /* Initialize the disk wedge subsystem. */ | |
502 | dkwedge_init(); | 456 | dkwedge_init(); | |
503 | 457 | |||
504 | /* Initialize interfaces. */ | 458 | /* Initialize interfaces. */ | |
505 | ifinit1(); | 459 | ifinit1(); | |
506 | 460 | |||
507 | /* Configure the system hardware. This will enable interrupts. */ | 461 | /* Configure the system hardware. This will enable interrupts. */ | |
508 | configure(); | 462 | configure(); | |
509 | 463 | |||
464 | ssp_init(); | |||
465 | ||||
466 | configure2(); | |||
467 | ||||
510 | ubc_init(); /* must be after autoconfig */ | 468 | ubc_init(); /* must be after autoconfig */ | |
511 | 469 | |||
512 | #ifdef SYSVSHM | 470 | #ifdef SYSVSHM | |
513 | /* Initialize System V style shared memory. */ | 471 | /* Initialize System V style shared memory. */ | |
514 | shminit(); | 472 | shminit(); | |
515 | #endif | 473 | #endif | |
516 | 474 | |||
517 | #ifdef SYSVSEM | 475 | #ifdef SYSVSEM | |
518 | /* Initialize System V style semaphores. */ | 476 | /* Initialize System V style semaphores. */ | |
519 | seminit(); | 477 | seminit(); | |
520 | #endif | 478 | #endif | |
521 | 479 | |||
522 | #ifdef SYSVMSG | 480 | #ifdef SYSVMSG |
/* $NetBSD: kern_ssp.c,v 1.2.4.2 2009/03/15 19:43:48 snj Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ssp.c,v 1.2.4.2 2009/03/15 19:43:48 snj Exp $");
#include <sys/systm.h>
#include <sys/intr.h>
#if defined(__SSP__) || defined(__SSP_ALL__)
long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
void __stack_chk_fail(void);
void
__stack_chk_fail(void)
{
panic("stack overflow detected; terminated");
}
void
ssp_init(void)
{
int s;
#ifdef DIAGNOSTIC
printf("Initializing SSP:");
#endif
/*
* We initialize ssp here carefully:
* 1. after we got some entropy
* 2. without calling a function
*/
size_t i;
long guard[__arraycount(__stack_chk_guard)];
arc4randbytes(guard, sizeof(guard));
s = splhigh();
for (i = 0; i < __arraycount(guard); i++)
__stack_chk_guard[i] = guard[i];
splx(s);
#ifdef DIAGNOSTIC
for (i = 0; i < __arraycount(guard); i++)
printf("%lx ", guard[i]);
printf("\n");
#endif
}
#else
void
ssp_init(void)
{
}
#endif
--- src/sys/kern/subr_autoconf.c 2009/02/02 02:38:32 1.163.4.1
+++ src/sys/kern/subr_autoconf.c 2009/03/15 19:43:48 1.163.4.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: subr_autoconf.c,v 1.163.4.1 2009/02/02 02:38:32 snj Exp $ */ | 1 | /* $NetBSD: subr_autoconf.c,v 1.163.4.2 2009/03/15 19:43:48 snj Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996, 2000 Christopher G. Demetriou | 4 | * Copyright (c) 1996, 2000 Christopher G. Demetriou | |
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. | |
@@ -67,27 +67,27 @@ | @@ -67,27 +67,27 @@ | |||
67 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 67 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
68 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 68 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
69 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 69 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
70 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 70 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
71 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 71 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
72 | * SUCH DAMAGE. | 72 | * SUCH DAMAGE. | |
73 | * | 73 | * | |
74 | * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL) | 74 | * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL) | |
75 | * | 75 | * | |
76 | * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94 | 76 | * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94 | |
77 | */ | 77 | */ | |
78 | 78 | |||
79 | #include <sys/cdefs.h> | 79 | #include <sys/cdefs.h> | |
80 | __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.163.4.1 2009/02/02 02:38:32 snj Exp $"); | 80 | __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.163.4.2 2009/03/15 19:43:48 snj Exp $"); | |
81 | 81 | |||
82 | #include "opt_ddb.h" | 82 | #include "opt_ddb.h" | |
83 | #include "drvctl.h" | 83 | #include "drvctl.h" | |
84 | 84 | |||
85 | #include <sys/param.h> | 85 | #include <sys/param.h> | |
86 | #include <sys/device.h> | 86 | #include <sys/device.h> | |
87 | #include <sys/disklabel.h> | 87 | #include <sys/disklabel.h> | |
88 | #include <sys/conf.h> | 88 | #include <sys/conf.h> | |
89 | #include <sys/kauth.h> | 89 | #include <sys/kauth.h> | |
90 | #include <sys/malloc.h> | 90 | #include <sys/malloc.h> | |
91 | #include <sys/kmem.h> | 91 | #include <sys/kmem.h> | |
92 | #include <sys/systm.h> | 92 | #include <sys/systm.h> | |
93 | #include <sys/kernel.h> | 93 | #include <sys/kernel.h> | |
@@ -401,58 +401,58 @@ config_interrupts_thread(void *cookie) | @@ -401,58 +401,58 @@ config_interrupts_thread(void *cookie) | |||
401 | (*dc->dc_func)(dc->dc_dev); | 401 | (*dc->dc_func)(dc->dc_dev); | |
402 | kmem_free(dc, sizeof(*dc)); | 402 | kmem_free(dc, sizeof(*dc)); | |
403 | config_pending_decr(); | 403 | config_pending_decr(); | |
404 | } | 404 | } | |
405 | kthread_exit(0); | 405 | kthread_exit(0); | |
406 | } | 406 | } | |
407 | 407 | |||
408 | /* | 408 | /* | |
409 | * Configure the system's hardware. | 409 | * Configure the system's hardware. | |
410 | */ | 410 | */ | |
411 | void | 411 | void | |
412 | configure(void) | 412 | configure(void) | |
413 | { | 413 | { | |
414 | extern void ssp_init(void); | |||
415 | CPU_INFO_ITERATOR cii; | |||
416 | struct cpu_info *ci; | |||
417 | int i, s; | |||
418 | ||||
419 | /* Initialize data structures. */ | 414 | /* Initialize data structures. */ | |
420 | config_init(); | 415 | config_init(); | |
421 | pmf_init(); | 416 | pmf_init(); | |
422 | #if NDRVCTL > 0 | 417 | #if NDRVCTL > 0 | |
423 | drvctl_init(); | 418 | drvctl_init(); | |
424 | #endif | 419 | #endif | |
425 | 420 | |||
426 | #ifdef USERCONF | 421 | #ifdef USERCONF | |
427 | if (boothowto & RB_USERCONF) | 422 | if (boothowto & RB_USERCONF) | |
428 | user_config(); | 423 | user_config(); | |
429 | #endif | 424 | #endif | |
430 | 425 | |||
431 | if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) { | 426 | if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) { | |
432 | config_do_twiddle = 1; | 427 | config_do_twiddle = 1; | |
433 | printf_nolog("Detecting hardware..."); | 428 | printf_nolog("Detecting hardware..."); | |
434 | } | 429 | } | |
435 | 430 | |||
436 | /* | 431 | /* | |
437 | * Do the machine-dependent portion of autoconfiguration. This | 432 | * Do the machine-dependent portion of autoconfiguration. This | |
438 | * sets the configuration machinery here in motion by "finding" | 433 | * sets the configuration machinery here in motion by "finding" | |
439 | * the root bus. When this function returns, we expect interrupts | 434 | * the root bus. When this function returns, we expect interrupts | |
440 | * to be enabled. | 435 | * to be enabled. | |
441 | */ | 436 | */ | |
442 | cpu_configure(); | 437 | cpu_configure(); | |
438 | } | |||
443 | 439 | |||
444 | /* Initialize SSP. */ | 440 | void | |
445 | ssp_init(); | 441 | configure2(void) | |
442 | { | |||
443 | CPU_INFO_ITERATOR cii; | |||
444 | struct cpu_info *ci; | |||
445 | int i, s; | |||
446 | 446 | |||
447 | /* | 447 | /* | |
448 | * Now that we've found all the hardware, start the real time | 448 | * Now that we've found all the hardware, start the real time | |
449 | * and statistics clocks. | 449 | * and statistics clocks. | |
450 | */ | 450 | */ | |
451 | initclocks(); | 451 | initclocks(); | |
452 | 452 | |||
453 | cold = 0; /* clocks are running, we're warm now! */ | 453 | cold = 0; /* clocks are running, we're warm now! */ | |
454 | s = splsched(); | 454 | s = splsched(); | |
455 | curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING; | 455 | curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING; | |
456 | splx(s); | 456 | splx(s); | |
457 | 457 | |||
458 | /* Boot the secondary processors. */ | 458 | /* Boot the secondary processors. */ |
--- src/sys/sys/device.h 2008/06/11 15:56:11 1.112
+++ src/sys/sys/device.h 2009/03/15 19:43:48 1.112.6.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: device.h,v 1.112 2008/06/11 15:56:11 drochner Exp $ */ | 1 | /* $NetBSD: device.h,v 1.112.6.1 2009/03/15 19:43:48 snj Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996, 2000 Christopher G. Demetriou | 4 | * Copyright (c) 1996, 2000 Christopher G. Demetriou | |
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. | |
@@ -384,26 +384,27 @@ struct pdevinit { | @@ -384,26 +384,27 @@ struct pdevinit { | |||
384 | extern struct cfdriverlist allcfdrivers;/* list of all cfdrivers */ | 384 | extern struct cfdriverlist allcfdrivers;/* list of all cfdrivers */ | |
385 | extern struct devicelist alldevs; /* list of all devices */ | 385 | extern struct devicelist alldevs; /* list of all devices */ | |
386 | extern struct cftablelist allcftables; /* list of all cfdata tables */ | 386 | extern struct cftablelist allcftables; /* list of all cfdata tables */ | |
387 | extern device_t booted_device; /* the device we booted from */ | 387 | extern device_t booted_device; /* the device we booted from */ | |
388 | extern device_t booted_wedge; /* the wedge on that device */ | 388 | extern device_t booted_wedge; /* the wedge on that device */ | |
389 | extern int booted_partition; /* or the partition on that device */ | 389 | extern int booted_partition; /* or the partition on that device */ | |
390 | 390 | |||
391 | struct vnode *opendisk(struct device *); | 391 | struct vnode *opendisk(struct device *); | |
392 | int config_handle_wedges(struct device *, int); | 392 | int config_handle_wedges(struct device *, int); | |
393 | 393 | |||
394 | void config_init(void); | 394 | void config_init(void); | |
395 | void drvctl_init(void); | 395 | void drvctl_init(void); | |
396 | void configure(void); | 396 | void configure(void); | |
397 | void configure2(void); | |||
397 | 398 | |||
398 | int config_cfdriver_attach(struct cfdriver *); | 399 | int config_cfdriver_attach(struct cfdriver *); | |
399 | int config_cfdriver_detach(struct cfdriver *); | 400 | int config_cfdriver_detach(struct cfdriver *); | |
400 | 401 | |||
401 | int config_cfattach_attach(const char *, struct cfattach *); | 402 | int config_cfattach_attach(const char *, struct cfattach *); | |
402 | int config_cfattach_detach(const char *, struct cfattach *); | 403 | int config_cfattach_detach(const char *, struct cfattach *); | |
403 | 404 | |||
404 | int config_cfdata_attach(cfdata_t, int); | 405 | int config_cfdata_attach(cfdata_t, int); | |
405 | int config_cfdata_detach(cfdata_t); | 406 | int config_cfdata_detach(cfdata_t); | |
406 | 407 | |||
407 | struct cfdriver *config_cfdriver_lookup(const char *); | 408 | struct cfdriver *config_cfdriver_lookup(const char *); | |
408 | struct cfattach *config_cfattach_lookup(const char *, const char *); | 409 | struct cfattach *config_cfattach_lookup(const char *, const char *); | |
409 | const struct cfiattrdata *cfiattr_lookup(const char *, const struct cfdriver *); | 410 | const struct cfiattrdata *cfiattr_lookup(const char *, const struct cfdriver *); |
--- src/sys/sys/systm.h 2009/02/26 20:38:00 1.228.4.1
+++ src/sys/sys/systm.h 2009/03/15 19:43:48 1.228.4.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: systm.h,v 1.228.4.1 2009/02/26 20:38:00 snj Exp $ */ | 1 | /* $NetBSD: systm.h,v 1.228.4.2 2009/03/15 19:43:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1982, 1988, 1991, 1993 | 4 | * Copyright (c) 1982, 1988, 1991, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * (c) UNIX System Laboratories, Inc. | 6 | * (c) UNIX System Laboratories, Inc. | |
7 | * All or some portions of this file are derived from material licensed | 7 | * All or some portions of this file are derived from material licensed | |
8 | * to the University of California by American Telephone and Telegraph | 8 | * to the University of California by American Telephone and Telegraph | |
9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | 9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
10 | * the permission of UNIX System Laboratories, Inc. | 10 | * the permission of UNIX System Laboratories, Inc. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -281,26 +281,28 @@ long fuiword(const void *); | @@ -281,26 +281,28 @@ long fuiword(const void *); | |||
281 | void hardclock(struct clockframe *); | 281 | void hardclock(struct clockframe *); | |
282 | void softclock(void *); | 282 | void softclock(void *); | |
283 | void statclock(struct clockframe *); | 283 | void statclock(struct clockframe *); | |
284 | 284 | |||
285 | #ifdef NTP | 285 | #ifdef NTP | |
286 | void ntp_init(void); | 286 | void ntp_init(void); | |
287 | #ifdef PPS_SYNC | 287 | #ifdef PPS_SYNC | |
288 | void hardpps(struct timespec *, long); | 288 | void hardpps(struct timespec *, long); | |
289 | #endif /* PPS_SYNC */ | 289 | #endif /* PPS_SYNC */ | |
290 | #else | 290 | #else | |
291 | void ntp_init(void); /* also provides adjtime() functionality */ | 291 | void ntp_init(void); /* also provides adjtime() functionality */ | |
292 | #endif /* NTP */ | 292 | #endif /* NTP */ | |
293 | 293 | |||
294 | void ssp_init(void); | |||
295 | ||||
294 | void initclocks(void); | 296 | void initclocks(void); | |
295 | void inittodr(time_t); | 297 | void inittodr(time_t); | |
296 | void resettodr(void); | 298 | void resettodr(void); | |
297 | void cpu_initclocks(void); | 299 | void cpu_initclocks(void); | |
298 | void setrootfstime(time_t); | 300 | void setrootfstime(time_t); | |
299 | 301 | |||
300 | void startprofclock(struct proc *); | 302 | void startprofclock(struct proc *); | |
301 | void stopprofclock(struct proc *); | 303 | void stopprofclock(struct proc *); | |
302 | void proftick(struct clockframe *); | 304 | void proftick(struct clockframe *); | |
303 | void setstatclockrate(int); | 305 | void setstatclockrate(int); | |
304 | 306 | |||
305 | /* | 307 | /* | |
306 | * Shutdown hooks. Functions to be run with all interrupts disabled | 308 | * Shutdown hooks. Functions to be run with all interrupts disabled |