diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index c26e636c81e2..b9889e333b65 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -957,6 +957,13 @@ create_pagetables(vm_paddr_t *firstaddr) pd_p[i] = (i << PDRSHIFT) | X86_PG_RW | X86_PG_V | PG_PS | pg_g; + /* + * Because we map the physical blocks in 2M pages, adjust firstaddr + * to record the physical blocks we've actually mapped into kernel + * virtual address space. + */ + *firstaddr = round_2mpage(*firstaddr); + /* And connect up the PD to the PDP (leaving room for L4 pages) */ pdp_p = (pdp_entry_t *)(KPDPphys + ptoa(KPML4I - KPML4BASE)); for (i = 0; i < nkpdpe; i++)