notes

What booting under OVMF proves, measured

An appendix to notes/x86-uefi-boot.md, which keeps the conclusion. This file holds the PVH-against-UEFI table, the four code paths it exercised for the first time, and the RAM milestone 195 (finish the UEFI boot path) reclaimed.

The comparison

The table below was measured with both boots at -m 256M, before milestone 195 reclaimed boot-services memory. The usable ram row is the one that moved; the next section records both figures. The runner's default is now 2 GiB (NIFE_MEM=256M reproduces the table). Firmware places its ACPI tables just under the top of RAM, so the memory size decides what physical addresses the kernel is asked to read. At 256 MiB they land low enough that a reach bug in the ACPI walk cannot show. One did, for as long as this script matched its PVH sibling; see notes/x86-port.md's BUGS.

The same kernel, same machine model, same -m 256M, booted twice. Everything that differs is the firmware.

PVH (-kernel) UEFI (OVMF)
memory map 9 regions 118 regions
rsdp in the handoff 0x0 0xfb7e014
RSDP revision / root 0, RSDT 2, XSDT
PCIe ECAM (from the MCFG) 0xb0000000 0xe0000000
usable RAM 261627 KiB 206684 KiB
RAM regions the allocator got 1 7 (8 with an archive)

Four of those are code paths that had never executed:

And the userspace archive arrives the same way it does under PVH, through the module list this loader writes:

  initrd      : 5229568 bytes at 0xd9bc000, 68 programs, from the PVH module list

The RAM that was left on the table, and how much came back

Before milestone 195 it was 206684 KiB against PVH's 261627 KiB. So about 54 MiB of a 256 MiB machine was reported reserved that a Linux-style loader would reclaim. That was a choice rather than a defect, in the conservative direction on purpose. Claiming less RAM than exists costs megabytes; claiming more corrupts something, on hardware nobody can attach a debugger to.

After it: 233148 KiB on the same 256 MiB machine, and 2068244 KiB against 2032128 on a 2 GiB one. Two classes moved, both of them dead by the time the kernel reads the map:

EfiLoaderData stays reserved, and must. Every allocation this loader makes that the kernel reads later asks for it: the hvm_start_info, the memory map, the module list, the archive, and the kernel image itself. The asymmetry is not a rule anyone has to remember, which is what makes it hold. The only thing asking for LOADER_CODE is the trampoline, and it asks because firmware sets the execute-disable bit on data allocations.

What is still reported reserved on the 256 MiB machine is 28 MiB, against PVH's 0.5 MiB. That is the firmware's own runtime services, ACPI NVS, its reserved ranges, and the loader's EfiLoaderData, and none of it is ours to take.