WIP: Own loaded kernel and library allocations through handover #34

Draft
erikinkinen wants to merge 13 commits from feature/loaded-kernel-image-grants into feature/firmware-topology-snapshot
Owner

Summary and rationale

Keep the kernel and each resolved shared library in original UEFI allocation owners through linking and handover. Describe their real allocations and exact PT_LOAD spans so the kernel can retain running libraries without granting a virtual hull across gaps.

Tracking and scope

Implements #33 atop #32 and composes the explicit runtime-provider contract from #36. Selects lib-handoff#13 and coordinates kernel#123 and kernel#143. Native image and SMP acceptance remains open.

Architecture, authority and failure behavior

Each image allocation immediately enters a unique owner. Copies and relocations require that original mutable owner; sealing removes those interfaces. Check initialized-byte/BSS compatibility and ELF alignment before loading. On failure, release images in reverse order; uncertain release retains custody and fail-stops.

Retain whole allocations, including holes, while mapping only the normalized segment page union. Compatible shared pages combine their page-granular policy; effective W+X refuses. Preserve original ELF flags and verify primary leaf backing and permissions. Cache selectors describe the actual PTE encoding, with PAT/MTRR meaning handled separately.

A prepared transfer binds the real image, table, BSP stack, handoff, source-image and startup owners before exit. Before any exit attempt, errors may return for cleanup. After an attempt, unrecoverable errors halt with original owners retained; stale map keys retry without allocating. The final raw memory partition must still match the prepared handoff, allowing equivalent descriptor splits and merges. Successful exit masks interrupts. Fixed nonreturning assembly withdraws old global translations, switches CR3 and the owned RSP, checks control state and jumps to the kernel. No Rust stack or metadata access follows the root switch. Global identity aliases and AP policy remain part of the coordinated native work.

Validation evidence

  • All 13 component gates, preserving the original gates
  • Strict host and native UEFI Clippy, warning-denied builds, rustdoc and Markdown
  • 75 Rust controls covering original ownership, refusal, initialization, relocation and page policy
  • Actual console and nonconsole UEFI release builds
  • Compiled PE control: 12 register/readback cases and four mutated-code controls
  • Current published CI
  • Coordinated native image and 1-, 2- and 4-CPU acceptance with the original-entry consumer

The compiled controls exercise the emitted transition instructions. They do not substitute for firmware or guest execution.

Review checklist

  • Original implementation and documented source/ownership contracts
  • Signed commits with rationale-bearing bodies
  • Cargo dependencies remain on main; public companion selection is explicit
  • Cohesive source files below 1,000 lines
  • README, ARCHITECTURE, ROADMAP and focused design updated
  • Descriptions, hashes and reservations kept distinct from original allocation grants
## Summary and rationale Keep the kernel and each resolved shared library in original UEFI allocation owners through linking and handover. Describe their real allocations and exact PT_LOAD spans so the kernel can retain running libraries without granting a virtual hull across gaps. ## Tracking and scope Implements #33 atop #32 and composes the explicit runtime-provider contract from #36. Selects [lib-handoff#13](https://git.erikinkinen.fi/erix/lib-handoff/pulls/13) and coordinates [kernel#123](https://git.erikinkinen.fi/erix/kernel/issues/123) and [kernel#143](https://git.erikinkinen.fi/erix/kernel/issues/143). Native image and SMP acceptance remains open. ## Architecture, authority and failure behavior Each image allocation immediately enters a unique owner. Copies and relocations require that original mutable owner; sealing removes those interfaces. Check initialized-byte/BSS compatibility and ELF alignment before loading. On failure, release images in reverse order; uncertain release retains custody and fail-stops. Retain whole allocations, including holes, while mapping only the normalized segment page union. Compatible shared pages combine their page-granular policy; effective W+X refuses. Preserve original ELF flags and verify primary leaf backing and permissions. Cache selectors describe the actual PTE encoding, with PAT/MTRR meaning handled separately. A prepared transfer binds the real image, table, BSP stack, handoff, source-image and startup owners before exit. Before any exit attempt, errors may return for cleanup. After an attempt, unrecoverable errors halt with original owners retained; stale map keys retry without allocating. The final raw memory partition must still match the prepared handoff, allowing equivalent descriptor splits and merges. Successful exit masks interrupts. Fixed nonreturning assembly withdraws old global translations, switches CR3 and the owned RSP, checks control state and jumps to the kernel. No Rust stack or metadata access follows the root switch. Global identity aliases and AP policy remain part of the coordinated native work. ## Validation evidence - [x] All 13 component gates, preserving the original gates - [x] Strict host and native UEFI Clippy, warning-denied builds, rustdoc and Markdown - [x] 75 Rust controls covering original ownership, refusal, initialization, relocation and page policy - [x] Actual console and nonconsole UEFI release builds - [x] Compiled PE control: 12 register/readback cases and four mutated-code controls - [x] Current published CI - [ ] Coordinated native image and 1-, 2- and 4-CPU acceptance with the original-entry consumer The compiled controls exercise the emitted transition instructions. They do not substitute for firmware or guest execution. ## Review checklist - [x] Original implementation and documented source/ownership contracts - [x] Signed commits with rationale-bearing bodies - [x] Cargo dependencies remain on main; public companion selection is explicit - [x] Cohesive source files below 1,000 lines - [x] README, ARCHITECTURE, ROADMAP and focused design updated - [x] Descriptions, hashes and reservations kept distinct from original allocation grants
Own every runtime allocation immediately, validate compatible source initialization before copying, and require the same mutable image owner for relocations. Normalize only the exact segment page union, retain whole original allocation exclusions, encode the coordinated runtime group, and check actual primary leaf policy with post-exit NX and supervisor write-protection admission.
Document the allocation lifecycle, compatible source initialization, page-granular permission unions and the separate native hardware boundary. Keep a refused-release fixture quarantined to prove the original fields survive, and use the checked alignment predicate in the owned-table reader.
Carry actual PT_LOAD alignment through fixed and dynamic sources, select a conforming checked library bias, and refuse invalid congruence or shared W+X before allocating image pages. Remove the obsolete region-count error now that original ledger capacity and normalized mapping capacity are checked separately.
Prepare the complete original image, table, stack, source and handoff owners before firmware exit. Mask interrupts at successful exit, consume cleanup handles while their aliases remain, then use fixed nonreturning assembly for global-translation withdrawal, root and stack installation, control-register readback and the Kernel entry jump. Keep handoff allocation custody private instead of exposing mutable physical-owner fields.
Move successful-exit retention into consuming original-owner operations, centralize pre-exit NX admission in the prepared transfer, and name post-exit hardware admission for its full NX and write-protection duties. Remove obsolete mutability now that the original boot-image owner moves into the nonreturning transition.
Run independent register and control semantics over the actual built PE stub, including failed readbacks and mutated instruction controls. Require original executable Kernel bytes for entry, admit the actual four-level CPU mode before exit, and keep the compiled control distinct from real native execution acceptance.
Wrap the source-initialization and hardware handover descriptions to the repository prose width without changing their contracts.
Keep the compiler memory barrier on the successful-exit and hardware-admission CLI instructions. The irreversible interrupt boundary must not allow surrounding ownership stores to move across masking.
ci: Enforce strict Clippy on privileged UEFI paths
All checks were successful
CI / test (pull_request) Has been skipped
CI / markdown (pull_request) Has been skipped
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 50s
a819ca74af
Check the real UEFI target after its original native build, using the same owned source gateway and mandatory warning policy. Keep hosted unit checks and compiled transfer controls alongside this native-only lint coverage.
erikinkinen added this to the Alpha 1 milestone 2026-11-13 16:01:14 +01:00
fix: Require an explicit Kernel runtime provider contract
All checks were successful
CI / test (pull_request) Has been skipped
CI / markdown (pull_request) Has been skipped
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 47s
0776f2cc82
Resolve compiler-runtime fallback imports only through an exact authenticated declaration and a real definition in the original Kernel load segments. Remove name-prefix guesses, reject malformed or duplicate contracts and keep unrelated Kernel symbols outside the fallback scope. This permits legitimate compiler trait imports without granting a broader namespace.
Distinguish failures before and after the first actual exit callback, preserving owners without firmware return after a possible partial shutdown. Retain the real normalization source snapshot and require the same semantic memory partition on every final refresh, allowing unchanged class splits, merges and ordering. Add callback-sequence and partition controls, and mask and halt native uncertain-cleanup frames.
merge: Compose explicit runtime providers with original image owners
All checks were successful
CI / test (pull_request) Has been skipped
CI / markdown (pull_request) Has been skipped
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 49s
a20ae364d5
Preserve the public runtime-export contract and real original definition checks while retaining owner-scoped image materialization and relocations. Remove both obsolete conflict paths: mangled-prefix guessing and writes authorized by mapping descriptions. Keep both feature ancestries for coordinated review and native acceptance.
Author
Owner

The allocation ledger and nonreturning handover are implemented, including safe handling of partial firmware exit and final memory-map changes. This also composes #36 without restoring prefix-based symbol guesses or map-authorized relocation writes. Coordinated native admission with the kernel consumer remains open.

The allocation ledger and nonreturning handover are implemented, including safe handling of partial firmware exit and final memory-map changes. This also composes #36 without restoring prefix-based symbol guesses or map-authorized relocation writes. Coordinated native admission with the kernel consumer remains open.
refactor: Separate dynamic ELF source controls
All checks were successful
CI / test (pull_request) Has been skipped
CI / markdown (pull_request) Has been skipped
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 49s
e5387118c4
Keep the composed dynamic loader below the source-file size limit by moving its existing segment-shape controls into a dedicated test module. Preserve the original fixture and every assertion without changing loader behavior.
All checks were successful
CI / test (pull_request) Has been skipped
CI / markdown (pull_request) Has been skipped
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 49s
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'feature/loaded-kernel-image-grants:feature/loaded-kernel-image-grants'
git switch 'feature/loaded-kernel-image-grants'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'feature/firmware-topology-snapshot'
git merge --no-ff 'feature/loaded-kernel-image-grants'
git switch 'feature/loaded-kernel-image-grants'
git rebase 'feature/firmware-topology-snapshot'
git switch 'feature/firmware-topology-snapshot'
git merge --ff-only 'feature/loaded-kernel-image-grants'
git switch 'feature/loaded-kernel-image-grants'
git rebase 'feature/firmware-topology-snapshot'
git switch 'feature/firmware-topology-snapshot'
git merge --no-ff 'feature/loaded-kernel-image-grants'
git switch 'feature/firmware-topology-snapshot'
git merge --squash 'feature/loaded-kernel-image-grants'
git switch 'feature/firmware-topology-snapshot'
git merge --ff-only 'feature/loaded-kernel-image-grants'
git switch 'feature/firmware-topology-snapshot'
git merge 'feature/loaded-kernel-image-grants'
git push origin 'feature/firmware-topology-snapshot'
Sign in to join this conversation.
No description provided.