From nobody Thu Aug 11 19:17:40 2022 X-Original-To: dev-commits-src-main@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 4M3c5y13y0z4YSHZ; Thu, 11 Aug 2022 19:18:14 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from smtp052.goneo.de (smtp052.goneo.de [85.220.129.60]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4M3c5x0HZ3z3Dny; Thu, 11 Aug 2022 19:18:12 +0000 (UTC) (envelope-from freebsd@walstatt-de.de) Received: from hub1.goneo.de (hub1.goneo.de [IPv6:2001:1640:5::8:52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by smtp5.goneo.de (Postfix) with ESMTPS id 00D7510A1E8D; Thu, 11 Aug 2022 21:18:11 +0200 (CEST) Received: from hub1.goneo.de (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by hub1.goneo.de (Postfix) with ESMTPS id 0E71C10A32F4; Thu, 11 Aug 2022 21:18:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walstatt-de.de; s=DKIM001; t=1660245489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5nr7N3kA3PdFbEGnPM0q0DtnKZpoD6NsdTYHG0JW7ew=; b=bk433e/FV/aZzUutOXwLqx2khgWCvi6rghj2LZo+VBbgzDK8xonskpdBfKICTEe5tLAuiS MbZl3RkEDbpI09mR9COV7xLfPa0srOSxbk66D38vTpN9wbkXqoD5DEmKV8nKifLLU1rnVl OKjYnWeqBNyA4HNe08woP7WFeVytKj2YURC9i+umi+HFT1ep+lWCkwA7sq51gZie8Jp0ar WPcDodBKQPKC4YNH6p+FfuTF0cmF/VcHyw10nzk3vghUXuvz0ifEboVZb2Ei7vo1sVbSkh Dk3bjw0XosoVlLltlrzCsic7k5O1f0hgnV/HfW5f0cFgtE1ktZxRnUiF1yq2ww== Received: from thor.intern.walstatt.dynvpn.de (dynamic-078-055-077-000.78.55.pool.telefonica.de [78.55.77.0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by hub1.goneo.de (Postfix) with ESMTPSA id B7CC110A330F; Thu, 11 Aug 2022 21:18:08 +0200 (CEST) Date: Thu, 11 Aug 2022 21:17:40 +0200 From: FreeBSD User To: Warner Losh Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 39fdad34e220 - main - stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr Message-ID: <20220811211807.0b9c8a75@thor.intern.walstatt.dynvpn.de> In-Reply-To: <202208110331.27B3Va7M007335@gitrepo.freebsd.org> References: <202208110331.27B3Va7M007335@gitrepo.freebsd.org> Organization: walstatt-de.de List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-UID: edb9a1 X-Rspamd-UID: 00f897 X-Rspamd-Queue-Id: 4M3c5x0HZ3z3Dny X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=walstatt-de.de header.s=DKIM001 header.b="bk433e/F"; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@walstatt-de.de has no SPF policy when checking 85.220.129.60) smtp.mailfrom=freebsd@walstatt-de.de X-Spamd-Result: default: False [-3.30 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; NEURAL_HAM_SHORT(-1.00)[-0.999]; R_DKIM_ALLOW(-0.20)[walstatt-de.de:s=DKIM001]; MIME_GOOD(-0.10)[text/plain]; DKIM_TRACE(0.00)[walstatt-de.de:+]; MLMMJ_DEST(0.00)[dev-commits-src-all@FreeBSD.org,dev-commits-src-main@FreeBSD.org]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; MIME_TRACE(0.00)[0:+]; HAS_ORG_HEADER(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DMARC_NA(0.00)[walstatt-de.de]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; ASN(0.00)[asn:25394, ipnet:85.220.128.0/17, country:DE]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Am Thu, 11 Aug 2022 03:31:36 GMT Warner Losh schrieb: > The branch main has been updated by imp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=39fdad34e220c52a433e78f20c8c39412429014e > > commit 39fdad34e220c52a433e78f20c8c39412429014e > Author: Warner Losh > AuthorDate: 2022-08-11 03:19:01 +0000 > Commit: Warner Losh > CommitDate: 2022-08-11 03:29:20 +0000 > > stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr > > The BIOS method of booting imposes an absolute limit of 640k for the > size of the program being run due to btx. In practice, this means that > programs larger than about 500kiB will fail in odd ways as the stack / > heap will overflow. > > Pick 510,000 as the cutoff line semi-arbitrarily. loader_lua is now > almost too big and we want to break the build when it crosses this > threshold. In my experience, below 500,000 always works, above 520,000 > always seems to fail with things getting bad somewhere between 512,000 > to 515,000. 510,000 is as close to the line as I think we can go, though > experience may dictate we need to lower this in the future. > > This is at-best a stop-breakage until we have a better way to subset the > boot loader for BIOS booting to allow better, more fined-tuned > /boot/loaders for the many different environments they have to run > in. This likely means we'll have a graphical loader than understands a > few filesystmes for installation, and a non-graphical loader that > understands the most filesystems possible for everything else in the > future. Our build infrastructure needs some work before we can do that, > however. > > At this late date, it likely isn't worth the efforts to move parts of > the loader into high memory. There's a number of assumptions about where > the stack is, where buffers reside, etc that are fulfilled when it lives > in the first 640k that would need bounce buffers and/or other counter > measures if we were to split it up. All BIOS calls are done in 16-bit > mode with SEG:OFF addresses, requiring them to be in the first 640k of > RAM. And nearly all machines in the last decade can boot with UEFI > (though there's some exceptions, so it isn't worth killing outright > yet). > > Sponsored by: Netflix > Reviewed by: kevans > Differential Revision: https://reviews.freebsd.org/D36129 > --- > stand/i386/loader/Makefile | 5 +++++ > stand/i386/pxeldr/Makefile | 3 +++ > 2 files changed, 8 insertions(+) > > diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile > index 3685281ffd2c..cde1513aac06 100644 > --- a/stand/i386/loader/Makefile > +++ b/stand/i386/loader/Makefile > @@ -19,6 +19,8 @@ PROG= ${LOADER}.sym > INTERNALPROG= > NEWVERSWHAT?= "bootstrap loader" x86 > VERSION_FILE= ${.CURDIR}/../loader/version > +LOADERSIZE= 510000 # Largest known safe size > + > > .PATH: ${BOOTSRC}/i386/loader > > @@ -79,9 +81,12 @@ CFLAGS+= -I${BOOTSRC}/i386 > 8x16.c: ${SRCTOP}/contrib/terminus/ter-u16b.bdf > vtfontcvt -f compressed-source -o ${.TARGET} ${.ALLSRC} > > + > ${LOADER}: ${LOADER}.bin ${BTXLDR} ${BTXKERN} > btxld -v -f elf -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ > -b ${BTXKERN} ${LOADER}.bin > + @set -- `${SIZE} ${.TARGET} | tail -1` ; x=$$((${LOADERSIZE}-$$4)); \ > + echo "$$x bytes available"; test $$x -ge 0 > > ${LOADER}.bin: ${LOADER}.sym > ${STRIPBIN} -R .comment -R .note -o ${.TARGET} ${.ALLSRC} > diff --git a/stand/i386/pxeldr/Makefile b/stand/i386/pxeldr/Makefile > index a44dc0de2885..f8bc1eae9a31 100644 > --- a/stand/i386/pxeldr/Makefile > +++ b/stand/i386/pxeldr/Makefile > @@ -13,6 +13,7 @@ BOOT= pxeboot > LDR= pxeldr > ORG= 0x7c00 > LOADER= loader > +PXELDRSIZE= 510000 # Largest known safe size > > .if defined(BOOT_PXELDR_PROBE_KEYBOARD) > CFLAGS+=-DPROBE_KEYBOARD > @@ -41,5 +42,7 @@ CLEANFILES+= ${LOADER} > ${LOADER}: ${LOADERBIN} ${BTXLDR} ${BTXKERN} > btxld -v -f elf -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ > -b ${BTXKERN} ${LOADERBIN} > + @set -- `${SIZE} ${.TARGET} | tail -1` ; x=$$((${PXELDRSIZE}-$$4)); \ > + echo "$$x bytes available"; test $$x -ge 0 > > .include > To make a long story short: Having WITH_BEARSSL=YES in /etc/src.conf blow off the loader. Can this be fixed? -- O. Hartmann