From nobody Sat Aug 13 03:49:20 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M4RPF0JXZz4Z1qH; Sat, 13 Aug 2022 03:49:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M4RPD6tc3z3hTC; Sat, 13 Aug 2022 03:49:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660362561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1ZmiYLy4IcRdPYjtFFYkWFoBqxSEYMXQ2d0XGyr3L8I=; b=AtM5/XRK1d4wTTpoKgHAiXqwsCjOBcEgoSJFFMZONHmucqpc1w7jdbT1CtkLNkoRisVYj5 /vzbwh+pZd2cApJxZ5YDBgXXQaO6/48niL7c6i+9fGOMnJ+nGcEUXNfaDw2skZDAVCD/fP gNGNsmvICkDO4Nr8Xm8PXHMAbmN9ghZ7NF/bFcKyEmDxnGorjoF2hHMrMPQSBSOeaKD2sw eGxeF+m4yn5E+jdGzy6ZRVwnUFTcQPiDELAQOfpefgtEJ1DIC3LC3qeMRWUFNuVICD16su sANmvli/7/XGNAQvbAe7RR6wZGf2sPYqFWguxlqfaI8iOqJqW7EwPZWYkZbFOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M4RPD5jTNzxPW; Sat, 13 Aug 2022 03:49:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27D3nKsR032726; Sat, 13 Aug 2022 03:49:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27D3nKVR032725; Sat, 13 Aug 2022 03:49:20 GMT (envelope-from git) Date: Sat, 13 Aug 2022 03:49:20 GMT Message-Id: <202208130349.27D3nKVR032725@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: f8a199f28f9d - main - stand: Raise limit to 550,000 bytes for loader List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f8a199f28f9de46fe7360c3a4a0e19e71be72721 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660362561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1ZmiYLy4IcRdPYjtFFYkWFoBqxSEYMXQ2d0XGyr3L8I=; b=fwceKRae/dsQaoXrcdCfzqgfA0c1wLTm/ZYnd/NsPkotdoXzXaPPdpd6ZXsIcxL5K79iYg cClhEBNI7OfhtIhg1lW86dXWdwWa2AtkLjw9f4E2v6oZ43VIKqMhmjR8Q87zkzuu1YxpxF RvYOuknGVml+H1UzQ2xA1IW7EPoCObEI7NtekwUMLxGRb8mPLob8rByWp3TE+tl31QlE4h vwwkOzwpXiLQdRaYI9UetpaIPm3kWnMSeEHLURX0SHiUU1N/3lOJ3P6cHb4UVyhxd/4Zj1 gkSr44wPZuD/mNZrV9J7NCeaCShdC1XCUCsAa42KVmly/fKXwE9lXm3V4GNmpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660362561; a=rsa-sha256; cv=none; b=RRI8allrhHp+od41h6UJWZnXpGSKEfGiWenkWYk0XhyOmMT2Q7lKY0eNJN0idR8Z6JV/EB HFSI3erPEAoYkNBEViMcxIFJbTY0/hEpyPjR1NT+zS3wWcYp5sPcuYXQvIoPhTiF2+Slz/ /utkeUEteLzXJ+6YInWXZozzxW9UD99r/+mm4Vyby0sLe+Pb41HIYrwQ60/QgCxYcl4N9H kQZy5HO2DBbMzUfAQuvthDZLARmbRxxzskqveEhzWJqM03RMxWFZ17uk/t9MV6/+ioOPVh Z4b5uegO9NdeykYzzorQwnAShkLWO1CYDHPYOcYNfqX1avpgVDumDuXSGzlkDA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=f8a199f28f9de46fe7360c3a4a0e19e71be72721 commit f8a199f28f9de46fe7360c3a4a0e19e71be72721 Author: Warner Losh AuthorDate: 2022-08-12 04:59:51 +0000 Commit: Warner Losh CommitDate: 2022-08-13 03:47:02 +0000 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 --- stand/i386/loader/Makefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index 539c736af38f..723220484e67 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 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