Why kernel load address changed?

Hi guys,
In the loader command line, I loaded the kernel as follow
load /boot/kernel/kernel
then lsmod show the following line
OK lsmod
0x200000: /boot/kernel/kernel (elf kernel , 0x1f3e2d0)
...
which means that kernel is loaded at address 0x200000, but later after the kernel has up, the sysctl debug.dump_modinfo shows a different address as follow
root@freebsd132:~ # sysctl debug.dump_modinfo
debug.dump_modinfo:
0xffffffff82906168:
type: (0x01) MODINFO_NAME
len: 20
value: /boot/kernel/kernel
0xffffffff82906188:
type: (0x02) MODINFO_TYPE
len: 11
value: elf kernel
0xffffffff829061a0:
type: (0x03) MODINFO_ADDR
len: 8
value: 0xffffffff80200000
...
what confused me is MODINFO_ADDR. Its value is 0xffffffff80200000 , which does not match the previous load address 0x200000. Is there any chance that the load address is changed when it is copied ? Or what I've missed ? Many thanks. (BTW I'm running amd64 GENERIC kernel)
 

 

I believe I'm not using kboot. I'm running amd64 GENERIC kernel on a virtual machine.
 
It get relocated depending of the arch. Check the common/load_elf.c
Yes. I've checked that.
1. loadimage will load kernel at 0x200000.
2. this address is recorded in the f_addr field of preloaded_file
3. and f_addr is copied to MODINFO_ADDR by md_copymodules(common/modinfo.c).
So in my understanding, the value of MODINFO_ADDR should be 0x200000 but it is not. This is what confused me.
 
Could be related:
Code:
/sys/amd64/include/vmparam.h: * 0xffffffff80000000                        KERNBASE

The address is not really different, it looks to be added to the value above.
 
 
Would be insufficient but related #define's in stable/14.
Searhed under /usr/src/sys/amd64/ only.

/usr/src/sys/amd64/include/vmparam.h:218:#define KERNBASE KV4ADDR(KPML4I, KPDPI, 0, 0) /usr/src/sys/amd64/include/vmparam.h:219:#define KERNSTART (KERNBASE + NBPDR) /usr/src/sys/amd64/include/param.h:97:#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ /usr/src/sys/amd64/include/param.h:98:#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ /usr/src/sys/amd64/include/param.h:103:#define PDRSHIFT 21 /* LOG2(NBPDR) */ /usr/src/sys/amd64/include/param.h:104:#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ /usr/src/sys/amd64/include/param.h:107:#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t))) /usr/src/sys/amd64/include/param.h:109:#define PDPSHIFT 30 /* LOG2(NBPDP) */ /usr/src/sys/amd64/include/param.h:113:#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) /usr/src/sys/amd64/include/param.h:115:#define PML4SHIFT 39 /* LOG2(NBPML4) */ /usr/src/sys/amd64/include/pmap.h-168-/* /usr/src/sys/amd64/include/pmap.h-169- * Pte related macros. This is complicated by having to deal with /usr/src/sys/amd64/include/pmap.h-170- * the sign extension of the 48th bit. /usr/src/sys/amd64/include/pmap.h-171- */ /usr/src/sys/amd64/include/pmap.h:172:#define KV4ADDR(l4, l3, l2, l1) ( \ /usr/src/sys/amd64/include/pmap.h-173- ((unsigned long)-1 << 47) | \ /usr/src/sys/amd64/include/pmap.h-174- ((unsigned long)(l4) << PML4SHIFT) | \ /usr/src/sys/amd64/include/pmap.h-175- ((unsigned long)(l3) << PDPSHIFT) | \ /usr/src/sys/amd64/include/pmap.h-176- ((unsigned long)(l2) << PDRSHIFT) | \ /usr/src/sys/amd64/include/pmap.h-177- ((unsigned long)(l1) << PAGE_SHIFT))
 
Back
Top