From nobody Tue Nov 28 16:06:32 2023 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 4SfnQ20vYZz528dx; Tue, 28 Nov 2023 16:06:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SfnQ20MVJz3Sfl; Tue, 28 Nov 2023 16:06:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701187594; 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: in-reply-to:in-reply-to:references:references; bh=2BoJAupxMhjJdja/I1tCD00z4IqxvVA0ODEavyPey6I=; b=NR01yAmeoutPSCU2NzyxsVvEYLwaiTrbNCwPe5Go5ex3isgx5X5jDwCx93aXPeKRyzFqmP Q+FbmGc1oVoNolbctoEEmRgI6YLlUW1hyDlVJtlmnfIIRueNlBRyZa0Ttb0fdiR44RvMg4 soE3SdR7DS7xd81DN/3SR6fhuIu5sa+i7G44RW57PBz3LLxtktWL891R7IiDaz04PxRIrE 2tZOkUnODkIWxseVPu5ClKA0eJ3HoOnEb1GkqVspfuwp4lbqNGh4gdXNILMF5dWwEs34w+ So0QGrh9Qov0RQHl/wpFYMkzqesS0UkppukPhuSWb6Yx5Oi92ZnH2x50nt33lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701187594; 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: in-reply-to:in-reply-to:references:references; bh=2BoJAupxMhjJdja/I1tCD00z4IqxvVA0ODEavyPey6I=; b=eFUy59r+bH7R/zykudcLwCtmgL5djRrFwrMZGlnYeRIcFv8AIB0z+dd6E3hrHc0KJgzJu2 +egaxPewvTa7MeMcVMKI3VB22MSCTfpJ9wp+dl3H2UVp1MPaAMNsI4++coPi+A5ARdBGIW j/Nm3Vf4GUdwNj4QB8piVk1K2GByGKRfjI8ScaJ1RxZy79bIxJLGR24CT1UswPr385mYUp l0B7qZJ5fGFBDk5rhkmbudc6HQ/idkf58s0wEbqRoo4PZr2915y0OYQsPREudoknwWmePs PfvaymxGKDn7wbT5xQE1u+oquWywjZeGghPELffTauPBEImgOMuYanDKHs3iCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701187594; a=rsa-sha256; cv=none; b=furKzYhhnc2z1b4ty0pz0ReVsaBvJrt78LzHBB+8OUGB0sk4MUEEIiKx2mKTP1hx1dViXh qAaddXMsRih5JzltAIx/XnGPMLXkvqO5JhUb4oLYqCZa4bDZ/qY07D0YgJIGwkXTKQKglP K/8XJB3e/wKZQYsMGxc0SEPJtlvkbz07abM8qcMbRdMtg5OX/Nbdv5za//piZpLDJDhV7N go/Uc4drXB20apTY2TNjb3oyvQZl+QjT+nibGUXUaKXdRjOpkPStxOu+NcPBtqSD+pBk/E vPMp1FjgY9omYIYZ2ugcuAhrn/0ReBSRy37sO6aIrwXMiCGYsBpv6dc46Y3dEw== Received: from [IPV6:2601:648:8384:fd00:51ff:8c8b:b16b:8ec9] (unknown [IPv6:2601:648:8384:fd00:51ff:8c8b:b16b:8ec9]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4SfnQ13fzJz1P1Z; Tue, 28 Nov 2023 16:06:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <8fa6ed4d-c26b-4dd6-86f2-c3751f86d426@FreeBSD.org> Date: Tue, 28 Nov 2023 08:06:32 -0800 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 User-Agent: Mozilla Thunderbird Subject: Re: git: c596126a5d3d - main - pmbr: Only load the first 545k rather than error out Content-Language: en-US To: Warner Losh , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202311272246.3ARMkNS1037267@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: <202311272246.3ARMkNS1037267@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/27/23 2:46 PM, Warner Losh wrote: > The branch main has been updated by imp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=c596126a5d3d2ee015ee6807b4041efa5b9d9b07 > > commit c596126a5d3d2ee015ee6807b4041efa5b9d9b07 > Author: Warner Losh > AuthorDate: 2023-11-27 22:40:40 +0000 > Commit: Warner Losh > CommitDate: 2023-11-27 22:45:56 +0000 > > pmbr: Only load the first 545k rather than error out > > It would be nice to have larger boot partitions for ESPs to live in one > day. It's trivial to carve out 5M 10M or 200M when provisioning, but > logistical issues may make it hard to do it after the fact. So only warn > when the partition is > 545k. If we ever grow the boot loader larger > than that, then it will be responsible for loading the rest anyway. > > Sponsored by: Netflix > Reviewed by: tsoome > Differential Revision: https://reviews.freebsd.org/D42774 > --- > stand/i386/pmbr/pmbr.S | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/stand/i386/pmbr/pmbr.S b/stand/i386/pmbr/pmbr.S > index c61acbe261bd..60b26df15720 100644 > --- a/stand/i386/pmbr/pmbr.S > +++ b/stand/i386/pmbr/pmbr.S > @@ -155,8 +155,10 @@ next_boot: addl $1,(%si) # Next LBA > mov %es,%ax # Adjust segment for next > addw $SECSIZE/16,%ax # sector > cmp $0x9000,%ax # Don't load past 0x90000, > - jae err_big # 545k should be enough for > - mov %ax,%es # any boot code. :) > + jb sz_ok # 545k should be enough for > + call err_big # any boot code, but warn > + mov $0x9000-SECSIZE/16,%ax # and truncate > +sz_ok: mov %ax,%es > jmp load_boot > # > # Move to the next partition. If we walk off the end of the sector, load > @@ -203,17 +205,21 @@ getdrvparams: > # > # Various error message entry points. > # > -err_big: movw $msg_big,%si # "Boot loader too > - jmp putstr # large" > +err_big: movw $msg_big,%si # "Truncated > + call putstr # to 545k" > + ret Hmm, the comment here and the text string don't match. > err_pt: movw $msg_pt,%si # "Invalid partition > - jmp putstr # table" > + call putstr # table" > +err_pt.1: jmp err_pt.1 # Await reset > > err_rd: movw $msg_rd,%si # "I/O error loading > - jmp putstr # boot loader" > + call putstr # boot loader" > + jmp err_pt.1 > > err_noboot: movw $msg_noboot,%si # "Missing boot > - jmp putstr # loader" > + call putstr # loader" > + jmp err_pt.1 > # > # Output an ASCIZ string to the console via the BIOS. > # > @@ -223,9 +229,9 @@ putstr.0: movw $0x7,%bx # Page:attribute > putstr: lodsb # Get character > testb %al,%al # End of string? > jnz putstr.0 # No > -putstr.1: jmp putstr.1 # Await reset > + ret > > -msg_big: .asciz "Boot loader too large" > +msg_big: .asciz "Loaded only 545k" > msg_pt: .asciz "Invalid partition table" > msg_rd: .asciz "I/O error loading boot loader" > msg_noboot: .asciz "Missing boot loader" I wonder if it would save a few bytes by having a common 'puterr' that does 'call putstr' and then the jmp to itself that the other err targets use rahter than adding the jmp to each one of those. But also, can't you just leave a gap in the partitions to leave room for a future ESP? It might not always be safe to load a full 545k depending on if the firmware has reserved some of memory just below 640k. 545k is an upper bound on how much can be loaded in terms of 640k - the load address, but the practical limit might be lower. It is probably safer as a general rule to keep the boot partition closer to the size of the boot loader and leave a gap in place instead. -- John Baldwin