diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c index 0fd13f73a18027..a0d3651ba266e2 100644 --- a/sys/vm/vm_init.c +++ b/sys/vm/vm_init.c @@ -100,6 +100,24 @@ long physmem; static void vm_mem_init(void *); SYSINIT(vm_mem, SI_SUB_VM, SI_ORDER_FIRST, vm_mem_init, NULL); +#ifdef INVARIANTS +/* + * Ensure that pmap_init() correctly initialized pagesizes[]. + */ +static void +vm_check_pagesizes(void) +{ + int i; + + KASSERT(pagesizes[0] == PAGE_SIZE, ("pagesizes[0] != PAGE_SIZE")); + for (i = 1; i < MAXPAGESIZES; i++) { + KASSERT((pagesizes[i - 1] != 0 && + pagesizes[i - 1] < pagesizes[i]) || pagesizes[i] == 0, + ("pagesizes[%d ... %d] are misconfigured", i - 1, i)); + } +} +#endif + /* * vm_mem_init() initializes the virtual memory system. * This is done only by the first cpu up. @@ -140,6 +158,10 @@ vm_mem_init(void *dummy) kmem_init_zero_region(); pmap_init(); vm_pager_init(); + +#ifdef INVARIANTS + vm_check_pagesizes(); +#endif } void