Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

fix(x86_64-linux): only hand free RAM to the kernel - #650

Merged
stlankes merged 1 commit into
hermit-os:mainfrom
martijnhoekstra:fix/x86_64-linux-memory-map
Nov 12, 2026
Merged

stlankes merged 1 commit into
hermit-os:mainfrom
martijnhoekstra:fix/x86_64-linux-memory-map

Conversation

@martijnhoekstra

Copy link
Copy Markdown
Contributor

Fixes #649.

The Linux boot path now passes only E820 RAM entries to the kernel as /memory nodes. It also adds an FDT memory reservation from the loader's start to the end of the boot stack or of PhysAlloc's allocations, whichever is higher. That covers the loader image with its page tables, the boot stack, page tables allocated without 1-GiB page support, and the kernel image. The kernel already honours FDT memory reservations. The multiboot and UEFI paths pass none.

Tested with kernel main:

  • The kernel CI's Firecracker command (rusty_demo) passes on Firecracker v1.12.0. On v1.17.0, rusty_demo gets to exit status 0, but Firecracker then reports the guest's shutdown as an error. That is a separate problem.
  • On a 256 MiB VM the kernel reports 250 MiB, and its free list starts at 0x802000.
  • An echo server with virtio-net and without pci passes TCP and UDP tests on both Firecracker versions.
  • The multiboot loader still boots the same server with pci on QEMU q35 (TCG).
  • cargo fmt is clean, and cargo xtask clippy gives the same warnings as on main for all five targets.

Not tested: the loader's xtask ci jobs, UEFI boot, more than one vCPU, and a CPU without 1-GiB pages. That last case is the only one where the loader allocates page tables from PhysAlloc.

The Linux boot path passed every E820 entry to the kernel as memory,
including reserved ones, and didn't reserve the loader's own memory.
Under Firecracker the kernel then handed out frames from the reserved
range at 0xeec00000 and from the page tables and boot stack it still
uses.

Pass only E820 RAM entries, and reserve the loader image, boot stack
and PhysAlloc allocations in the FDT.

Assisted-by: Claude:claude-opus-5-5
@martijnhoekstra
martijnhoekstra marked this pull request as ready for review November 11, 2026 11:44

@stlankes stlankes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I checked that the reservation covers everything the kernel still uses.

@stlankes
stlankes added this pull request to the merge queue Nov 12, 2026
Merged via the queue into hermit-os:main with commit 778fec6 Nov 12, 2026
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x86_64-linux: the kernel gets reserved memory and the loader's own memory as free RAM

2 participants