roadmap BUILT

195. Finish the UEFI boot path: the suite under firmware, the memory it gives back, and a second core

Built. The UEFI loader boots the kernel's tour under OVMF and, once calef has run it, on the OptiPlex. This milestone is the three follow-ons of milestone 87 (the x86_64 bare-metal machine). All three are done, and the first one was not small.

The three, and what each turned out to be

Run the kernel suite under firmware, not just the tour

cargo xtask uefi-test does, and script/test --arch x86_64 runs it after the tour. 192 passed, 68 skipped under OVMF, which is the same 192 and the same 68 names as under PVH, because the runner now attaches the PVH runner's virtio-blk-pci disk, NVMe controller and intel-iommu too. The tree can now say "it passes under real firmware" rather than only "it boots under real firmware".

It was scoped as a two-line change to uefi_image and was not, for a reason only a bigger kernel could show. The test build's physical span reaches 10 MiB where the tour's reaches 2.3, and OVMF keeps ACPI NVS at 8 MiB and its own boot-services allocations from 9 to 23.5. So AllocatePages(AllocateAddress) refused the whole range and the firmware said Load Error and nothing else.

Two things came of that:

Reclaim boot-services memory

Re-measured rather than inherited, because the runner's default moved to 2 GiB. Boot-services code and data, plus EfiLoaderCode (the loader's own PE image and its one-shot trampoline, both dead by then), are reported as RAM now. 2032128 KiB of usable RAM on a 2 GiB machine becomes 2068244. And 206684 becomes 233148 on a 256 MiB one. EfiLoaderData stays reserved and must: the hvm_start_info, the memory map, the module list, the archive and the kernel image are all in it.

The asymmetry holds without anyone remembering it, which is why it is worth stating: the only allocation this loader makes as LOADER_CODE is the trampoline, and it asks for that because firmware sets the execute-disable bit on data.

SMP under UEFI

The loader asks the firmware for physical 0x8000 by name instead of assuming it. Two cores come up under OVMF, five runs out of five, and cargo xtask uefi-boot gates it. A refusal of that page is a printed warning rather than a failed boot, because a single-core boot on a machine whose firmware wants it is worth more than none.

It was grouped here as "may not be small" against milestone 161's two open ap_boot defects. It met one of them: every_secondary_runs_scheduled_work fails about half the time at two cores, which is why the suite stays at one core and the tour is where the second one is gated. Neither defect was touched.

What it took off xenon's evening

Milestone 215's (a PCI function's interrupt on x86_64) BUGS listed three things only the OptiPlex could confirm. Two are now answered on patagonia, both of them because real firmware enumerates the bus and places every BAR before nife exists:

The third is still xenon's: whether the OptiPlex's firmware leaves VT-d interrupt remapping off.

BUGS

Follow-on

Index row

The kernel suite runs under OVMF now (cargo xtask uefi-test): the same 192 passes and the same 68 skips as under PVH. Boot-services memory and the loader's own code come back, 36 MiB of a 2 GiB machine. Two cores come up under firmware and the tour gates it. It also moved PHYS_START to 32 MiB, because the test build would not load at 1 MiB under real firmware at all, and closed two of the three things milestone 215 recorded as answerable only at a bench.