cpu_attach(): in the MP case, fix up idle lwp info as well as lwp0.l_cpu.

for LOCKDEBUG, mutex_destroy() the cpu0 spc_lwplock with the global
cpuinfo VA, and re-mutex_init() it with the per-cpu address that is only
now available.  for non-boot cpus, be sure to also initialise curlwp to
the idle lwp.

xcall(), pmap_quiet_check(), pmap_pmap_pool_ctor(), pmap_pmap_pool_dtor(),
and pmap_enu4m(): don't care about cpus that have not been attached yet.
This commit is contained in:
mrg 2007-05-28 21:24:17 +00:00
parent 8f8cea5c68
commit 839b86dc5e
2 changed files with 43 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.202 2007/05/19 23:04:48 mrg Exp $ */
/* $NetBSD: cpu.c,v 1.203 2007/05/28 21:24:17 mrg Exp $ */
/*
* Copyright (c) 1996
@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.202 2007/05/19 23:04:48 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.203 2007/05/28 21:24:17 mrg Exp $");
#include "opt_multiprocessor.h"
#include "opt_lockdebug.h"
@ -425,10 +425,20 @@ cpu_attach(struct cpu_softc *sc, int node, int mid)
*/
cpi = sc->sc_cpuinfo = alloc_cpuinfo_global_va(1, NULL);
pmap_globalize_boot_cpuinfo(cpi);
cpuinfo.ci_self = cpi;
/* XXX - fixup lwp.l_cpu */
/* XXX - fixup lwp0 and idlelwp l_cpu */
lwp0.l_cpu = cpi;
cpi->ci_data.cpu_idlelwp->l_cpu = cpi;
cpi->ci_data.cpu_idlelwp->l_mutex =
&cpi->ci_schedstate.spc_lwplock;
#if defined(LOCKDEBUG)
/* XXX */
mutex_destroy(&cpuinfo.ci_schedstate.spc_lwplock);
mutex_init(&cpi->ci_schedstate.spc_lwplock, MUTEX_SPIN, IPL_SCHED);
#endif
#else
/* The `local' VA is global for uniprocessor. */
cpi = sc->sc_cpuinfo = (struct cpu_info *)CPUINFO_VA;
@ -469,7 +479,8 @@ cpu_attach(struct cpu_softc *sc, int node, int mid)
* Note: `eintstack' is set in alloc_cpuinfo() above.
* The %wim register will be initialized in cpu_hatch().
*/
cpi->curpcb = (struct pcb *)cpi->ci_data.cpu_idlelwp->l_addr;
cpi->ci_curlwp = cpi->ci_data.cpu_idlelwp;
cpi->curpcb = (struct pcb *)cpi->ci_curlwp->l_addr;
cpi->curpcb->pcb_wim = 1;
getcpuinfo(cpi, node);
@ -711,6 +722,9 @@ xcall(xcall_func_t func, xcall_trap_t trap, int arg0, int arg1, int arg2,
for (n = 0; n < sparc_ncpus; n++) {
struct cpu_info *cpi = cpus[n];
if (!cpi)
continue;
/* Note: n == cpi->ci_cpuid */
if ((cpuset & (1 << n)) == 0)
continue;
@ -751,7 +765,7 @@ xcall(xcall_func_t func, xcall_trap_t trap, int arg0, int arg1, int arg2,
for (n = 0; n < sparc_ncpus; n++) {
struct cpu_info *cpi = cpus[n];
if ((cpuset & (1 << n)) == 0)
if (!cpi || (cpuset & (1 << n)) == 0)
continue;
if (cpi->msg.complete == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.315 2007/05/17 14:51:30 yamt Exp $ */
/* $NetBSD: pmap.c,v 1.316 2007/05/28 21:24:18 mrg Exp $ */
/*
* Copyright (c) 1996
@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.315 2007/05/17 14:51:30 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.316 2007/05/28 21:24:18 mrg Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -4153,6 +4153,10 @@ pmap_quiet_check(struct pmap *pm)
n = 0;
#endif
{
#if defined(MULTIPROCESSOR)
if (cpus[n] == NULL)
continue;
#endif
if (pm->pm_reg_ptps[n][vr] != SRMMU_TEINVALID)
printf("pmap_chk: spurious PTP in user "
"region %d on CPU %d\n", vr, n);
@ -4267,6 +4271,10 @@ pmap_pmap_pool_ctor(void *arg, void *object, int flags)
{
int *upt, *kpt;
#if defined(MULTIPROCESSOR)
if (cpus[n] == NULL)
continue;
#endif
upt = pool_get(&L1_pool, flags);
pm->pm_reg_ptps[n] = upt;
pm->pm_reg_ptps_pa[n] = VA2PA((char *)upt);
@ -4317,6 +4325,10 @@ pmap_pmap_pool_dtor(void *arg, void *object)
n = 0;
#endif
{
#if defined(MULTIPROCESSOR)
if (cpus[n] == NULL)
continue;
#endif
int *pt = pm->pm_reg_ptps[n];
pm->pm_reg_ptps[n] = NULL;
pm->pm_reg_ptps_pa[n] = 0;
@ -4498,9 +4510,14 @@ pgt_lvl23_remove4m(struct pmap *pm, struct regmap *rp, struct segmap *sp,
PMAP_CPUSET(pm));
#ifdef MULTIPROCESSOR
/* Invalidate level 1 PTP entries on all CPUs */
for (; n < sparc_ncpus; n++)
for (; n < sparc_ncpus; n++) {
if (cpus[n] == NULL)
continue;
#endif
setpgt4m(&pm->pm_reg_ptps[n][vr], SRMMU_TEINVALID);
#ifdef MULTIPROCESSOR
}
#endif
pool_put(&segmap_pool, rp->rg_segmap);
rp->rg_segmap = NULL;
@ -6342,6 +6359,10 @@ pmap_enu4m(struct pmap *pm, vaddr_t va, vm_prot_t prot, int flags,
i = 0;
#endif
{
#if defined(MULTIPROCESSOR)
if (cpus[i] == NULL)
continue;
#endif
setpgt4m(&pm->pm_reg_ptps[i][vr],
(VA2PA((void *)ptd) >> SRMMU_PPNPASHIFT) |
SRMMU_TEPTD);