The new binutils has correctly redefined MAXPAGESIZE on amd64 as 0x200000

instead of 0x100000.  As a side effect, an amd64 kernel now loads at
physical address 0x200000 instead of 0x100000.  This is probably for the
best because it avoids the use of a 2MB page mapping for the first 1MB of
the kernel that also spans the fixed MTRRs.  However, getmemsize() still
thinks that the kernel loads at 0x100000, and so the physical memory between
0x100000 and 0x200000 is lost.  Fix this problem by replacing the hard-wired
constant in getmemsize() by a symbol "kernphys" that is defined by the
linker script.

In collaboration with:	kib
This commit is contained in:
Alan Cox 2011-03-28 06:35:17 +00:00
parent e45dab861e
commit 1c675a3bc3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220090
2 changed files with 8 additions and 2 deletions

View File

@ -156,6 +156,11 @@ static void get_fpcontext(struct thread *td, mcontext_t *mcp);
static int set_fpcontext(struct thread *td, const mcontext_t *mcp);
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
/*
* The file "conf/ldscript.amd64" defines the symbol "kernphys". Its value is
* the physical address at which the kernel is loaded.
*/
extern char kernphys[];
#ifdef DDB
extern vm_offset_t ksym_start, ksym_end;
#endif
@ -1417,7 +1422,7 @@ getmemsize(caddr_t kmdp, u_int64_t first)
/*
* block out kernel memory as not available.
*/
if (pa >= 0x100000 && pa < first)
if (pa >= (vm_paddr_t)kernphys && pa < first)
goto do_dump_avail;
/*

View File

@ -6,7 +6,8 @@ SEARCH_DIR("/usr/lib");
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = kernbase + CONSTANT (MAXPAGESIZE) + SIZEOF_HEADERS;
kernphys = CONSTANT (MAXPAGESIZE);
. = kernbase + kernphys + SIZEOF_HEADERS;
.interp : { *(.interp) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }