From 2c61985659ddca6abea7803312a06305314e6399 Mon Sep 17 00:00:00 2001 From: mhitch Date: Fri, 10 Feb 2012 04:49:44 +0000 Subject: [PATCH] The recent kmem changes allocate a large kernel address space before pmap_init() is called, and the initial kernel PT pages aren't enough for the allocations pmap_init(). This fails because pmap_kenter_pa() tries to allocate a new kernel PT page and traps because the pmap has not been initialized. When computing the number if initial kernel PT pages, include enough to allow kmem to map the physical memory. This should fix PR/45915. OK by releng@. One mac68k system has been verified to boot. Volunteers to test the others welcome. Amigas with at least up to 128MB of memory were OK, but larger memory will need some adjusting. --- sys/arch/atari/atari/atari_init.c | 10 ++++++++-- sys/arch/cesfic/cesfic/pmap_bootstrap.c | 6 +++--- sys/arch/hp300/hp300/pmap_bootstrap.c | 6 +++--- sys/arch/luna68k/luna68k/pmap_bootstrap.c | 6 +++--- sys/arch/mac68k/mac68k/pmap_bootstrap.c | 14 ++++++++++++-- sys/arch/mvme68k/mvme68k/pmap_bootstrap.c | 7 ++++--- sys/arch/news68k/news68k/pmap_bootstrap.c | 6 +++--- sys/arch/next68k/next68k/pmap_bootstrap.c | 6 +++--- sys/arch/x68k/x68k/pmap_bootstrap.c | 6 +++--- 9 files changed, 42 insertions(+), 25 deletions(-) diff --git a/sys/arch/atari/atari/atari_init.c b/sys/arch/atari/atari/atari_init.c index adead4d5e545..af8e1cc8708a 100644 --- a/sys/arch/atari/atari/atari_init.c +++ b/sys/arch/atari/atari/atari_init.c @@ -1,4 +1,4 @@ -/* $NetBSD: atari_init.c,v 1.97 2012/01/27 18:52:52 para Exp $ */ +/* $NetBSD: atari_init.c,v 1.98 2012/02/10 04:49:44 mhitch Exp $ */ /* * Copyright (c) 1995 Leo Weppelman @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.97 2012/01/27 18:52:52 para Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.98 2012/02/10 04:49:44 mhitch Exp $"); #include "opt_ddb.h" #include "opt_mbtype.h" @@ -322,6 +322,12 @@ start_c(int id, u_int ttphystart, u_int ttphysize, u_int stphysize, if (machineid & ATARI_MILAN) ptextra += btoc(PCI_IO_SIZE + PCI_MEM_SIZE); ptextra += btoc(BOOTM_VA_POOL); + /* + * now need to account for the kmem area, which is allocated + * before pmap_init() is called. It is roughly the size of physical + * memory. + */ + ptextra += physmem; /* * The 'pt' (the initial kernel pagetable) has to map the kernel and diff --git a/sys/arch/cesfic/cesfic/pmap_bootstrap.c b/sys/arch/cesfic/cesfic/pmap_bootstrap.c index a6d65c61f87d..4f673dccaf54 100644 --- a/sys/arch/cesfic/cesfic/pmap_bootstrap.c +++ b/sys/arch/cesfic/cesfic/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.31 2011/01/02 18:48:05 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.32 2012/02/10 04:49:45 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.31 2011/01/02 18:48:05 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.32 2012/02/10 04:49:45 mhitch Exp $"); #include #include @@ -120,7 +120,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) lkptpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int); + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG); nextpa += nptpages * PAGE_SIZE; /* diff --git a/sys/arch/hp300/hp300/pmap_bootstrap.c b/sys/arch/hp300/hp300/pmap_bootstrap.c index d2d3186dbd17..e07bbdad4cc4 100644 --- a/sys/arch/hp300/hp300/pmap_bootstrap.c +++ b/sys/arch/hp300/hp300/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.54 2011/01/06 14:19:54 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.55 2012/02/10 04:49:45 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.54 2011/01/06 14:19:54 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.55 2012/02/10 04:49:45 mhitch Exp $"); #include #include @@ -126,7 +126,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) lkptpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int) + + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG) + (IIOMAPSIZE + EIOMAPSIZE + NPTEPG - 1) / NPTEPG; nextpa += nptpages * PAGE_SIZE; diff --git a/sys/arch/luna68k/luna68k/pmap_bootstrap.c b/sys/arch/luna68k/luna68k/pmap_bootstrap.c index ef7421514888..86c80540b48e 100644 --- a/sys/arch/luna68k/luna68k/pmap_bootstrap.c +++ b/sys/arch/luna68k/luna68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.32 2011/01/02 18:48:06 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.33 2012/02/10 04:49:45 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.32 2011/01/02 18:48:06 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.33 2012/02/10 04:49:45 mhitch Exp $"); #include "opt_m68k_arch.h" @@ -125,7 +125,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) kptmpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int) + + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG) + (iiomapsize + NPTEPG - 1) / NPTEPG; nextpa += nptpages * PAGE_SIZE; diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c index 1922ef1bc77b..2ecbd144d9ac 100644 --- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c +++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.92 2011/01/02 18:48:06 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.93 2012/02/10 04:49:45 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.92 2011/01/02 18:48:06 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.93 2012/02/10 04:49:45 mhitch Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -156,6 +156,16 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) kptpa = nextpa; nptpages = Sysptsize + (IIOMAPSIZE + ROMMAPSIZE + VIDMAPSIZE + NPTEPG - 1) / NPTEPG; + /* + * New kmem arena is allocated prior to pmap_init(), so we need + * additiona PT pages to account for that allocation, which is based + * on physical memory size. Just sum up memory and add enough PT + * pages for that size. + */ + mem_size = 0; + for (i = 0; i < numranges; i++) + mem_size += high[i] - low[i]; + nptpages += howmany(m68k_btop(mem_size), NPTEPG); nextpa += nptpages * PAGE_SIZE; for (i = 0; i < numranges; i++) diff --git a/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c b/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c index 4bff446a6d75..1a5c6cb44503 100644 --- a/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c +++ b/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.48 2011/01/02 18:48:06 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.49 2012/02/10 04:49:45 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.48 2011/01/02 18:48:06 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.49 2012/02/10 04:49:45 mhitch Exp $"); #include "opt_m68k_arch.h" @@ -135,7 +135,8 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) kptmpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int) + (iiomappages + NPTEPG - 1) / NPTEPG; + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG) + + (iiomappages + NPTEPG - 1) / NPTEPG; nextpa += nptpages * PAGE_SIZE; /* diff --git a/sys/arch/news68k/news68k/pmap_bootstrap.c b/sys/arch/news68k/news68k/pmap_bootstrap.c index 0b44b5b0e1b1..0c946123d87b 100644 --- a/sys/arch/news68k/news68k/pmap_bootstrap.c +++ b/sys/arch/news68k/news68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.37 2011/11/20 15:38:00 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.38 2012/02/10 04:49:45 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.37 2011/11/20 15:38:00 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.38 2012/02/10 04:49:45 mhitch Exp $"); #include "opt_m68k_arch.h" @@ -138,7 +138,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) kptmpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int) + + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG) + (iiomapsize + eiomapsize + NPTEPG - 1) / NPTEPG; nextpa += nptpages * PAGE_SIZE; diff --git a/sys/arch/next68k/next68k/pmap_bootstrap.c b/sys/arch/next68k/next68k/pmap_bootstrap.c index 6a85a411ebdd..620a7597f6e2 100644 --- a/sys/arch/next68k/next68k/pmap_bootstrap.c +++ b/sys/arch/next68k/next68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.39 2011/01/02 18:48:07 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.40 2012/02/10 04:49:46 mhitch Exp $ */ /* * This file was taken from mvme68k/mvme68k/pmap_bootstrap.c @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.39 2011/01/02 18:48:07 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.40 2012/02/10 04:49:46 mhitch Exp $"); #include "opt_m68k_arch.h" @@ -147,7 +147,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) lkptpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int) + + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG) + (IIOMAPSIZE + MONOMAPSIZE + COLORMAPSIZE + NPTEPG - 1) / NPTEPG; nextpa += nptpages * PAGE_SIZE; diff --git a/sys/arch/x68k/x68k/pmap_bootstrap.c b/sys/arch/x68k/x68k/pmap_bootstrap.c index 7d79dc32fa3c..be4d71c1b155 100644 --- a/sys/arch/x68k/x68k/pmap_bootstrap.c +++ b/sys/arch/x68k/x68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_bootstrap.c,v 1.55 2011/05/14 10:19:58 tsutsui Exp $ */ +/* $NetBSD: pmap_bootstrap.c,v 1.56 2012/02/10 04:49:46 mhitch Exp $ */ /* * Copyright (c) 1991, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.55 2011/05/14 10:19:58 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.56 2012/02/10 04:49:46 mhitch Exp $"); #include "opt_m68k_arch.h" @@ -122,7 +122,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa) kptmpa = nextpa; nextpa += PAGE_SIZE; kptpa = nextpa; - nptpages = RELOC(Sysptsize, int) + + nptpages = RELOC(Sysptsize, int) + howmany(physmem, NPTEPG) + (IIOMAPSIZE + NPTEPG - 1) / NPTEPG; nextpa += nptpages * PAGE_SIZE;