spec: combine BIOS and EFI roms using "util/catrom.pl"

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1926561

When combining BIOS and EFI roms, the EfiRom utility from edk2-tools
clears the "last image indicator" in the BIOS ROM image header, and then
updates the checksum in the last byte of the BIOS ROM image. However,
EfiRom does not update any internal, iPXE-specific checksums in the BIOS
ROM image.

In the rare case when the checksum residing in the BIOS ROM's last byte
does not fall into such padding that was added previously by
"util/padimg.pl" -- that is, if the BIOS image is a whole multiple of 512
bytes even without padding --, then the recalculation of *only* the last
byte invalidates the LZMA stream and/or an internal CRC32 checksum that
are embedded elsewhere in the BIOS ROM. Consequently, iPXE fails to
LZMA-decompress itself when booted on SeaBIOS.

iPXE's own "util/catrom.pl" utility knows how to update internal
(iPXE-specific) checksums; use this tool for combining the BIOS and EFI
images.

(

  In theory we could abandon EfiRom from edk2-tools altogether, and
  prepare even the stand-alone EFI driver image with iPXE-internal
  tooling. For this, we'd only have to build the
  "bin-x86_64-efi/${rom}.efirom" target, in place of the
  "bin-x86_64-efi/${rom}.efidrv" target. The iPXE build would
  automatically convert the latter into the former with the "util/efirom"
  program.

  Unfortunately, "util/efirom" does not support "EFI compression", and
  that would cause us to nearly exhaust our 256 KB "migration buffer".
  Therefore, continue using EfiRom, but only for compressing the "efidrv"
  binary to a single (not combined) EFI ROM image. Perform only the
  combination step with "util/catrom.pl".

)

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Laszlo Ersek 2021-02-18 04:16:46 +01:00 committed by Cole Robinson
parent cc925706f9
commit a515f8e718

View File

@ -53,7 +53,7 @@
Name: ipxe Name: ipxe
Version: %{date} Version: %{date}
Release: 2.git%{hash}%{?dist} Release: 3.git%{hash}%{?dist}
Summary: A network boot loader Summary: A network boot loader
License: GPLv2 with additional permissions and BSD License: GPLv2 with additional permissions and BSD
@ -175,12 +175,15 @@ for rom in %{qemuroms}; do
vid="0x${rom%%????}" vid="0x${rom%%????}"
did="0x${rom#????}" did="0x${rom#????}"
EfiRom -f "$vid" -i "$did" --pci23 \ EfiRom -f "$vid" -i "$did" --pci23 \
-b bin/${rom}.rom \
%if 0%{?efi_ia32} %if 0%{?efi_ia32}
-ec bin-i386-efi/${rom}.efidrv \ -ec bin-i386-efi/${rom}.efidrv \
%endif %endif
-ec bin-x86_64-efi/${rom}.efidrv \ -ec bin-x86_64-efi/${rom}.efidrv \
-o bin-combined/${rom}.rom -o bin-combined/${rom}.eficrom
util/catrom.pl \
bin/${rom}.rom \
bin-combined/${rom}.eficrom \
> bin-combined/${rom}.rom
EfiRom -d bin-combined/${rom}.rom EfiRom -d bin-combined/${rom}.rom
# truncate to at least 256KiB # truncate to at least 256KiB
truncate -s \>256K bin-combined/${rom}.rom truncate -s \>256K bin-combined/${rom}.rom
@ -243,6 +246,9 @@ done
%endif %endif
%changelog %changelog
* Tue Feb 23 2021 Cole Robinson <aintdiscole@gmail.com> - 20200823-3.git4bd064de
- combine BIOS and EFI roms using "util/catrom.pl"
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 20200823-2.git4bd064de * Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 20200823-2.git4bd064de
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild