On amd64 we try to guarantee that VA = PA + KERNBASE in the bootstrap

memory. But we have a problem with the ISA I/O MEM, because its va is
located above the kernel and its pa below it, so it does not respect
the rule.

To compensate for that we make the map look like the ISA stuff is above
the kernel by applying an offset on the pa. The issue with this design is
that we systematically lose 96 pages of physical memory.

Fix this by applying the offset on the va instead. Now these 96 pages are
internalized into uvm, and the rule is respected until kern_end.
This commit is contained in:
maxv 2016-12-09 17:57:24 +00:00
parent c035549e68
commit 1311bb81d9
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.115 2016/12/06 15:05:07 maxv Exp $ */
/* $NetBSD: locore.S,v 1.116 2016/12/09 17:57:24 maxv Exp $ */
/*
* Copyright-o-rama!
@ -592,6 +592,8 @@ no_NOX:
*
* (PROC0 STK + L4 + L3 + L2 + L1) is later referred to as BOOTSTRAP TABLES.
*
* ISA I/O MEM has no physical page allocated here, just virtual addresses.
*
* Important note: the kernel segments are properly 4k-aligned
* (see kern.ldscript), so there's no need to enforce alignment.
*/
@ -864,8 +866,8 @@ longmode_hi:
movw %ax,%gs
movw %ax,%fs
/* XXX merge these */
leaq (TABLESIZE+IOM_SIZE)(%rsi),%rdi
/* The first physical page available. */
leaq (TABLESIZE)(%rsi),%rdi
#else /* XEN */
/* First, reset the PSL. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.234 2016/11/25 11:57:36 maxv Exp $ */
/* $NetBSD: machdep.c,v 1.235 2016/12/09 17:57:24 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.234 2016/11/25 11:57:36 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.235 2016/12/09 17:57:24 maxv Exp $");
/* #define XENDEBUG_LOW */
@ -1608,7 +1608,7 @@ init_x86_64(paddr_t first_avail)
#endif /* !XEN */
/* End of the virtual space we have created so far. */
kern_end = KERNBASE + first_avail;
kern_end = (vaddr_t)atdevbase + IOM_SIZE;
#ifndef XEN
/* The area for the module map. */