Date: Tue, 28 Nov 2023 20:06:02 +0200 From: Toomas Soome <tsoome@me.com> To: John Baldwin <jhb@FreeBSD.org> Cc: Warner Losh <imp@bsdimp.com>, Warner Losh <imp@freebsd.org>, src-committers <src-committers@freebsd.org>, "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, dev-commits-src-main@freebsd.org Subject: Re: git: c596126a5d3d - main - pmbr: Only load the first 545k rather than error out Message-ID: <234CE696-4583-41CF-A94D-3D29EA4676C5@me.com> In-Reply-To: <e5973b11-f84c-40c7-bda1-dc666263eb3f@FreeBSD.org> References: <202311272246.3ARMkNS1037267@gitrepo.freebsd.org> <8fa6ed4d-c26b-4dd6-86f2-c3751f86d426@FreeBSD.org> <CANCZdfqC_Y2%2Bj7Vi5rWbKagyByk7xrWBy6H0q8qw8hDpZc4WuQ@mail.gmail.com> <e5973b11-f84c-40c7-bda1-dc666263eb3f@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <jhb@FreeBSD.org> 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 = <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. >>>=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 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;"><br = id=3D"lineBreakAtBeginningOfMessage"><div><br><blockquote = type=3D"cite"><div>On 28. Nov 2023, at 19:56, John Baldwin = <jhb@FreeBSD.org> wrote:</div><br = class=3D"Apple-interchange-newline"><div><div>On 11/28/23 9:07 AM, = Warner Losh wrote:<br><blockquote type=3D"cite">On Tue, Nov 28, 2023 at = 9:06=E2=80=AFAM John Baldwin <jhb@freebsd.org> = wrote:<br><blockquote type=3D"cite">But also, can't you just leave a gap = in the partitions to leave room<br>for a future ESP? It might not = always be safe to load a full 545k<br>depending on if the firmware has = reserved some of memory just below<br>640k. 545k is an upper bound = on how much can be loaded in terms of<br>640k - the load address, but = the practical limit might be lower. It is<br>probably safer as a = general rule to keep the boot partition closer to<br>the size of the = boot loader and leave a gap in place = instead.<br><br></blockquote>Today we load 512k = always.<br></blockquote><br>Well, we load the partition size always. = The default size of the partition<br>has grown over time. = Arguably we should have been using padding instead of<br>growing = the partition, but that is harder to write in installer tools, = etc.<br>When I wrote pmbr I on purpose used the partition size as the = size to load<br>rather than trying to assume information about the = payload and parse a<br>length from the payload due to the limited room = in the MBR. I think we<br>started out creating freebsd-boot = partitions that were 64k and later grew<br>them with a desire they could = be replaced with an ESP partition, but ESPs<br>need a minimum size of = 512k?<br><br></div></div></blockquote><br></div><div>The size is not = specified (from UEFI_Spec_2_10_Aug29):</div><div><br></div><div>"<span = style=3D"font-family: NimbusRomNo9L; font-size: 10pt;">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.</span><font face=3D"NimbusRomNo9L" = size=3D"2">=E2=80=9D</font></div><div><span style=3D"font-family: = NimbusRomNo9L; font-size: 10pt;"><br></span></div><div><font = face=3D"NimbusRomNo9L" size=3D"2">and </font></div><div><font = face=3D"NimbusRomNo9L" size=3D"2"><br></font></div><div><font = face=3D"NimbusRomNo9L" size=3D"2">"</font><span style=3D"font-family: = NimbusRomNo9L; font-size: 10pt;">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.</span><font = face=3D"NimbusRomNo9L" size=3D"2">=E2=80=9D</font></div><div><span = style=3D"font-family: NimbusRomNo9L; font-size: = 10pt;"><br></span></div><div><font face=3D"NimbusRomNo9L" size=3D"2">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. </font></div><div><font face=3D"NimbusRomNo9L" = size=3D"2"><br></font></div><div><font face=3D"NimbusRomNo9L" = size=3D"2">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.</font></div><div><font face=3D"NimbusRomNo9L" = size=3D"2"><br></font></div><div><font face=3D"NimbusRomNo9L" = size=3D"2">rgds,</font></div><div><font face=3D"NimbusRomNo9L" = size=3D"2">toomas</font></div></body></html>= --Apple-Mail=_1938CAEA-1A7B-4C6C-AC05-91F5BC64EA33--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?234CE696-4583-41CF-A94D-3D29EA4676C5>