diff --git a/sys/mips/mips/machdep.c b/sys/mips/mips/machdep.c index 356e52821df..eebe4411712 100644 --- a/sys/mips/mips/machdep.c +++ b/sys/mips/mips/machdep.c @@ -260,8 +260,11 @@ mips_proc0_init(void) { proc_linkup0(&proc0, &thread0); + KASSERT((kstack0 & PAGE_MASK) == 0, + ("kstack0 is not aligned on a page boundary: 0x%0lx", + (long)kstack0)); thread0.td_kstack = kstack0; - thread0.td_kstack_pages = KSTACK_PAGES - 1; + thread0.td_kstack_pages = KSTACK_PAGES; thread0.td_md.md_realstack = roundup2(thread0.td_kstack, PAGE_SIZE * 2); /* * Do not use cpu_thread_alloc to initialize these fields diff --git a/sys/mips/mips/pmap.c b/sys/mips/mips/pmap.c index 137f5fce2fa..671413ba9ba 100644 --- a/sys/mips/mips/pmap.c +++ b/sys/mips/mips/pmap.c @@ -291,6 +291,12 @@ pmap_bootstrap(void) /* Sort. */ again: for (i = 0; phys_avail[i + 1] != 0; i += 2) { + /* + * Keep the memory aligned on page boundary. + */ + phys_avail[i] = round_page(phys_avail[i]); + phys_avail[i + 1] = trunc_page(phys_avail[i + 1]); + if (phys_avail[i + 1] >= MIPS_KSEG0_LARGEST_PHYS) memory_larger_than_512meg++; if (i < 2)