freebsd-nq/stand
Nathan Whitehorn 861a0b4808 Fix regression introduced in r328806, preventing boot at least on all
PowerPC Apple hardware, and likely all Open Firmware systems.

The loader would allocate memory for its heap at whatever address Open
Firmware gave it, which would in general be the lowest unallocated address,
usually starting a page or two above 0. As the kernel is linked at 1 MB,
and loader insists on running the kernel at its link address, any heap
larger than 1 MB would overlap the kernel, causing loader memory allocations
to corrupt the kernel and vice versa.

Although r328806 made this problem much worse by increasing the heap size
to 8 MB, causing 88% of the loader heap to overlap with the kernel, the
problem has always existed. The old heap size was 1 MB and, unless that
started exactly at zero, which would cause other problems, some number of
pages of the loader heap still overlapped with the kernel.

This patch solves the issue in two ways and cleans up some related code:
- Moves the loader heap inside of the loader. This guarantees that the
  heap will be contiguous with the loader and simplifies the heap
  allocation code at no cost, since the heap lives in BSS.
- Moves the loader, previously at 28 MB and dangerously close to the kernel
  it loads, a bit higher to 44 MB. This has the effect of breaking loader
  on non-embedded PPC machines with < 48 MB of RAM, but we did not support
  those anyway.

The fundamental problem is that the way loader loads ELF files is
incredibly fragile, but that can't be fixed without fundamental
architectural changes.

MFC after:	10 days
2018-02-03 23:49:21 +00:00
..
arm Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
arm64
common Make cross-endian loader changes apply only to powerpc 2018-02-03 01:23:48 +00:00
efi Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
fdt Centralize several variables. 2018-02-02 06:32:26 +00:00
ficl Centralize several variables. 2018-02-02 06:32:26 +00:00
ficl32
forth Remove pcibios forth support. 2018-02-02 15:01:49 +00:00
geli Centralize several variables. 2018-02-02 06:32:26 +00:00
i386 Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
kshim
libsa Implement strcoll as strcmp. 2018-02-02 21:18:32 +00:00
libsa32
man
mips Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
ofw Fix regression introduced in r328806, preventing boot at least on all 2018-02-03 23:49:21 +00:00
powerpc Fix regression introduced in r328806, preventing boot at least on all 2018-02-03 23:49:21 +00:00
sparc64 Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
uboot Centralize several variables. 2018-02-02 06:32:26 +00:00
usb Centralize several variables. 2018-02-02 06:32:26 +00:00
userboot Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
zfs Centralize several variables. 2018-02-02 06:32:26 +00:00
zfs32
defs.mk Centralize several variables. 2018-02-02 06:32:26 +00:00
fdt.mk
ficl.mk Now that we no longer conditionally compile some files outside of ficl 2018-02-02 15:01:54 +00:00
loader.mk Invent new LDR_INTERP for the loader interpreter to use. Use this in 2018-02-02 15:40:49 +00:00
Makefile
Makefile.amd64 Switch to proper MK_LOADER_GELI tests. 2017-12-04 01:14:12 +00:00
Makefile.arm
Makefile.arm64
Makefile.i386 Switch to proper MK_LOADER_GELI tests. 2017-12-04 01:14:12 +00:00
Makefile.inc Minor flags cleanup 2017-12-02 00:06:58 +00:00
Makefile.mips
Makefile.powerpc
Makefile.sparc64
uboot.mk