Skip to content

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

Draft
martijnhoekstra wants to merge 1 commit into
hermit-os:mainfrom
martijnhoekstra:fix/x86_64-linux-memory-map
Draft

martijnhoekstra wants to merge 1 commit into
hermit-os:mainfrom
martijnhoekstra:fix/x86_64-linux-memory-map

Conversation

@martijnhoekstra

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

1 participant