stand: Raise limit to 550,000 bytes for loader

Raise the limit for /boot/loader to be 550k. The IBM PC imposes a limit
of 640k of RAM below 1MB, which is needed for real mode calls. BTX takes
40k of that. The BIOS takes some amount (25k seems a good "99% take less
than or equal to this" estimate for that, though some systems consume
more). Most typical setups need 25k of stack.  This leaves 550k for
code. We set the limit to 550,000 which gives about an extra 13,000
bytes of buffer for machines that whose setups use a little more stack
or whose BIOS reserves a bit more...

Add this derivation in the Makefile. Also recommend setting LOADERSIZE
lower in /etc/src.conf when the loader has to run on a system whose BIOS
takes up more space, or for a complex setup. Add a recipe for how to
find how much RAM your BIOS uses as well (thanks to jhb@ for the
trick). Network cards that boot via PXE and HBAs with their BIOS enabled
are known to be large consumers of lomem space.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D36152
This commit is contained in:
Warner Losh 2022-08-11 22:59:51 -06:00
parent b9fd884a8d
commit f8a199f28f

View File

@ -19,8 +19,22 @@ PROG= ${LOADER}.sym
INTERNALPROG=
NEWVERSWHAT?= "bootstrap loader" x86
VERSION_FILE= ${.CURDIR}/../loader/version
LOADERSIZE?= 508000 # Largest known safe size for loader.bin
#
# There's 640k - 40k maximum space, less however much memory the BIOS uses. A
# non-random survey suggests that 20k-25k is a good value for 'most' machines.
# We also need to subtract maximum stack usage (20-25k).
#
# So 640k - 40k - 25k - 25k = 550k = 563,200 bytes, but use 550,000 below for
# some extra buffer for more complex setups and/or wider BIOS lomem variation.
#
# Some systems use more stack or have BIOS resere more RAM (or both), and will
# need to set this lower in /etc/loader.conf if the above buffer is too small.
#
# sudo dd if=/dev/mem bs=1 iseek=0x413 count=2 | hd -d
#
# will tell you how many kiB of lomem are available.
#
LOADERSIZE?= 550000 # Largest known safe size for loader.bin
.PATH: ${BOOTSRC}/i386/loader