Skip to content

Add caller-backed PreparedImage and reserve prepared-image region outside kernel fixture - #64

Merged
thanks-cohn merged 2 commits into
mainfrom
codex/begin-engineering-bounded-machine-adapter
Aug 13, 2026
Merged

Add caller-backed PreparedImage and reserve prepared-image region outside kernel fixture#64
thanks-cohn merged 2 commits into
mainfrom
codex/begin-engineering-bounded-machine-adapter

Conversation

@thanks-cohn

Copy link
Copy Markdown
Owner

Motivation

  • Batch 31 discovered that the pinned BusyBox artifact requires ~245 candidate pages and that enlarging inline kernel backing is unsafe because it pushes the kernel image into the inherited 0x8040_0000 fixture range. The correct repair is a distinct bounded machine-adapter reservation plus PREPARE-time Sv39 table backing.
  • Implement a minimal, general mechanism so PREPARE can reserve backing and table pages atomically without growing the ordinary kernel image or weakening PREPARE/COMMIT atomicity and W+X=0 guarantees.

Description

  • Add PreparedImage and PreparedPage to projects/59-bounded-address-space-exec-image/src/bounded_address_space_exec_image.zig to materialize page bytes directly into caller-supplied backing while returning only bounded metadata and capacity errors.
  • Extend the freestanding machine path to use caller-backed prepared images by allocating external_prepared_backing and external_prepared_stack in a new linker reservation and invoking PreparedImage.prepare(..., backing) during PREPARE.
  • Add a dedicated linker PT_LOAD reservation region at 0x80600000 and PHDR/section changes so prepared-image storage is outside the ordinary image and the inherited fixture window.
  • Update PREPARE/COMMIT flow to preflight Sv39 table leaves against reserved backing, materialize the initial stack into reserved storage, replace the live stack only at COMMIT, and preserve W+X=0 and static-musl invariants.
  • Update module contracts, port/README/DETAILS/MASTERY text, COMMANDS.md, and add a Batch 31B handoff report documenting the frontier and next action.

Testing

  • zig build test-bounded-address-space-exec-image succeeded and unit tests covering inline MaterializedImage and the new PreparedImage behavior passed.
  • zig build smoke-bounded-address-space-exec-image succeeded and the focused materialization/safety smoke checks passed.
  • zig build install-freestanding-riscv64-morphic-runtime embedding the exact pinned BusyBox artifact completed successfully and produced an executable with a separate reservation PT_LOAD (no load segment now spans the inherited fixture window).
  • Repository tooling checks python3 tools/check-command-reference.py --check and the module contract consistency checks passed after updating details.json/port.js.
  • Host QEMU-based runtime verification python3 tools/verify-freestanding-riscv64-external-artifact-transport.py --self-test could not run here because qemu-system-riscv64 is not available, so PREPARE/COMMIT and U-mode BusyBox execution were not validated in this environment.
  • Repository index generation failed in this environment due to missing node, so aggregate index regeneration was not completed here; the focused module and recipe tests above were used to validate the change instead.

Codex Task

@thanks-cohn
thanks-cohn merged commit 2f45bb5 into main Aug 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant