[FEATURE] Own hardware page-table roots for native address-space switching #22

Open
opened 2026-09-21 23:45:23 +02:00 by erikinkinen · 0 comments
Owner

Problem and motivation

Native VSpace switches currently replay recorded mappings in the shared active page-table hierarchy. This makes each switch depend on the size of the participating address spaces, including during IPC. The executed-code investigation in Integration #3 identifies Kernel mapping batching and permission switching as leading code candidates. Those counts do not establish elapsed-time ownership or a speedup. Growing compiler heaps and threaded runtimes make this a relevant prerequisite for runtime memory and threading and complete native toolchain self-hosting.

Proposed behavior and scope

Give each native VSpace an owned hardware page-table root. Switching between already prepared address spaces must select the exact live root without replaying every recorded user mapping. Mapping creation, permission changes and revocation still update the authorized VSpace and complete required invalidation. Shared threads retain their existing VSpace identity; switching threads must preserve independent stack/TLS and process lifetime rules.

Kernel owns root construction, activation, table-page ownership and retirement. Coordinate existing Memd, Vspaced, Pagerd, Procd and Rootd consumers only where their contracts need changes. Integration owns native isolation/failure scenarios, exact-source images and profiling; Docs owns the memory, lifecycle and testing manual contracts. Preserve the native capability ABI unless a separately specified change is necessary. This is not a POSIX identity-based authority mechanism.

Authority, security and reliability

  • Existing caller-local MAP/MANAGE capabilities remain the sole external source of mapping authority. A root address, ID, cached translation or CPU register must not create or widen authority. Resolve live object identity and reject retiring/stale objects before activation or mutation.
  • Kernel owns page-table allocations for the exact VSpace lifetime. Ordinary snapshots must not retain an activation handle or duplicate cleanup ownership. Define shared supervisor mappings, recursive mappings and early bootstrap overlays explicitly; user entries must not mutate a shared supervisor subtree.
  • Preserve frame provenance, zero initialization, W^X, rights attenuation and generation checks. Pending mutations must not leave an unrecorded usable mapping. Source freshness and executable validation remain unchanged.
  • Define activation, mutation, revocation and retirement ordering for every resident CPU. Invalidation must cover global translations and any enabled context tags; root replacement alone is not a global-translation revocation proof. The architectural reference is the Intel system programming manual, including translation caching and invalidation.
  • Faults or partial allocation leave exact cleanup custody. Never resume ordinary use after uncertain withdrawal. Retire roots and table pages only after no CPU can execute or walk them, preserving frame-release and final-process-binding ordering. Define lock/interrupt order and allocation-free cleanup progress.

Acceptance criteria

Checklist
  • Document root/page/frame ownership, shared supervisor mappings, bootstrap handoff, lock order, CPU residency and retirement state transitions before hardware integration.
  • Implement owned roots and mapping/protection/unmapping for active and inactive VSpaces with existing authority, error-precedence and cleanup guarantees.
  • Add positive/negative controls for distinct contents at the same virtual address, shared-thread address spaces, read-only/NX denial, supervisor isolation, stale object reuse and inactive teardown while another space runs.
  • Inject construction, allocation, activation, revocation and final-release failures; prove no usable unowned root, residual mapping or leaked table/frame ownership. Preserve existing native lifetime, owned-invocation, mapping and pager regression coverage.
  • Validate concurrent CPU residency and acknowledged invalidation before claiming concurrent userspace execution. Accounting-only AP activity is not this evidence. Cover global entries, context-tag reuse if introduced, and delayed acknowledgements before reclamation.
  • Remove obsolete per-page switch replay and superseded APIs after equivalent native isolation/lifetime coverage passes. Do not retain an authority-bearing fallback or introduce new fixed mapping-count limits.
  • Use the maintained profiler to show switch work no longer scales with unchanged user mapping count, then demonstrate a measured improvement under the original uninstrumented startup/command acceptance rules. Retain failures and instrumentation overhead separately; no threshold or optimization-profile relaxation.
  • Pass formatting, strict Clippy, all required host/native matrices, missing-docs enforcement, source policy and warning-free test/image builds. Keep authored code files below 1,000 lines, update component/manual documentation, and monitor original CI.

Alternatives and tradeoffs

Further bit-expression rewrites are insufficient evidence: the first isolated permission-encoder comparison produces the same 17 instructions and 63 bytes. Scoped batching and live table hints remain useful for actual mutations, but preserving a shared hierarchy still requires per-page work on a switch. Independent roots add table ownership and invalidation complexity, so security and failure semantics precede performance. Root-layout sharing, bootstrap migration and CPU residency need explicit implementation evidence; no speedup or isolation claim follows from this proposal alone.

Tracking and rollout

Coordinate with target-memory ownership, native process switching, and runtime memory and threading. Integration owns matching images and profiling; Docs owns the technical manual. This remains part of Alpha 1 completion.

## Problem and motivation Native VSpace switches currently replay recorded mappings in the shared active page-table hierarchy. This makes each switch depend on the size of the participating address spaces, including during IPC. The executed-code investigation in [Integration #3](https://git.erikinkinen.fi/erix/integration/issues/3) identifies Kernel mapping batching and permission switching as leading code candidates. Those counts do not establish elapsed-time ownership or a speedup. Growing compiler heaps and threaded runtimes make this a relevant prerequisite for [runtime memory and threading](https://git.erikinkinen.fi/erix/kernel/issues/1) and complete native toolchain self-hosting. ## Proposed behavior and scope Give each native VSpace an owned hardware page-table root. Switching between already prepared address spaces must select the exact live root without replaying every recorded user mapping. Mapping creation, permission changes and revocation still update the authorized VSpace and complete required invalidation. Shared threads retain their existing VSpace identity; switching threads must preserve independent stack/TLS and process lifetime rules. Kernel owns root construction, activation, table-page ownership and retirement. Coordinate existing Memd, Vspaced, Pagerd, Procd and Rootd consumers only where their contracts need changes. Integration owns native isolation/failure scenarios, exact-source images and profiling; Docs owns the memory, lifecycle and testing manual contracts. Preserve the native capability ABI unless a separately specified change is necessary. This is not a POSIX identity-based authority mechanism. ## Authority, security and reliability - Existing caller-local MAP/MANAGE capabilities remain the sole external source of mapping authority. A root address, ID, cached translation or CPU register must not create or widen authority. Resolve live object identity and reject retiring/stale objects before activation or mutation. - Kernel owns page-table allocations for the exact VSpace lifetime. Ordinary snapshots must not retain an activation handle or duplicate cleanup ownership. Define shared supervisor mappings, recursive mappings and early bootstrap overlays explicitly; user entries must not mutate a shared supervisor subtree. - Preserve frame provenance, zero initialization, W^X, rights attenuation and generation checks. Pending mutations must not leave an unrecorded usable mapping. Source freshness and executable validation remain unchanged. - Define activation, mutation, revocation and retirement ordering for every resident CPU. Invalidation must cover global translations and any enabled context tags; root replacement alone is not a global-translation revocation proof. The architectural reference is the [Intel system programming manual](https://cdrdv2-public.intel.com/671190/253668-sdm-vol-3a.pdf), including translation caching and invalidation. - Faults or partial allocation leave exact cleanup custody. Never resume ordinary use after uncertain withdrawal. Retire roots and table pages only after no CPU can execute or walk them, preserving frame-release and final-process-binding ordering. Define lock/interrupt order and allocation-free cleanup progress. ## Acceptance criteria <details> <summary>Checklist</summary> - [ ] Document root/page/frame ownership, shared supervisor mappings, bootstrap handoff, lock order, CPU residency and retirement state transitions before hardware integration. - [ ] Implement owned roots and mapping/protection/unmapping for active and inactive VSpaces with existing authority, error-precedence and cleanup guarantees. - [ ] Add positive/negative controls for distinct contents at the same virtual address, shared-thread address spaces, read-only/NX denial, supervisor isolation, stale object reuse and inactive teardown while another space runs. - [ ] Inject construction, allocation, activation, revocation and final-release failures; prove no usable unowned root, residual mapping or leaked table/frame ownership. Preserve existing native lifetime, owned-invocation, mapping and pager regression coverage. - [ ] Validate concurrent CPU residency and acknowledged invalidation before claiming concurrent userspace execution. Accounting-only AP activity is not this evidence. Cover global entries, context-tag reuse if introduced, and delayed acknowledgements before reclamation. - [ ] Remove obsolete per-page switch replay and superseded APIs after equivalent native isolation/lifetime coverage passes. Do not retain an authority-bearing fallback or introduce new fixed mapping-count limits. - [ ] Use the maintained profiler to show switch work no longer scales with unchanged user mapping count, then demonstrate a measured improvement under the original uninstrumented startup/command acceptance rules. Retain failures and instrumentation overhead separately; no threshold or optimization-profile relaxation. - [ ] Pass formatting, strict Clippy, all required host/native matrices, missing-docs enforcement, source policy and warning-free test/image builds. Keep authored code files below 1,000 lines, update component/manual documentation, and monitor original CI. </details> ## Alternatives and tradeoffs Further bit-expression rewrites are insufficient evidence: the first isolated permission-encoder comparison produces the same 17 instructions and 63 bytes. Scoped batching and live table hints remain useful for actual mutations, but preserving a shared hierarchy still requires per-page work on a switch. Independent roots add table ownership and invalidation complexity, so security and failure semantics precede performance. Root-layout sharing, bootstrap migration and CPU residency need explicit implementation evidence; no speedup or isolation claim follows from this proposal alone. ## Tracking and rollout Coordinate with [target-memory ownership](https://git.erikinkinen.fi/erix/kernel/issues/121), [native process switching](https://git.erikinkinen.fi/erix/kernel/issues/123), and [runtime memory and threading](https://git.erikinkinen.fi/erix/kernel/issues/1). Integration owns matching images and profiling; Docs owns the technical manual. This remains part of [Alpha 1 completion](https://git.erikinkinen.fi/erix/integration/issues/65).
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:27 +01:00
Sign in to join this conversation.
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
erix/kernel#22
No description provided.