From: Glenn Washburn Date: Sun, 9 Jun 2024 02:42:34 +0000 (-0500) Subject: tests/util/grub-shell: Use pflash instead of -bios to load UEFI firmware X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2fc9dfcd1ca6fa7e8bd281b1b2d36dc125ecd20;p=thirdparty%2Fgrub.git tests/util/grub-shell: Use pflash instead of -bios to load UEFI firmware According to the OVMF whitepaper [1]: IMPORTANT: Never pass OVMF.fd to qemu with the -bios option. That option maps the firmware image as ROM into the guest's address space, and forces OVMF to emulate non-volatile variables with a fallback driver that is bound to have insufficient and confusing semantics. Use the pflash interface instead. Currently the unified firmware file is used, which contains both firmware code and variable sections. By enabling snapshot on the pflash device, the firmware can be loaded in such a way that variables can be written to without writing to the backing file. Since pflash does no searching for firmware paths that are not absolute, unlike the -bios option, also make firmware paths absolute. Additionally, update the previous firmware paths or file names that did not correspond to ones installed by Debian. Use the q35 machine, instead of the default i440fx, for i386-efi because the default machine type does not emulate a flash device, which is now needed to load the firmware. [1] http://www.linux-kvm.org/downloads/lersek/ovmf-whitepaper-c770f8c.txt Signed-off-by: Glenn Washburn Reviewed-by: Daniel Kiper --- diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 3113cc3a2..89b9d4205 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -181,21 +181,26 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 - qemuopts="-bios OVMF-ia32.fd $qemuopts" + pflash=/usr/share/qemu/OVMF32.fd + qemuopts="-drive if=pflash,format=raw,unit=0,snapshot=on,file=$pflash $qemuopts" + qemuopts="-machine q35 $qemuopts" ;; x86_64-efi) qemu=qemu-system-x86_64 boot=cd console=console trim=1 - qemuopts="-bios OVMF.fd $qemuopts" + pflash=/usr/share/qemu/OVMF.fd + qemuopts="-drive if=pflash,format=raw,unit=0,snapshot=on,file=$pflash $qemuopts" ;; arm64-efi) qemu=qemu-system-aarch64 boot=hd console=console trim=1 - qemuopts="-machine virt -cpu cortex-a57 -bios /usr/share/qemu-efi/QEMU_EFI.fd $qemuopts" + pflash=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd + qemuopts="-drive if=pflash,format=raw,unit=0,snapshot=on,file=$pflash $qemuopts" + qemuopts="-machine virt -cpu cortex-a57 $qemuopts" disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" serial_port= ;; @@ -204,7 +209,9 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=hd console=console trim=1 - qemuopts="-machine virt -bios /usr/share/ovmf-arm/QEMU_EFI.fd $qemuopts" + pflash=/usr/share/AAVMF/AAVMF32.fd + qemuopts="-drive if=pflash,format=raw,unit=0,snapshot=on,file=$pflash $qemuopts" + qemuopts="-machine virt $qemuopts" disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" serial_port=efi0 ;;