handoff: pin BootHandoffV1's layout at compile time in both crates #157

Open
nonos-sync wants to merge 2 commits from nonos-sync/gh-612 into main AGit
Member

@eKisNonos, fixes #608.

BootHandoffV1 is still defined by hand in both crates. Each crate now has a layout.rs with the same compile-time asserts: the size of the struct and of every field type, plus the offset of every field.

The numbers were measured from both crates (compile-error probes) and agree: 2008 bytes, firmware at 280, cmdline_ptr at 1824, policy at 1832.

Verification:

  • Kernel cargo check (microkernel-core) passes.
  • Bootloader cargo check --target x86_64-unknown-uefi passes with --features dev-qemu and --features production.
  • Negative test: changing one offset (zk 208 to 209) fails the build with E0080.

Not boot-tested yet; this has no runtime effect.


Opened on GitHub by senseix21 as pull request 612. Review and merge happen there while this repository is kept in step from GitHub; this copy follows it, and is marked merged or closed when it is.

@eKisNonos, fixes [#608](https://github.com/NON-OS/nonos-micro-kernel/issues/608). `BootHandoffV1` is still defined by hand in both crates. Each crate now has a `layout.rs` with the same compile-time asserts: the size of the struct and of every field type, plus the offset of every field. The numbers were **measured** from both crates (compile-error probes) and agree: 2008 bytes, `firmware` at 280, `cmdline_ptr` at 1824, `policy` at 1832. **Verification:** - Kernel `cargo check` (`microkernel-core`) passes. - Bootloader `cargo check --target x86_64-unknown-uefi` passes with `--features dev-qemu` and `--features production`. - Negative test: changing one offset (`zk` 208 to 209) fails the build with E0080. Not boot-tested yet; this has no runtime effect. --- Opened on GitHub by senseix21 as [pull request 612](https://github.com/NON-OS/microkernel/pull/612). Review and merge happen there while this repository is kept in step from GitHub; this copy follows it, and is marked merged or closed when it is.
The loader and the kernel each define BootHandoffV1 by hand. The only
guard was the kernel's runtime size check, which catches a size change but
not two fields of the same size swapped or reordered, and it fires on boot,
not on build.

Both crates now carry the same compile-time asserts: the size of the struct
and of every field type, and the offset of every field. The numbers were
measured from both crates as they stand and agree (2008 bytes, cmdline_ptr
at 1824, policy at 1832). A field moved or resized on one side now fails
that side's build.

Refs #608
nonos-sync changed title from WIP: handoff: pin BootHandoffV1's layout at compile time in both crates to handoff: pin BootHandoffV1's layout at compile time in both crates 2026-10-10 05:09:39 -04:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin +refs/pull/157/head:nonos-sync/gh-612
git switch nonos-sync/gh-612
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
NON-OS/nonos-micro-kernel!157
No description provided.