From nobody Tue Nov 28 18:06:02 2023 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 4Sfr4F1lPRz52Jwx for ; Tue, 28 Nov 2023 18:06:21 +0000 (UTC) (envelope-from tsoome@me.com) Received: from mr85p00im-ztdg06011901.me.com (mr85p00im-ztdg06011901.me.com [17.58.23.198]) (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 4Sfr4D6Zmmz4K0B for ; Tue, 28 Nov 2023 18:06:20 +0000 (UTC) (envelope-from tsoome@me.com) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1701194779; bh=1HeoP5YU7Dg8r/aUVGGC/DANRzEyMuOhmzwupjjPULI=; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:To; b=DKBPNQ4rAnjSp0x/WM1zh7954oWBG+ri2xjy/st+SkOVC9sXLO1X+1fCAOBmWkm2s U+XRTOmroFwpSTxeBfwJwFOILylxDzJBgsygM9ostGXei4exSX3wVU/6hmywktI5Hk XPTqw3sHBf0woioWRJW4NYTa+VuEaVwEWPvjI4pbxhgYcOwyd08uGV/H0U6ROpz3ul uwarsY4c6D838hKZKPKMYdQUEI2bJErsKsx0uubqtCAfQIXkaMgmfXmefF0P5o4ZWG Fav9S0faw6xhUMNlGkA661sqJE9QrZdykJSBnlv6SkjHAEO8HS6M/skGpD7XZshZzl 0JfF/80F3P12Q== Received: from smtpclient.apple (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-ztdg06011901.me.com (Postfix) with ESMTPSA id ADCA99000E8; Tue, 28 Nov 2023 18:06:17 +0000 (UTC) From: Toomas Soome Message-Id: <234CE696-4583-41CF-A94D-3D29EA4676C5@me.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_1938CAEA-1A7B-4C6C-AC05-91F5BC64EA33" 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 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) Subject: Re: git: c596126a5d3d - main - pmbr: Only load the first 545k rather than error out Date: Tue, 28 Nov 2023 20:06:02 +0200 In-Reply-To: Cc: Warner Losh , Warner Losh , src-committers , "" , dev-commits-src-main@freebsd.org To: John Baldwin References: <202311272246.3ARMkNS1037267@gitrepo.freebsd.org> <8fa6ed4d-c26b-4dd6-86f2-c3751f86d426@FreeBSD.org> X-Mailer: Apple Mail (2.3774.200.91.1.1) X-Proofpoint-ORIG-GUID: 6qT8u4FNjrGYJRLmp2k7YdzutxTcVODo X-Proofpoint-GUID: 6qT8u4FNjrGYJRLmp2k7YdzutxTcVODo X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.425,18.0.816,17.11.62.513.0000000_definitions?= =?UTF-8?Q?=3D2022-01-18=5F01:2022-01-14=5F01,2022-01-18=5F01,2021-12-02?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 mlxscore=0 clxscore=1015 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2311280145 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:714, ipnet:17.58.16.0/20, country:US] X-Rspamd-Queue-Id: 4Sfr4D6Zmmz4K0B --Apple-Mail=_1938CAEA-1A7B-4C6C-AC05-91F5BC64EA33 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 28. Nov 2023, at 19:56, John Baldwin wrote: >=20 > On 11/28/23 9:07 AM, Warner Losh wrote: >> On Tue, Nov 28, 2023 at 9:06=E2=80=AFAM John Baldwin = wrote: >>> 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. >>>=20 >> Today we load 512k always. >=20 > Well, we load the partition size always. The default size of the = partition > has grown over time. Arguably we should have been using padding = instead of > growing the partition, but that is harder to write in installer tools, = etc. > When I wrote pmbr I on purpose used the partition size as the size to = load > rather than trying to assume information about the payload and parse a > length from the payload due to the limited room in the MBR. I think = we > started out creating freebsd-boot partitions that were 64k and later = grew > them with a desire they could be replaced with an ESP partition, but = ESPs > need a minimum size of 512k? >=20 The size is not specified (from UEFI_Spec_2_10_Aug29): "It is outside of the scope of this specifi- cation to attempt to = coordinate the specification of size and location of an ESP that can be = shared by multiple OS or Diagnostics installations, or to manage = potential namespace collisions in directory naming in a single (central) = ESP.=E2=80=9D and=20 "The EFI firmware must support the FAT32, FAT16, and FAT12 variants of = the EFI file system. What variant of EFI FAT to use is defined by the = size of the media.=E2=80=9D In reality, there are systems which only support FAT32 on hard disks, = and that will set minimum size ~34MB with 512B sector and a bit over = 256MB with 4k sector.=20 However, there are suggestions from vendors (notably Microsoft), to have = at least ~100MB to make it possible to store auxiliary files such as = diagnostics and other tools. rgds, toomas= --Apple-Mail=_1938CAEA-1A7B-4C6C-AC05-91F5BC64EA33 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 28. Nov 2023, at 19:56, John Baldwin = <jhb@FreeBSD.org> wrote:

On 11/28/23 9:07 AM, = Warner Losh wrote:
On Tue, Nov 28, 2023 at = 9:06=E2=80=AFAM John Baldwin <jhb@freebsd.org> = wrote:
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.

Today we load 512k = always.

Well, we load the partition size always. =  The default size of the partition
has grown over time. =  Arguably we should have been using padding instead of
growing = the partition, but that is harder to write in installer tools, = etc.
When I wrote pmbr I on purpose used the partition size as the = size to load
rather than trying to assume information about the = payload and parse a
length from the payload due to the limited room = in the MBR.  I think we
started out creating freebsd-boot = partitions that were 64k and later grew
them with a desire they could = be replaced with an ESP partition, but ESPs
need a minimum size of = 512k?


The size is not = specified (from UEFI_Spec_2_10_Aug29):

"It is outside of = the scope of this specifi- cation to attempt to coordinate the = specification of size and location of an ESP that can be shared by = multiple OS or Diagnostics installations, or to manage potential = namespace collisions in directory naming in a single (central) = ESP.=E2=80=9D

and 

"The EFI firmware must support the = FAT32, FAT16, and FAT12 variants of the EFI file system. What variant of = EFI FAT to use is defined by the size of the media.=E2=80=9D

In = reality, there are systems which only support FAT32 on hard disks, and = that will set minimum size ~34MB with 512B sector and a bit over 256MB = with 4k sector. 

However, there are suggestions from vendors (notably = Microsoft), to have at least ~100MB to make it possible to store = auxiliary files such as diagnostics and other = tools.

rgds,
toomas
= --Apple-Mail=_1938CAEA-1A7B-4C6C-AC05-91F5BC64EA33--