freebsd-dev/sys
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 amd64: set the correct LMA values 2015-06-26 07:12:17 +00:00
arm Fix a misplaced #endif (maybe a mismerge?). Emitting the symbol for CURPMAP 2015-06-24 18:26:04 +00:00
arm64 add floatingpoint.h for arm64 2015-06-24 14:51:53 +00:00
boot Install version.4th.8 again 2015-06-21 06:56:29 +00:00
bsm
cam Fix REPORT LUNS command output for the case when same LUN mapped to same 2015-06-20 13:02:57 +00:00
cddl MFV r284412: 5911 ZFS "hangs" while deleting file 2015-06-19 06:58:05 +00:00
compat Add EPOLLRDHUP support. 2015-06-20 05:40:35 +00:00
conf amd64: set the correct LMA values 2015-06-26 07:12:17 +00:00
contrib Merge ACPICA 20150619. 2015-06-18 23:14:45 +00:00
crypto
ddb Correct the function name in catch-all error handling case. 2015-06-17 10:20:59 +00:00
dev Rename seq_* to mseq_*, to avoid clashes with seq.h (namely, seq_read.) 2015-06-26 04:12:06 +00:00
fs Restore the td_cookie value for the tmpfs directory entry which was a 2015-06-19 07:25:15 +00:00
gdb
geom Fix off-by-one error in fstyp(8) and geom_label(4) that made them use 2015-06-18 21:55:55 +00:00
gnu
i386 Replace struct filedesc argument in getvnode with struct thread 2015-06-16 13:09:18 +00:00
isa
kern Un-static cpuset_which() - it's useful in other contexts, such as some 2015-06-26 04:14:05 +00:00
kgssapi
libkern Add more __aeabi_memcpy functions, later versions of clang generate calls 2015-05-31 07:31:20 +00:00
mips Add if_vlan, ipfw{,_nat}.ko, and libalias to the AR934X kernel config 2015-06-13 06:09:00 +00:00
modules Several build changes for ix and ixv: 2015-06-24 15:53:52 +00:00
net Another attempt to make this compile on more architectures after r284777. 2015-06-25 23:16:01 +00:00
net80211 Break out the current 802.11 software scan methods into an indirect table. 2015-06-08 02:35:43 +00:00
netgraph
netinet Reverting r284710. 2015-06-22 22:16:06 +00:00
netinet6 Add FIB support for SCTP. 2015-06-17 15:20:14 +00:00
netipsec drop key_sa_stir_iv as it isn't used... 2015-06-11 13:05:37 +00:00
netnatm
netpfil ALTQ FAIRQ discipline import from DragonFLY 2015-06-24 19:16:41 +00:00
netsmb
nfs
nfsclient
nfsserver
nlm
ofed fd: make rights a mandatory argument to fget_unlocked 2015-06-16 09:52:36 +00:00
opencrypto change the KASSERT so it is meaningful, var is unsigned, so even 2015-06-19 22:42:26 +00:00
pc98
powerpc Allow DTrace to be compiled-in to the kernel. 2015-06-10 15:53:39 +00:00
rpc
security Replace struct filedesc argument in getvnode with struct thread 2015-06-16 13:09:18 +00:00
sparc64 Generalised support for copy-on-write structures shared by threads. 2015-06-10 10:43:59 +00:00
sys Un-static cpuset_which() - it's useful in other contexts, such as some 2015-06-26 04:14:05 +00:00
teken
tools
ufs vfs_msync(), called from syncer vnode fsync VOP, only iterates over 2015-06-17 04:46:58 +00:00
vm If INVARIANTS is specified, add ctor/dtor to junk memory if they are 2015-06-25 20:44:46 +00:00
x86 Split the DMAR unit domains and contexts. Domains carry address space 2015-06-26 07:01:29 +00:00
xdr
xen Garbage collect comments which related to the pre-r284296 support for a 2015-06-21 06:05:33 +00:00
Makefile Kill EoL whitespace. 2015-05-29 14:03:07 +00:00