Public bug reported:

This is on Ubuntu 26.04.1 (resolute) with ovmf-generic
2025.11-3ubuntu7.3 (source package edk2) and qemu-system-x86
1:10.2.1+ds-1ubuntu3.3. The firmware in 2025.11-3ubuntu7.4 from
resolute-proposed behaves the same way.

An x86_64 guest that reboots can hang inside OVMF before the firmware
prints anything: there is nothing on the serial port, and the display
stays at "Guest has not initialized the display (yet)". Whether it
happens depends on what the guest left in one page of its memory, so
from the outside it looks random. I ran into it in the CI of ClaraOS
(https://claraos.org), a hobby operating system I work on, where a test
that reboots a guest hung in 3 of 36 runs on GitHub's Ubuntu 26.04
runners. When I looped that test in a 26.04 container, the reboot hung
37 times out of 65.

What goes wrong

edk2-stable202511 looks at the page at 0x812000 (PcdOvmfIgvmParamBase)
on every boot, for a memory map that an IGVM loader may have put there
(PlatformIgvmMemoryMapFind in OvmfPkg/Library/PlatformInitLib/Igvm.c,
which came with upstream commit 5e8db785e4). It takes the page for such
a map when the first entry's PageCount, the 64-bit word at offset 8, is
not zero, its EntryType is below 16 and its Reserved field is zero, and
it then uses that map instead of the one QEMU provides. The firmware
does not keep the page to itself, though: its own memory map hands
0x812000 to the OS as ordinary free memory. QEMU keeps the contents of
RAM across a reset, so when a guest has stored something there and
reboots, the firmware reads the guest's data as the machine's memory
map. In the hung guest that I took apart, the firmware had put the
64-bit PCI MMIO window at 0x200000800000000, and PciHostBridgeDxe was
going round a loop that it never left.

Upstream fixed it on 2025-12-10 by reserving the page:

  OvmfPkg/PlatformInitLib: reserve igvm parameter area
  
https://github.com/tianocore/edk2/commit/e4f99a85545f41ef7ae23cd939484d69a84b6176

That commit is in edk2-stable202602 and later, so 26.10 and 27.04
(2026.05-2ubuntu3) already have it, and so do Debian testing and
unstable. Resolute is the only series whose edk2 was cut between the two
commits.

How to see it

The firmware's memory map shows it without any guest. With efi-shell-x64
installed:

  mkdir -p esp/EFI/BOOT
  cp /usr/share/efi-shell-x64/shellx64.efi esp/EFI/BOOT/BOOTX64.EFI
  printf 'memmap\r\nreset -s\r\n' > esp/startup.nsh
  cp /usr/share/OVMF/OVMF_VARS_4M.fd vars.fd
  qemu-system-x86_64 -machine q35 -m 512M -display none -nic none -serial stdio 
\
      -drive 
if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \
      -drive if=pflash,format=raw,file=vars.fd \
      -drive file=fat:rw:esp,format=raw | grep -a ' 00000000008'

With 2025.11-3ubuntu7.3, one of the lines it prints has the page in the
middle of an available range:

  Available  000000000080C000-0000000000813FFF 0000000000000008
000000000000000F

With the firmware files from 26.10's ovmf-generic 2026.05-2ubuntu3, on
the same QEMU, it is held back:

  Available  000000000080C000-0000000000811FFF 0000000000000006 000000000000000F
  RT_Data    0000000000812000-0000000000812FFF 0000000000000001 800000000000000F
  Available  0000000000813000-0000000000813FFF 0000000000000001 000000000000000F

To see what the firmware does once there is data in the page, QEMU's
loader device can write two words there at every reset, on a machine
with no disk. These are the two words that were in the page of one of
the hung guests:

  cp /usr/share/OVMF/OVMF_VARS_4M.fd vars.fd
  qemu-system-x86_64 -machine q35 -m 512M -display none -nic none -serial stdio 
\
      -drive 
if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \
      -drive if=pflash,format=raw,file=vars.fd \
      -device loader,addr=0x812000,data=0x20000017a5d0,data-len=8 \
      -device loader,addr=0x812008,data=0x268,data-len=8

That prints nothing for as long as I leave it running. Without the two
loader lines, "BdsDxe: No bootable option or device was found." is on
the serial port within a few seconds. One caveat: this command writes
the page from outside the guest, whatever the memory map says, so it
hangs a fixed firmware too (I tried 2026.05-2ubuntu3). To tell whether a
package has the fix, look at the memory map.

What I'm asking for

Could e4f99a8554 be backported to edk2 in resolute as an SRU? It is a
small change, one memory allocation HOB that marks the page as runtime
data, and the only thing a guest should notice is that it has one 4 KiB
page fewer. The commit applies to edk2-stable202511 as it is, and none
of the patches in the package touch the four files it changes. I have
not built it.

On the ClaraOS side I have changed the system to keep away from that
page (with that change the same loop went 48 reboots without a hang), so
nothing of mine is waiting on this. I'm reporting it because any guest
that happens to write to that page and then reboots can end up the same
way. I have only tried OVMF_CODE_4M.fd under TCG, and I have not tried
to make a Linux guest do it.

The longer story, with how it was tracked down, is at
https://github.com/the-clara-os/clara-os/issues/78

** Affects: edk2 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: resolute

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2175541

Title:
  OVMF can hang on guest reboot: IGVM parameter page 0x812000 is given
  to the guest as free memory (upstream fix e4f99a8554 missing in
  2025.11)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/edk2/+bug/2175541/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to