grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] tests/util/grub-shell: Use pflash instead of -bios to load U


From: Glenn Washburn
Subject: [PATCH 1/2] tests/util/grub-shell: Use pflash instead of -bios to load UEFI firmware
Date: Sat, 8 Jun 2024 21:42:34 -0500

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 <development@efficientek.com>
---
 tests/util/grub-shell.in | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index 496e1bab33c8..b0fbc6969637 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
        ;;
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]