freebsd-nq/sys/amd64/amd64
Roger Pau Monné 7e748038cd amd64: set the correct LMA values
The current linker script generates program headers with VMA == LMA:

Entry point 0xffffffff802e7000
There are 6 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0xffffffff80200040 0xffffffff80200040
                 0x0000000000000150 0x0000000000000150  R E    8
  INTERP         0x0000000000000190 0xffffffff80200190 0xffffffff80200190
                 0x000000000000000d 0x000000000000000d  R      1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000000000 0xffffffff80200000 0xffffffff80200000
                 0x00000000010559b0 0x00000000010559b0  R E    200000
  LOAD           0x0000000001056000 0xffffffff81456000 0xffffffff81456000
                 0x0000000000132638 0x000000000052ecf8  RW     200000
  DYNAMIC        0x0000000001056000 0xffffffff81456000 0xffffffff81456000
                 0x00000000000000d0 0x00000000000000d0  RW     8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    8

This is fine for the FreeBSD loader, because it completely ignores p_paddr
and instead uses p_vaddr with a hardcoded offset. Other loaders however
acknowledge p_paddr (like the Xen ELF loader), in which case they will try
to load the kernel at the wrong place. Fix this by adding an AT keyword to
the first section specifying the physical address, other sections will
follow suit, so it ends up looking like:

Entry point 0xffffffff802e7000
There are 6 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0xffffffff80200040 0x0000000000200040
                 0x0000000000000150 0x0000000000000150  R E    8
  INTERP         0x0000000000000190 0xffffffff80200190 0x0000000000200190
                 0x000000000000000d 0x000000000000000d  R      1
      [Requesting program interpreter: /red/herring]
  LOAD           0x0000000000000000 0xffffffff80200000 0x0000000000200000
                 0x00000000010559b0 0x00000000010559b0  R E    200000
  LOAD           0x0000000001056000 0xffffffff81456000 0x0000000001456000
                 0x0000000000132638 0x000000000052ecf8  RW     200000
  DYNAMIC        0x0000000001056000 0xffffffff81456000 0x0000000001456000
                 0x00000000000000d0 0x00000000000000d0  RW     8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RWE    8

Tested on bare metal using the native FreeBSD loader and grub2 from TRUEOS.

Sponsored by: Citrix Systems R&D
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D2783
2015-06-26 07:12:17 +00:00
..
amd64_mem.c
apic_vector.S Rewrite amd64 PCID implementation to follow an algorithm described in 2015-05-09 19:11:01 +00:00
atomic.c
atpic_vector.S
autoconf.c
bios.c
bpf_jit_machdep.c
bpf_jit_machdep.h
cpu_switch.S Rewrite amd64 PCID implementation to follow an algorithm described in 2015-05-09 19:11:01 +00:00
db_disasm.c ddb: finish converting boolean values. 2015-05-21 15:16:18 +00:00
db_interface.c
db_trace.c
elf_machdep.c In preparation for switching linuxulator to the use the native 1:1 2015-05-24 14:51:29 +00:00
exception.S
fpu.c
gdb_machdep.c Report the values of x86 segment registers to remote debuggers. 2015-06-12 15:14:08 +00:00
genassym.c Rewrite amd64 PCID implementation to follow an algorithm described in 2015-05-09 19:11:01 +00:00
in_cksum.c
initcpu.c Update print_INTEL_TLB() by the tag values from the Intel SDM 2015-06-06 22:03:24 +00:00
io.c
locore.S
machdep.c The kernel sends signals to the processes via ABI specific sv_sendsig method. 2015-05-24 17:56:02 +00:00
mem.c
minidump_machdep.c
mp_machdep.c Rewrite amd64 PCID implementation to follow an algorithm described in 2015-05-09 19:11:01 +00:00
mp_watchdog.c CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten 2015-05-22 17:05:21 +00:00
mpboot.S
pmap.c Account for superpage mappings that are created by pmap_copy(). 2015-06-09 18:04:28 +00:00
prof_machdep.c
ptrace_machdep.c Ensure that the supplied data length is large enough to hold the base 2015-02-18 23:34:03 +00:00
sigtramp.S
stack_machdep.c
support.S adrian asked me to revert and get more testing 2015-04-05 05:18:14 +00:00
sys_machdep.c
trap.c Generalised support for copy-on-write structures shared by threads. 2015-06-10 10:43:59 +00:00
uio_machdep.c
uma_machdep.c Fix integer truncation bug in malloc(9) 2015-04-01 12:42:26 +00:00
vm_machdep.c Remove several write-only variables, all reported by the gcc 4.9 2015-05-29 13:24:17 +00:00
xen-locore.S amd64: set the correct LMA values 2015-06-26 07:12:17 +00:00