Skip to content

Add support for PVH boot protocol; FreeBSD VM tests#646

Open
nohajc wants to merge 6 commits into
containers:mainfrom
nohajc:freebsd-tests-ready
Open

Add support for PVH boot protocol; FreeBSD VM tests#646
nohajc wants to merge 6 commits into
containers:mainfrom
nohajc:freebsd-tests-ready

Conversation

@nohajc
Copy link
Copy Markdown
Contributor

@nohajc nohajc commented Apr 21, 2026

Adds three new integration test cases:

  1. Boot FreeBSD VM and print OK
  2. Test FreeBSD TCP client
  3. Test FreeBSD TCP server

Adds PVH boot protocol support (based on #284) to enable FreeBSD boot on x86_64.

Direct kernel boot works

  • on macOS and Linux aarch64 with the raw boot image and generic kernel configuration
  • on Linux x86_64 with ELF PVH image and the Firecracker kernel configuration

Gvproxy with vfkit enabled on Linux via containers/gvisor-tap-vsock@c09fb7d

@nohajc nohajc force-pushed the freebsd-tests-ready branch 3 times, most recently from a5e37f8 to 0e77561 Compare April 21, 2026 23:07
@nohajc nohajc force-pushed the freebsd-tests-ready branch 14 times, most recently from a2f25a4 to 2165985 Compare May 2, 2026 20:01
Implement PVH (Para-Virtualized Hardware) boot protocol support,
enabling FreeBSD x86_64 kernels to boot via the Xen PVH ABI.

Key changes:
- arch/Cargo.toml: add linux-loader (elf feature) as x86_64 dep
- layout.rs: add PVH_INFO_START, MODLIST_START, MEMMAP_START, RSDP_ADDR
- mptable.rs: export MPTABLE_START as pub
- gdt.rs: fix get_limit() to apply granularity (G) bit expansion
- mod.rs: add configure_pvh(), add_memmap_entry(); refactor
  configure_system() to dispatch to configure_pvh() or
  configure_64bit_boot() based on pvh flag; add pvh param
- regs.rs: add pvh param to setup_regs/setup_sregs/
  configure_segments_and_sregs; set 32-bit protected mode GDT and
  CR0=PE|ET for PVH; set rbx=PVH_INFO_START per PVH ABI
- vstate.rs: thread pvh through configure_x86_64()
- builder.rs: detect PvhEntryPresent in ELF load result; propagate
  pvh through PayloadConfig, load_payload, create_vcpus_x86_64
- lib.rs: add pvh param to Vmm::configure_system()

Co-authored-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jan Noha <nohajc@gmail.com>
@nohajc nohajc force-pushed the freebsd-tests-ready branch 2 times, most recently from d29252f to 711b0b0 Compare May 2, 2026 21:42
@nohajc nohajc marked this pull request as ready for review May 2, 2026 21:57
nohajc added 2 commits May 3, 2026 00:13
- simple boot test, gvproxy connect and listen tests
- fix timing issue in all network listen tests
- replace the macOS-only `cfg` gate with a `gvproxy -version` check

Signed-off-by: Jan Noha <nohajc@gmail.com>
- have to install lld and also clang on the self-hosted runner

Signed-off-by: Jan Noha <nohajc@gmail.com>
nohajc added 2 commits May 3, 2026 00:13
Signed-off-by: Jan Noha <nohajc@gmail.com>
Signed-off-by: Jan Noha <nohajc@gmail.com>
@nohajc nohajc force-pushed the freebsd-tests-ready branch from 711b0b0 to a3bf760 Compare May 2, 2026 22:13
…the definition

Signed-off-by: Jan Noha <nohajc@gmail.com>
@nohajc nohajc force-pushed the freebsd-tests-ready branch from a3bf760 to b801ff5 Compare May 3, 2026 08:50
@nohajc
Copy link
Copy Markdown
Contributor Author

nohajc commented May 5, 2026

Ready for review.

@nohajc
Copy link
Copy Markdown
Contributor Author

nohajc commented May 11, 2026

Gonna make adjustments based on the new contribution guidelines. Mainly need to fix "co-authored by" for AI assistants.

Comment on lines +69 to +72
TestOutcome::Fail(format!(
"expected exactly {:?}, got {:?}",
"OK\n", output_str
))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The file test_freebsd_gvproxy_tcp_guest_connect.rs was introduced as part of this PR. Please squash this formatting fix into the appropriate commit tests: add FreeBSD guest support in this case.

@mtjhrc mtjhrc changed the title FreeBSD VM tests Add support for PVH boot protocol; FreeBSD VM tests May 11, 2026
@mtjhrc
Copy link
Copy Markdown
Collaborator

mtjhrc commented May 11, 2026

Thanks for working on this! I'll take a more detailed look later. Also note, that I changed the PR title, because this not only adds the tests but implements/revives the PVH boot support.

@nohajc
Copy link
Copy Markdown
Contributor Author

nohajc commented May 11, 2026

Makes sense. PVH is the enabler for the full test suite to cover all architectures but I wasn't sure at first if I can make it work.

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.

2 participants