aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2022-08-12 04:59:51 +0000
committerWarner Losh <imp@FreeBSD.org>2023-01-24 21:49:31 +0000
commit6760e8df9dc63db2d24e07882c49bb4e9da1602e (patch)
treec867b845ca34597e3fc37288ce98d6d522f90a54
parentdba7abcda4a8668e5949656afd5f19dbf072acb6 (diff)
downloadsrc-6760e8df9dc63db2d24e07882c49bb4e9da1602e.tar.gz
src-6760e8df9dc63db2d24e07882c49bb4e9da1602e.zip
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 (cherry picked from commit f8a199f28f9de46fe7360c3a4a0e19e71be72721) stand: Fix a couple of comment typos in f8a199f28f9d The commit message documented it as /etc/src.conf but the comment in the source mentioned the non-existent /etc/loader.conf. Fixes: f8a199f28f9d ("stand: Raise limit to 550,000 bytes for loader") (cherry picked from commit 3179bb2737493bc4191c3239226bda50f0b64b8f)
-rw-r--r--stand/i386/loader/Makefile18
1 files changed, 16 insertions, 2 deletions
diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile
index 539c736af38f..3195cb00c6be 100644
--- a/stand/i386/loader/Makefile
+++ b/stand/i386/loader/Makefile
@@ -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 reserve more RAM (or both), and will
+# need to set this lower in /etc/src.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