Move physmem calculations before nptpage initialization.

Fixes mvme68k specific part of PR port-m68k/45915
(panic: pmap_enter_ptpage: can't get KPT page).
Reported and confirmed by Andrew Gillham on his MVME177:
http://mail-index.NetBSD.org/port-mvme68k/2013/09/17/msg000082.html

Should be pulled up to all netbsd-6 branches.
This commit is contained in:
tsutsui 2013-09-19 12:04:36 +00:00
parent 7b5edfdc0d
commit 47d496f11b

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap_bootstrap.c,v 1.51 2012/02/10 06:28:39 mhitch Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.52 2013/09/19 12:04:36 tsutsui Exp $ */
/*
* Copyright (c) 1991, 1993
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.51 2012/02/10 06:28:39 mhitch Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.52 2013/09/19 12:04:36 tsutsui Exp $");
#include "opt_m68k_arch.h"
@ -99,6 +99,42 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
u_int stfree = 0; /* XXX: gcc -Wuninitialized */
#endif
/*
* Initialize the mem_clusters[] array for the crash dump
* code. While we're at it, compute the total amount of
* physical memory in the system.
*/
for (i = 0; i < VM_PHYSSEG_MAX; i++) {
if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
RELOC(phys_seg_list[i].ps_end, paddr_t)) {
/*
* No more memory.
*/
break;
}
/*
* Make sure these are properly rounded.
*/
RELOC(phys_seg_list[i].ps_start, paddr_t) =
m68k_round_page(RELOC(phys_seg_list[i].ps_start,
paddr_t));
RELOC(phys_seg_list[i].ps_end, paddr_t) =
m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
paddr_t));
size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
RELOC(phys_seg_list[i].ps_start, paddr_t);
RELOC(mem_clusters[i].start, u_quad_t) =
RELOC(phys_seg_list[i].ps_start, paddr_t);
RELOC(mem_clusters[i].size, u_quad_t) = size;
RELOC(physmem, int) += size >> PGSHIFT;
RELOC(mem_cluster_cnt, int) += 1;
}
/*
* Calculate important physical addresses:
*
@ -408,42 +444,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
*/
RELOC(lwp0uarea, vaddr_t) = lwp0upa - firstpa;
/*
* Initialize the mem_clusters[] array for the crash dump
* code. While we're at it, compute the total amount of
* physical memory in the system.
*/
for (i = 0; i < VM_PHYSSEG_MAX; i++) {
if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
RELOC(phys_seg_list[i].ps_end, paddr_t)) {
/*
* No more memory.
*/
break;
}
/*
* Make sure these are properly rounded.
*/
RELOC(phys_seg_list[i].ps_start, paddr_t) =
m68k_round_page(RELOC(phys_seg_list[i].ps_start,
paddr_t));
RELOC(phys_seg_list[i].ps_end, paddr_t) =
m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
paddr_t));
size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
RELOC(phys_seg_list[i].ps_start, paddr_t);
RELOC(mem_clusters[i].start, u_quad_t) =
RELOC(phys_seg_list[i].ps_start, paddr_t);
RELOC(mem_clusters[i].size, u_quad_t) = size;
RELOC(physmem, int) += size >> PGSHIFT;
RELOC(mem_cluster_cnt, int) += 1;
}
/*
* Scoot the start of available on-board RAM forward to
* account for: