Skip to content

pflash size check appears to be incompatible with OVMF on x86

Host environment

  • Operating system: Arch Linux
  • OS/kernel version: Linux 6.0.6-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sat, 29 Oct 2022 14:11:29 +0000 x86_64 GNU/Linux
  • Architecture: x86_64
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: 7.1.50

Commit https://github.com/qemu/qemu/commit/334c388f25707a234c4a0dea05b9df08d7746638 introduced an error when a pflash device's size is not a power of two. This error triggers when trying to start a Windows VM using OVMF firmware with the parameters -drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd -drive if=pflash,format=raw,unit=1,file=/tmp/OVMF_VARS.fd.

Indeed, OVMF_VARS.secboot.fd (from Arch Linux edk2-ovmf version 202208-1) has a size of 1966080 bytes, which is not a power of two. Trying to work around the check using truncate -s 2097152 /usr/share/edk2-ovmf/x64/OVMF_CODE.secboot.fd appears to function, but the VM does not boot.

Edited by main()
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information