Module Name: src Committed By: maxv Date: Fri Dec 9 17:57:24 UTC 2016
Modified Files: src/sys/arch/amd64/amd64: locore.S machdep.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.234 -r1.235 src/sys/arch/amd64/amd64/machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.115 src/sys/arch/amd64/amd64/locore.S:1.116 --- src/sys/arch/amd64/amd64/locore.S:1.115 Tue Dec 6 15:05:07 2016 +++ src/sys/arch/amd64/amd64/locore.S Fri Dec 9 17:57:24 2016 @@ -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. */ Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.234 src/sys/arch/amd64/amd64/machdep.c:1.235 --- src/sys/arch/amd64/amd64/machdep.c:1.234 Fri Nov 25 11:57:36 2016 +++ src/sys/arch/amd64/amd64/machdep.c Fri Dec 9 17:57:24 2016 @@ -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. */