xref: /titanic_52/usr/src/uts/sun4/os/mp_startup.c (revision c2580b931007758eab8cb5ae8726ebe1588e259b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/sysmacros.h>
30 #include <sys/prom_plat.h>
31 #include <sys/prom_debug.h>
32 #include <vm/hat_sfmmu.h>
33 #include <vm/seg_kp.h>
34 #include <vm/seg_kmem.h>
35 #include <sys/machsystm.h>
36 #include <sys/callb.h>
37 #include <sys/cpu_module.h>
38 #include <sys/chip.h>
39 #include <sys/dtrace.h>
40 #include <sys/reboot.h>
41 #include <sys/kdi.h>
42 #include <sys/traptrace.h>
43 #ifdef TRAPTRACE
44 #include <sys/bootconf.h>
45 #endif /* TRAPTRACE */
46 #include <sys/cpu_sgnblk_defs.h>
47 
48 extern void cpu_intrq_setup(struct cpu *);
49 extern void cpu_intrq_cleanup(struct cpu *);
50 extern void cpu_intrq_register(struct cpu *);
51 
52 struct cpu	*cpus;	/* pointer to other cpus; dynamically allocate */
53 struct cpu	*cpu[NCPU];	/* pointers to all CPUs */
54 uint64_t	cpu_pa[NCPU];	/* pointers to all CPUs in PA */
55 cpu_core_t	cpu_core[NCPU];	/* cpu_core structures */
56 
57 #ifdef TRAPTRACE
58 caddr_t	ttrace_buf;	/* bop alloced traptrace for all cpus except 0 */
59 #endif /* TRAPTRACE */
60 
61 /* bit mask of cpus ready for x-calls, protected by cpu_lock */
62 cpuset_t cpu_ready_set;
63 
64 /* bit mask used to communicate with cpus during bringup */
65 static cpuset_t proxy_ready_set;
66 
67 static void	slave_startup(void);
68 
69 /*
70  * Defined in $KARCH/os/mach_mp_startup.c
71  */
72 #pragma weak init_cpu_info
73 
74 /*
75  * Amount of time (in milliseconds) we should wait before giving up on CPU
76  * initialization and assuming that the CPU we're trying to wake up is dead
77  * or out of control.
78  */
79 #define	CPU_WAKEUP_GRACE_MSEC 1000
80 
81 #ifdef	TRAPTRACE
82 /*
83  * This function bop allocs traptrace buffers for all cpus
84  * other than boot cpu.
85  */
86 caddr_t
87 trap_trace_alloc(caddr_t base)
88 {
89 	caddr_t	vaddr;
90 	extern int max_ncpus;
91 
92 	if (max_ncpus == 1) {
93 		return (base);
94 	}
95 
96 	if ((vaddr = (caddr_t)BOP_ALLOC(bootops, base, (TRAP_TSIZE *
97 		(max_ncpus - 1)), TRAP_TSIZE)) == NULL) {
98 		panic("traptrace_alloc: can't bop alloc");
99 	}
100 	ttrace_buf = vaddr;
101 	PRM_DEBUG(ttrace_buf);
102 	return (vaddr + (TRAP_TSIZE * (max_ncpus - 1)));
103 }
104 #endif	/* TRAPTRACE */
105 
106 /*
107  * common slave cpu initialization code
108  */
109 void
110 common_startup_init(cpu_t *cp, int cpuid)
111 {
112 	kthread_id_t tp;
113 	sfmmu_t *sfmmup;
114 	caddr_t	sp;
115 
116 	/*
117 	 * Allocate and initialize the startup thread for this CPU.
118 	 */
119 	tp = thread_create(NULL, 0, slave_startup, NULL, 0, &p0,
120 	    TS_STOPPED, maxclsyspri);
121 
122 	/*
123 	 * Set state to TS_ONPROC since this thread will start running
124 	 * as soon as the CPU comes online.
125 	 *
126 	 * All the other fields of the thread structure are setup by
127 	 * thread_create().
128 	 */
129 	THREAD_ONPROC(tp, cp);
130 	tp->t_preempt = 1;
131 	tp->t_bound_cpu = cp;
132 	tp->t_affinitycnt = 1;
133 	tp->t_cpu = cp;
134 	tp->t_disp_queue = cp->cpu_disp;
135 
136 	sfmmup = astosfmmu(&kas);
137 	CPUSET_ADD(sfmmup->sfmmu_cpusran, cpuid);
138 
139 	/*
140 	 * Setup thread to start in slave_startup.
141 	 */
142 	sp = tp->t_stk;
143 	tp->t_pc = (uintptr_t)slave_startup - 8;
144 	tp->t_sp = (uintptr_t)((struct rwindow *)sp - 1) - STACK_BIAS;
145 
146 	cp->cpu_id = cpuid;
147 	cp->cpu_self = cp;
148 	cp->cpu_thread = tp;
149 	cp->cpu_lwp = NULL;
150 	cp->cpu_dispthread = tp;
151 	cp->cpu_dispatch_pri = DISP_PRIO(tp);
152 	cp->cpu_startup_thread = tp;
153 }
154 
155 /*
156  * parametric flag setting functions.  these routines set the cpu
157  * state just prior to releasing the slave cpu.
158  */
159 void
160 cold_flag_set(int cpuid)
161 {
162 	cpu_t *cp;
163 
164 	ASSERT(MUTEX_HELD(&cpu_lock));
165 
166 	cp = cpu[cpuid];
167 	cp->cpu_flags |= CPU_RUNNING | CPU_ENABLE | CPU_EXISTS;
168 	cpu_add_active(cp);
169 	/*
170 	 * Add CPU_READY after the cpu_add_active() call
171 	 * to avoid pausing cp.
172 	 */
173 	cp->cpu_flags |= CPU_READY;		/* ready */
174 	cpu_set_state(cp);
175 }
176 
177 static void
178 warm_flag_set(int cpuid)
179 {
180 	cpu_t *cp;
181 
182 	ASSERT(MUTEX_HELD(&cpu_lock));
183 
184 	/*
185 	 * warm start activates cpus into the OFFLINE state
186 	 */
187 	cp = cpu[cpuid];
188 	cp->cpu_flags |= CPU_RUNNING | CPU_READY | CPU_EXISTS
189 		| CPU_OFFLINE | CPU_QUIESCED;
190 	cpu_set_state(cp);
191 }
192 
193 /*
194  * Internal cpu startup sequencer
195  * The sequence is as follows:
196  *
197  * MASTER	SLAVE
198  * -------	----------
199  * assume the kernel data is initialized
200  * clear the proxy bit
201  * start the slave cpu
202  * wait for the slave cpu to set the proxy
203  *
204  *		the slave runs slave_startup and then sets the proxy
205  *		the slave waits for the master to add slave to the ready set
206  *
207  * the master finishes the initialization and
208  * adds the slave to the ready set
209  *
210  *		the slave exits the startup thread and is running
211  */
212 void
213 start_cpu(int cpuid, void(*flag_func)(int))
214 {
215 	extern void cpu_startup(int);
216 	int timout;
217 
218 	ASSERT(MUTEX_HELD(&cpu_lock));
219 
220 	/*
221 	 * Before we begin the dance, tell DTrace that we're about to start
222 	 * a CPU.
223 	 */
224 	if (dtrace_cpustart_init != NULL)
225 		(*dtrace_cpustart_init)();
226 
227 	/* start the slave cpu */
228 	CPUSET_DEL(proxy_ready_set, cpuid);
229 	if (prom_test("SUNW,start-cpu-by-cpuid") == 0) {
230 		(void) prom_startcpu_bycpuid(cpuid, (caddr_t)&cpu_startup,
231 		    cpuid);
232 	} else {
233 		/* "by-cpuid" interface didn't exist.  Do it the old way */
234 		pnode_t nodeid = cpunodes[cpuid].nodeid;
235 
236 		ASSERT(nodeid != (pnode_t)0);
237 		(void) prom_startcpu(nodeid, (caddr_t)&cpu_startup, cpuid);
238 	}
239 
240 	/* wait for the slave cpu to check in. */
241 	for (timout = CPU_WAKEUP_GRACE_MSEC; timout; timout--) {
242 		if (CPU_IN_SET(proxy_ready_set, cpuid))
243 			break;
244 		DELAY(1000);
245 	}
246 	if (timout == 0) {
247 		panic("cpu%d failed to start (2)", cpuid);
248 	}
249 
250 	/*
251 	 * The slave has started; we can tell DTrace that it's safe again.
252 	 */
253 	if (dtrace_cpustart_fini != NULL)
254 		(*dtrace_cpustart_fini)();
255 
256 	/* run the master side of stick synchronization for the slave cpu */
257 	sticksync_master();
258 
259 	/*
260 	 * deal with the cpu flags in a phase-specific manner
261 	 * for various reasons, this needs to run after the slave
262 	 * is checked in but before the slave is released.
263 	 */
264 	(*flag_func)(cpuid);
265 
266 	/* release the slave */
267 	CPUSET_ADD(cpu_ready_set, cpuid);
268 }
269 
270 #ifdef TRAPTRACE
271 int trap_tr0_inuse = 1;	/* it is always used on the boot cpu */
272 int trap_trace_inuse[NCPU];
273 #endif /* TRAPTRACE */
274 
275 #define	cpu_next_free	cpu_prev
276 
277 /*
278  * Routine to set up a CPU to prepare for starting it up.
279  */
280 void
281 setup_cpu_common(int cpuid)
282 {
283 	struct cpu *cp = NULL;
284 	kthread_id_t tp;
285 #ifdef TRAPTRACE
286 	int tt_index;
287 	TRAP_TRACE_CTL	*ctlp;
288 	caddr_t	newbuf;
289 #endif /* TRAPTRACE */
290 
291 	extern void idle();
292 
293 	ASSERT(MUTEX_HELD(&cpu_lock));
294 	ASSERT(cpu[cpuid] == NULL);
295 
296 	ASSERT(ncpus <= max_ncpus);
297 
298 #ifdef TRAPTRACE
299 	/*
300 	 * allocate a traptrace buffer for this CPU.
301 	 */
302 	ctlp = &trap_trace_ctl[cpuid];
303 	if (!trap_tr0_inuse) {
304 		trap_tr0_inuse = 1;
305 		newbuf = trap_tr0;
306 		tt_index = -1;
307 	} else {
308 		for (tt_index = 0; tt_index < (max_ncpus-1); tt_index++)
309 			if (!trap_trace_inuse[tt_index])
310 			    break;
311 		ASSERT(tt_index < max_ncpus - 1);
312 		trap_trace_inuse[tt_index] = 1;
313 		newbuf = (caddr_t)(ttrace_buf + (tt_index * TRAP_TSIZE));
314 	}
315 	ctlp->d.vaddr_base = newbuf;
316 	ctlp->d.offset = ctlp->d.last_offset = 0;
317 	ctlp->d.limit = trap_trace_bufsize;
318 	ctlp->d.paddr_base = va_to_pa(newbuf);
319 	ASSERT(ctlp->d.paddr_base != (uint64_t)-1);
320 #endif /* TRAPTRACE */
321 	/*
322 	 * initialize hv traptrace buffer for this CPU
323 	 */
324 	mach_htraptrace_setup(cpuid);
325 
326 	/*
327 	 * Obtain pointer to the appropriate cpu structure.
328 	 */
329 	if (cpu0.cpu_flags == 0) {
330 		cp = &cpu0;
331 	} else {
332 		/*
333 		 *  When dynamically allocating cpu structs,
334 		 *  cpus is used as a pointer to a list of freed
335 		 *  cpu structs.
336 		 */
337 		if (cpus) {
338 			/* grab the first cpu struct on the free list */
339 			cp = cpus;
340 			if (cp->cpu_next_free)
341 				cpus = cp->cpu_next_free;
342 			else
343 				cpus = NULL;
344 		}
345 	}
346 
347 	if (cp == NULL)
348 		cp = vmem_xalloc(static_alloc_arena, CPU_ALLOC_SIZE,
349 		    CPU_ALLOC_SIZE, 0, 0, NULL, NULL, VM_SLEEP);
350 
351 	bzero(cp, sizeof (*cp));
352 
353 	cp->cpu_id = cpuid;
354 	cp->cpu_self = cp;
355 
356 	/*
357 	 * Initialize ptl1_panic stack
358 	 */
359 	ptl1_init_cpu(cp);
360 
361 	/*
362 	 * Initialize the dispatcher for this CPU.
363 	 */
364 	disp_cpu_init(cp);
365 
366 	cpu_vm_data_init(cp);
367 
368 	/*
369 	 * Now, initialize per-CPU idle thread for this CPU.
370 	 */
371 	tp = thread_create(NULL, 0, idle, NULL, 0, &p0, TS_ONPROC, -1);
372 
373 	cp->cpu_idle_thread = tp;
374 
375 	tp->t_preempt = 1;
376 	tp->t_bound_cpu = cp;
377 	tp->t_affinitycnt = 1;
378 	tp->t_cpu = cp;
379 	tp->t_disp_queue = cp->cpu_disp;
380 
381 	/*
382 	 * Registering a thread in the callback table is usually
383 	 * done in the initialization code of the thread. In this
384 	 * case, we do it right after thread creation to avoid
385 	 * blocking idle thread while registering itself. It also
386 	 * avoids the possibility of reregistration in case a CPU
387 	 * restarts its idle thread.
388 	 */
389 	CALLB_CPR_INIT_SAFE(tp, "idle");
390 
391 	init_cpu_info(cp);
392 
393 	/*
394 	 * Initialize the interrupt threads for this CPU
395 	 */
396 	cpu_intr_alloc(cp, NINTR_THREADS);
397 
398 	/*
399 	 * Add CPU to list of available CPUs.
400 	 * It'll be on the active list after it is started.
401 	 */
402 	cpu_add_unit(cp);
403 
404 	/*
405 	 * Allocate and init cpu module private data structures,
406 	 * including scrubber.
407 	 */
408 	cpu_init_private(cp);
409 
410 	/*
411 	 * Associate this CPU with a physical processor
412 	 */
413 	chip_cpu_init(cp);
414 
415 	cpu_intrq_setup(cp);
416 
417 	/*
418 	 * Initialize MMU context domain information.
419 	 */
420 	sfmmu_cpu_init(cp);
421 
422 }
423 
424 /*
425  * Routine to clean up a CPU after shutting it down.
426  */
427 int
428 cleanup_cpu_common(int cpuid)
429 {
430 	struct cpu *cp;
431 #ifdef TRAPTRACE
432 	int i;
433 	TRAP_TRACE_CTL	*ctlp;
434 	caddr_t	newbuf;
435 #endif /* TRAPTRACE */
436 
437 	ASSERT(MUTEX_HELD(&cpu_lock));
438 	ASSERT(cpu[cpuid] != NULL);
439 
440 	cp = cpu[cpuid];
441 
442 	/* Free cpu module private data structures, including scrubber. */
443 	cpu_uninit_private(cp);
444 
445 	/* Free cpu ID string and brand string. */
446 	kmem_free(cp->cpu_idstr, strlen(cp->cpu_idstr) + 1);
447 	kmem_free(cp->cpu_brandstr, strlen(cp->cpu_brandstr) + 1);
448 
449 	cpu_vm_data_destroy(cp);
450 
451 	/*
452 	 * Remove CPU from list of available CPUs.
453 	 */
454 	cpu_del_unit(cpuid);
455 
456 	/*
457 	 * Clean any machine specific interrupt states.
458 	 */
459 	cpu_intrq_cleanup(cp);
460 
461 	/*
462 	 * At this point, the only threads bound to this CPU should be
463 	 * special per-cpu threads: it's idle thread, it's pause thread,
464 	 * and it's interrupt threads.  Clean these up.
465 	 */
466 	cpu_destroy_bound_threads(cp);
467 
468 	/*
469 	 * Free the interrupt stack.
470 	 */
471 	segkp_release(segkp, cp->cpu_intr_stack);
472 
473 	/*
474 	 * Free hv traptrace buffer for this CPU.
475 	 */
476 	mach_htraptrace_cleanup(cpuid);
477 #ifdef TRAPTRACE
478 	/*
479 	 * Free the traptrace buffer for this CPU.
480 	 */
481 	ctlp = &trap_trace_ctl[cpuid];
482 	newbuf = ctlp->d.vaddr_base;
483 	i = (newbuf - ttrace_buf) / (TRAP_TSIZE);
484 	if (((newbuf - ttrace_buf) % (TRAP_TSIZE) == 0) &&
485 	    ((i >= 0) && (i < (max_ncpus-1)))) {
486 		/*
487 		 * This CPU got it's trap trace buffer from the
488 		 * boot-alloc'd bunch of them.
489 		 */
490 		trap_trace_inuse[i] = 0;
491 		bzero(newbuf, (TRAP_TSIZE));
492 	} else if (newbuf == trap_tr0) {
493 		trap_tr0_inuse = 0;
494 		bzero(trap_tr0, (TRAP_TSIZE));
495 	} else {
496 		cmn_err(CE_WARN, "failed to free trap trace buffer from cpu%d",
497 		    cpuid);
498 	}
499 	bzero(ctlp, sizeof (*ctlp));
500 #endif /* TRAPTRACE */
501 
502 	/*
503 	 * There is a race condition with mutex_vector_enter() which
504 	 * caches a cpu pointer. The race is detected by checking cpu_next.
505 	 */
506 	disp_cpu_fini(cp);
507 	cpu_pa[cpuid] = 0;
508 	sfmmu_cpu_cleanup(cp);
509 	bzero(cp, sizeof (*cp));
510 
511 	/*
512 	 * Place the freed cpu structure on the list of freed cpus.
513 	 */
514 	if (cp != &cpu0) {
515 		if (cpus) {
516 			cp->cpu_next_free = cpus;
517 			cpus = cp;
518 		}
519 		else
520 			cpus = cp;
521 	}
522 
523 	return (0);
524 }
525 
526 /*
527  * This routine is used to start a previously powered off processor.
528  * Note that restarted cpus are initialized into the offline state.
529  */
530 void
531 restart_other_cpu(int cpuid)
532 {
533 	struct cpu *cp;
534 	kthread_id_t tp;
535 	caddr_t	sp;
536 	extern void idle();
537 
538 	ASSERT(MUTEX_HELD(&cpu_lock));
539 	ASSERT(cpuid < NCPU && cpu[cpuid] != NULL);
540 
541 	/*
542 	 * Obtain pointer to the appropriate cpu structure.
543 	 */
544 	cp = cpu[cpuid];
545 
546 	common_startup_init(cp, cpuid);
547 
548 	/*
549 	 * idle thread t_lock is held when the idle thread is suspended.
550 	 * Manually unlock the t_lock of idle loop so that we can resume
551 	 * the suspended idle thread.
552 	 * Also adjust the PC of idle thread for re-retry.
553 	 */
554 	cp->cpu_intr_actv = 0;	/* clear the value from previous life */
555 	cp->cpu_m.mutex_ready = 0; /* we are not ready yet */
556 	lock_clear(&cp->cpu_idle_thread->t_lock);
557 	tp = cp->cpu_idle_thread;
558 
559 	sp = tp->t_stk;
560 	tp->t_sp = (uintptr_t)((struct rwindow *)sp - 1) - STACK_BIAS;
561 	tp->t_pc = (uintptr_t)idle - 8;
562 
563 	/*
564 	 * restart the cpu now
565 	 */
566 	promsafe_pause_cpus();
567 	start_cpu(cpuid, warm_flag_set);
568 	start_cpus();
569 
570 	/* call cmn_err outside pause_cpus/start_cpus to avoid deadlock */
571 	cmn_err(CE_CONT, "!cpu%d initialization complete - restarted\n",
572 	    cpuid);
573 }
574 
575 /*
576  * Startup function executed on 'other' CPUs.  This is the first
577  * C function after cpu_start sets up the cpu registers.
578  */
579 static void
580 slave_startup(void)
581 {
582 	struct cpu	*cp = CPU;
583 	ushort_t	original_flags = cp->cpu_flags;
584 
585 	mach_htraptrace_configure(cp->cpu_id);
586 	cpu_intrq_register(CPU);
587 	cp->cpu_m.mutex_ready = 1;
588 	cp->cpu_m.poke_cpu_outstanding = B_FALSE;
589 
590 	/* acknowledge that we are done with initialization */
591 	CPUSET_ADD(proxy_ready_set, cp->cpu_id);
592 
593 	/* synchronize STICK */
594 	sticksync_slave();
595 
596 	if (boothowto & RB_DEBUG)
597 		kdi_dvec_cpu_init(cp);
598 
599 	/*
600 	 * the slave will wait here forever -- assuming that the master
601 	 * will get back to us.  if it doesn't we've got bigger problems
602 	 * than a master not replying to this slave.
603 	 * the small delay improves the slave's responsiveness to the
604 	 * master's ack and decreases the time window between master and
605 	 * slave operations.
606 	 */
607 	while (!CPU_IN_SET(cpu_ready_set, cp->cpu_id))
608 		DELAY(1);
609 
610 	/* enable interrupts */
611 	(void) spl0();
612 
613 	/*
614 	 * Signature block update to indicate that this CPU is in OS now.
615 	 * This needs to be done after the PIL is lowered since on
616 	 * some platforms the update code may block.
617 	 */
618 	CPU_SIGNATURE(OS_SIG, SIGST_RUN, SIGSUBST_NULL, cp->cpu_id);
619 
620 	/*
621 	 * park the slave thread in a safe/quiet state and wait for the master
622 	 * to finish configuring this CPU before proceeding to thread_exit().
623 	 */
624 	while (((volatile ushort_t)cp->cpu_flags) & CPU_QUIESCED)
625 		DELAY(1);
626 
627 	/*
628 	 * Initialize CPC CPU state.
629 	 */
630 	kcpc_hw_startup_cpu(original_flags);
631 
632 	/*
633 	 * Notify the CMT subsystem that the slave has started
634 	 */
635 	chip_cpu_startup(CPU);
636 
637 	/*
638 	 * Now we are done with the startup thread, so free it up.
639 	 */
640 	thread_exit();
641 	cmn_err(CE_PANIC, "slave_startup: cannot return");
642 	/*NOTREACHED*/
643 }
644 
645 extern struct cpu	*cpu[NCPU];	/* pointers to all CPUs */
646 
647 extern void setup_cpu_common(int);
648 extern void common_startup_init(cpu_t *, int);
649 extern void start_cpu(int, void(*func)(int));
650 extern void cold_flag_set(int cpuid);
651 
652 /*
653  * cpu_bringup_set is a tunable (via /etc/system, debugger, etc.) that
654  * can be used during debugging to control which processors are brought
655  * online at boot time.  The variable represents a bitmap of the id's
656  * of the processors that will be brought online.  The initialization
657  * of this variable depends on the type of cpuset_t, which varies
658  * depending on the number of processors supported (see cpuvar.h).
659  */
660 cpuset_t cpu_bringup_set;
661 
662 
663 /*
664  * Generic start-all cpus entry.  Typically used during cold initialization.
665  * Note that cold start cpus are initialized into the online state.
666  */
667 /*ARGSUSED*/
668 void
669 start_other_cpus(int flag)
670 {
671 	int cpuid;
672 	extern void idlestop_init(void);
673 	int bootcpu;
674 
675 	/*
676 	 * Check if cpu_bringup_set has been explicitly set before
677 	 * initializing it.
678 	 */
679 	if (CPUSET_ISNULL(cpu_bringup_set)) {
680 #ifdef MPSAS
681 		/* just CPU 0 */
682 		CPUSET_ADD(cpu_bringup_set, 0);
683 #else
684 		CPUSET_ALL(cpu_bringup_set);
685 #endif
686 	}
687 
688 	if (&cpu_feature_init)
689 		cpu_feature_init();
690 
691 	/*
692 	 * Initialize CPC.
693 	 */
694 	kcpc_hw_init();
695 
696 	mutex_enter(&cpu_lock);
697 
698 	/*
699 	 * Initialize our own cpu_info.
700 	 */
701 	init_cpu_info(CPU);
702 
703 	/*
704 	 * Initialize CPU 0 cpu module private data area, including scrubber.
705 	 */
706 	cpu_init_private(CPU);
707 
708 	/*
709 	 * perform such initialization as is needed
710 	 * to be able to take CPUs on- and off-line.
711 	 */
712 	cpu_pause_init();
713 	xc_init();		/* initialize processor crosscalls */
714 	idlestop_init();
715 
716 	if (!use_mp) {
717 		mutex_exit(&cpu_lock);
718 		cmn_err(CE_CONT, "?***** Not in MP mode\n");
719 		return;
720 	}
721 	/*
722 	 * should we be initializing this cpu?
723 	 */
724 	bootcpu = getprocessorid();
725 
726 	/*
727 	 * launch all the slave cpus now
728 	 */
729 	for (cpuid = 0; cpuid < NCPU; cpuid++) {
730 		pnode_t nodeid = cpunodes[cpuid].nodeid;
731 
732 		if (nodeid == (pnode_t)0)
733 			continue;
734 
735 		if (cpuid == bootcpu) {
736 			if (!CPU_IN_SET(cpu_bringup_set, cpuid)) {
737 				cmn_err(CE_WARN, "boot cpu not a member "
738 				    "of cpu_bringup_set, adding it");
739 				CPUSET_ADD(cpu_bringup_set, cpuid);
740 			}
741 			continue;
742 		}
743 		if (!CPU_IN_SET(cpu_bringup_set, cpuid))
744 			continue;
745 
746 		ASSERT(cpu[cpuid] == NULL);
747 
748 		setup_cpu_common(cpuid);
749 
750 		common_startup_init(cpu[cpuid], cpuid);
751 
752 		start_cpu(cpuid, cold_flag_set);
753 		/*
754 		 * Because slave_startup() gets fired off after init()
755 		 * starts, we can't use the '?' trick to do 'boot -v'
756 		 * printing - so we always direct the 'cpu .. online'
757 		 * messages to the log.
758 		 */
759 		cmn_err(CE_CONT, "!cpu%d initialization complete - online\n",
760 		    cpuid);
761 
762 		/*
763 		 * XXX: register_cpu_setup() callbacks should be called here
764 		 * with a new setup code, CPU_BOOT (or something).
765 		 */
766 		if (dtrace_cpu_init != NULL)
767 			(*dtrace_cpu_init)(cpuid);
768 	}
769 
770 	/*
771 	 * since all the cpus are online now, redistribute interrupts to them.
772 	 */
773 	intr_redist_all_cpus();
774 
775 	mutex_exit(&cpu_lock);
776 
777 	/*
778 	 * Start the Ecache scrubber.  Must be done after all calls to
779 	 * cpu_init_private for every cpu (including CPU 0).
780 	 */
781 	cpu_init_cache_scrub();
782 
783 	if (&cpu_mp_init)
784 		cpu_mp_init();
785 }
786