diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 3377376f158d..59a6ca8839f6 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -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; /* diff --git a/sys/conf/ldscript.amd64 b/sys/conf/ldscript.amd64 index ce275ef6c365..9210a730c30e 100644 --- a/sys/conf/ldscript.amd64 +++ b/sys/conf/ldscript.amd64 @@ -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) }