interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

GitHub aien-dev/aienux#357 (code only)

closed derived c2e347f87b95f8f7 #357

Imported from GitHub aien-dev/aienux#357 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 65466db96d54082d17bbdcda087a6a8795ab6f61 · Head 0e260289a79f0129267e8cc550e118231939f771

Apply it

git checkout -b patch-c2e347f87b95f8f7 65466db96d54082d17bbdcda087a6a8795ab6f61
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/c2e347f87b95f8f7.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
357
0e260289a79f0129267e8cc550e118231939f771
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":357,"url":"https://github.com/aien-dev/aienux/pull/357","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:16Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 509e815b..4ab2b7a7 100644
--- a/.crumb
+++ b/.crumb
@@ -27,33 +27,33 @@
           "purpose": "Directory crates. Purpose not yet described by a human."
         },
         {
-          "digest": "ff4b451c83c055a494d6598f83241ead8cc7bd43626e37cbadf4bf65ace5b74c",
-          "last_commit": "2cdd37f",
+          "digest": "b3206a74cb029a51277f86e5e41b11e87b1b0a8266e0eb3e4d6c9bde8599695a",
+          "last_commit": "dbcc813",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
         {
           "digest": "6760e8dde3217be76eca9feda31df7a6cc46c9d800e393f9bf9e6684a7745c2b",
-          "last_commit": "b46b6ba",
+          "last_commit": "65466db",
           "name": "native",
           "purpose": "Directory native. Purpose not yet described by a human."
         },
         {
           "digest": "7d0a21caf52696488c30c66204426d875d73cc672162cf9bcbe7eb34d6cc77b2",
-          "last_commit": "b46b6ba",
+          "last_commit": "65466db",
           "name": "scripts",
           "purpose": "Directory scripts. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:1d407e81725caba6588e1f632c1fa9155fef46948912716dc1ebc23faf10fd3a",
-      "compiled_at": "2026-10-13T13:46:16Z",
+      "children_root": "sha256:5fc62abdda4de084c4a1f3848c349dcbec7c4ca75adac1252dfd80171d200b00",
+      "compiled_at": "2026-10-13T14:14:52Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:908e1933bc353aad469fd5abfd9bc0ba32add6dc66e51edb55e5330582cb09a1",
+      "digest": "sha256:33f43bda17813bb2f44af036190fc03b22ee159e4d4791ae5b056cc9868aea36",
       "evidence_files": 156,
       "evidence_root": "sha256:cd53ab119be9de6ce28c4f5949b106c9622f1fe105611de3de21c3bce7932694",
-      "files": 3148,
-      "generated_at_commit": "b46b6ba4c5f031ff1d0d8cf3ea31b5093fbd2f4f",
-      "source_tree": "sha256:646df3d08f465dcca436bbc45d527fabe6b66c08629d52b7e2f851d896bc22a8"
+      "files": 3149,
+      "generated_at_commit": "dbcc8133ea836912906f685ebe3198e844ee3efd",
+      "source_tree": "sha256:4ecbdcfbb65655d93c2df4db45a588813f8777fc0f42009099a2b74006e3f0a9"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/docs/.crumb b/docs/.crumb
index 4ca41f86..40f776a1 100644
--- a/docs/.crumb
+++ b/docs/.crumb
@@ -17,8 +17,8 @@
     "generated": {
       "children": [
         {
-          "digest": "a845beb92a810b2349a8fc52048276ca6949076e4343912bbb9b70859036bf8f",
-          "last_commit": "22eb360",
+          "digest": "e924f0b65fb4e4c81984c39226ae714352e9b36610353df4ad9dd13106e3ba86",
+          "last_commit": "dbcc813",
           "name": "adr",
           "purpose": "Directory docs/adr. Purpose not yet described by a human."
         },
@@ -29,15 +29,15 @@
           "purpose": "Directory docs/crumbs. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:baea130f2c52779b57d90139beb66ac01b21ab499d113471a334be5500f3e369",
-      "compiled_at": "2026-10-12T20:56:51Z",
+      "children_root": "sha256:c5d7ca9ce0145309c90a439711adcb6dd8e8e40ff48b90455f545e63c05f04c8",
+      "compiled_at": "2026-10-13T14:14:52Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:ff4b451c83c055a494d6598f83241ead8cc7bd43626e37cbadf4bf65ace5b74c",
+      "digest": "sha256:b3206a74cb029a51277f86e5e41b11e87b1b0a8266e0eb3e4d6c9bde8599695a",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 74,
-      "generated_at_commit": "04e39e7223149deef6c14e4175d40e80c63eee0a",
-      "source_tree": "sha256:87b7ec7512cc0767c9b71c8c869251782ac516418bba44b9efb93c764d3cb912"
+      "files": 75,
+      "generated_at_commit": "dbcc8133ea836912906f685ebe3198e844ee3efd",
+      "source_tree": "sha256:173e1dfdebc4df6807d26f728282d5df77c8da1be381b2c2296e4024bc17cb94"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/docs/adr/.crumb b/docs/adr/.crumb
index 953f8e46..7e32f69a 100644
--- a/docs/adr/.crumb
+++ b/docs/adr/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-12T10:28:17Z",
+      "compiled_at": "2026-10-13T14:14:52Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:a845beb92a810b2349a8fc52048276ca6949076e4343912bbb9b70859036bf8f",
+      "digest": "sha256:e924f0b65fb4e4c81984c39226ae714352e9b36610353df4ad9dd13106e3ba86",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 22,
-      "generated_at_commit": "56d125f12abf2b8ba2886d6da4d86fda8dd244b3",
-      "source_tree": "sha256:a545e3c9b4b62eeda5f39afcb71b7cdecf2da41e11413598afe8cdd0787de90f"
+      "files": 23,
+      "generated_at_commit": "dbcc8133ea836912906f685ebe3198e844ee3efd",
+      "source_tree": "sha256:fec3e141adbfedffd581ee5ba8e9c3e14f58baa2685fa1ec1e42651acecbf236"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/docs/adr/0020-pi5-software-only-dma-confinement.md b/docs/adr/0020-pi5-software-only-dma-confinement.md
new file mode 100644
index 00000000..0723db6c
--- /dev/null
+++ b/docs/adr/0020-pi5-software-only-dma-confinement.md
@@ -0,0 +1,84 @@
+# ADR 0020: Pi 5 software-only DMA confinement (an explicit, Pi-only exception to ADR 0012 rule 5)
+
+Status: Accepted (operator, decision D3, 2026-10-13). Applies to the Raspberry Pi 5 only. It does NOT apply to the Spark.
+Date: 2026-10-13
+Amends: [ADR 0012](0012-self-construction-capability-growth-and-generations.md) rule 5 ("No native admission without enforcement"), for the Pi 5 network path only. Also names two doctrine passages in aien-architecture that this exception departs from: `doctrine/TRUST.md` section 5.1 item 2 (SMMUv3 DMA sandboxing) and `doctrine/ARCHITECTURE.md` "DMA & Bus Confinement" (SMMUv3 / PCIe IOMMU confinement). Those passages stay true for the Spark; a matching note is owed in aien-architecture (not done by this ADR).
+Governing: ADR 0012 rule 5; `native/kernel/core/smmu.c` (the Spark's enforcement, SMMU stream windows).
+
+Label used everywhere (boot banner, this ADR, gate names): **software-only DMA confinement (Pi 5, weaker than the Spark)**.
+
+## Context
+
+ADR 0012 rule 5 says native components run on the physical machine only after enforceable memory, DMA (SMMU) and capability isolation exist. On the Spark that is met by SMMU stream windows. The Pi 5 has no such unit in front of its network card.
+
+Facts about the Pi 5 network path (read, not run; sources are the Linux tree `raspberrypi/linux` branch `rpi-6.12.y` and the RP1 datasheet, not this repository, and were read in the research that preceded this ADR, to be re-verified by whoever builds the driver):
+
+1. The Ethernet MAC is a Cadence GEM_GXL block inside the RP1 south bridge, reached from the BCM2712 over PCIe (RP1 peripherals datasheet RP-008370-DS-1, chapter 7: packet buffer DMA, AXI4 bus master). Linux drives it with descriptor rings only (`drivers/net/ethernet/cadence/macb_main.c`, `raspberrypi_rp1_config` near line 5192; 44-bit DMA mask near line 5369). There is no programmed-I/O or FIFO mode to use instead. So once the NIC is on, a device on the bus reads and writes RAM at addresses that software puts in descriptors, and whatever the device itself decides.
+2. A partial hardware backstop exists: the BCM2712 PCIe root complex has inbound windows (`drivers/pci/controller/pcie-brcmstb.c`: `brcm_pcie_get_inbound_wins` near line 1173, `set_inbound_win_registers` near line 1327, access enable near line 1359). A window is a power-of-two size from 4 KiB to 64 GiB, aligned to its size, up to 10 windows. Linux's `bcm2712.dtsi` pcie2 `dma-ranges` (near lines 556 to 562) maps 64 GiB, which is all of RAM, so Linux uses it as no confinement at all. The window belongs to the whole controller: the GEM, RP1's own DMA engines and USB share it, and there is no read/write split. Whether MSI writes from RP1 pass through the same window is UNVERIFIED.
+3. This repository has no Pi 5 network driver yet. This ADR is written before the driver so the driver is built to the rule, not the rule fitted to the driver.
+
+The decision to accept a software-only rule was taken by the operator as D3 on 2026-10-13, knowing that it is weaker than the Spark.
+
+## Decision drivers
+
+1. Be honest: a rule that software enforces cannot stop a device that ignores descriptors. State what is and is not covered.
+2. Make the worst case small: if the NIC misbehaves, it should only be able to reach one small block that holds nothing of value.
+3. Fail closed: any violation stops the NIC, it does not log and continue.
+4. Keep the Spark untouched and its stronger rule intact.
+
+## Options
+
+### Option 1: No Pi networking (keep ADR 0012 rule 5 as written)
+
+- Upside: no exception, no weaker path.
+- Downside: the Pi stays offline; the house-server and Store-over-network work on the Pi cannot proceed.
+- Picking it: nothing changes; the Pi 5 lane stops at local-only features. Reversible at any time.
+
+### Option 2: Software-only confinement plus the root-complex window as a backstop (chosen)
+
+- What it is: the rules in the Decision below.
+- Upside: bounded, testable on a host, labelled; the hardware window removes the "any address in RAM" case when it works.
+- Downside: a NIC that ignores descriptors is stopped only by the root-complex window, which is shared, coarse, and not yet proven to cover every path (MSI UNVERIFIED). Software checks cannot see what the device actually does.
+- Picking it: Pi networking can be built. It is an exception to rule 5 that is written down, scoped to the Pi, and revisited (see Consequences).
+
+### Option 3: Wait for a real IOMMU in front of the NIC
+
+- Upside: would meet rule 5 fully.
+- Downside: this ADR does not know of one on the Pi 5. UNVERIFIED whether any exists on RP1 or BCM2712 for this path; no date.
+- Picking it: same as Option 1 in practice.
+
+## Decision
+
+Option 2. The following rules bind every Pi 5 network driver.
+
+1. **One bounce window.** A single contiguous, power-of-two sized, size-aligned block of at most 2 MiB, allocated zeroed at boot, used for nothing else. It holds the descriptor rings and the packet buffers. No other memory is ever device-visible.
+2. **One writer.** Only the kernel GEM driver writes descriptors. No agent, task or other kernel code gets a path to the rings.
+3. **Every descriptor checked.** Each descriptor address and length must lie fully inside the window. The check is overflow-safe (it must not compute `addr + len` in a way that can wrap). A zero length is refused. A violation refuses the descriptor, halts the NIC and latches: the NIC stays off until reboot.
+4. **Shadow, not trust.** The driver keeps its own record of each descriptor it issued. The device can write the ring (it writes status words back), so ring contents are never read back as addresses; a descriptor is re-issued only from the driver's record, and a reused (stale) slot is rewritten in full.
+5. **Copy only.** Packets are copied into and out of the window. No kernel or agent pointer ever reaches the device.
+6. **Hardware backstop where possible.** Program the BCM2712 PCIe root-complex inbound window to exactly the bounce block (one window, size and base equal to the block). Limits, stated plainly: it is controller-wide (RP1 DMA and USB share it), it has no read/write split, it only confines what the root complex sees, and the MSI path is UNVERIFIED. If it cannot be programmed, the boot banner says so and the driver does not claim a backstop.
+7. **Refused outright:** scatter-gather (one descriptor per frame), jumbo frames (frame length capped at the standard Ethernet maximum), device-supplied addresses, and DMA from any other RP1 function (only the GEM is enabled for bus mastering).
+8. **Label.** The boot banner prints `software-only DMA confinement (Pi 5, weaker than the Spark)`, and every gate that exercises this path carries `SWDMA` in its name.
+
+### Scope of the exception
+
+This is an explicit exception to ADR 0012 rule 5 for the Raspberry Pi 5 only. It does NOT apply to the Spark, whose DMA stays fenced by SMMU stream windows (`native/kernel/core/smmu.c`). No code from this ADR is built into the Spark or QEMU images. It does not allow native admission of generated components on the Pi; it covers the NIC's DMA only.
+
+## Consequences
+
+- A Pi 5 with networking is weaker than the Spark: a bug in this driver or a misbehaving RP1 can still reach the whole bounce block, and, if the root-complex window is not effective, possibly more. Nothing secret is ever placed in the window.
+- The exception should be revisited if a hardware fence in front of the GEM is found.
+- A later cut adds the real driver, the root-complex window programming and the boot banner; this ADR and the validator (`native/kernel/dev/dma_window.c`) come first.
+
+## Tests (required before any Pi NIC path is enabled)
+
+1. Host tests with mutants for the validator: address below the window, address plus length past the end, a length that makes `addr + len` wrap, zero length, a stale descriptor slot reused, misaligned buffers, a second violation after a latch.
+2. Mutation proof: removing each check makes the host test fail.
+3. Descriptor-ring helpers can only emit in-window addresses (property test over arbitrary inputs, including hostile ones).
+4. Gate checks that the boot banner carries the label and that the default (Spark/QEMU) image contains none of the Pi DMA code.
+5. On the Pi (later, by the operator's runner): NIC halts on an injected out-of-window descriptor; root-complex window readback equals the bounce block; MSI behaviour measured, not assumed.
+
+## Evidence and limits
+
+- Facts in Context were read from the Linux `rpi-6.12.y` tree, the RP1 datasheet and ADR 0012 / aien-architecture doctrine text; line numbers are approximate and no Pi hardware was touched by this ADR.
+- Nothing here has been run on a Pi. The MSI path and the existence of any other fence are UNVERIFIED.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index b9d8b25b..5d5564ae 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -24,6 +24,7 @@ This directory documents the key architectural decisions and formal technical sp
 | [ADR 0016](0016-continuity-objects-over-store-v1.md) | Continuity objects over System Store v1 | Proposed (format freeze needs operator approval) | 2026-09-25 | [ADR 0007](0007-continuous-existence-provisioning-once.md), [ADR 0015](0015-system-store-v1-format.md); M4 continuity |
 | [ADR 0018](0018-allen-subject-state-object.md) | ALLEN Subject State Object (continuity kind 24) | Proposed (companion to ARCH-0035; format freeze needs operator approval) | 2026-10-04 | [ADR 0016](0016-continuity-objects-over-store-v1.md); omega ARCH-0022 Cortex; R16 |
 | [ADR 0019](0019-per-resource-capability-generation.md) | Per-resource capability generation (OSC unit `required_generation`, domain 1) | Accepted (Option 3; counter tracked in aienos#285) | 2026-10-08 | [ADR 0013](0013-aienos-abi-v1.md); [ADR 0014](0014-binary-artifact-v0-and-native-admission.md) amendment point 5; aien-protocols `specs/osc-unit-artifact` section 15.3 C1 |
+| [ADR 0020](0020-pi5-software-only-dma-confinement.md) | Pi 5 software-only DMA confinement (Pi-only exception to ADR 0012 rule 5) | Accepted (operator D3, 2026-10-13) | 2026-10-13 | [ADR 0012](0012-self-construction-capability-growth-and-generations.md) rule 5; `native/kernel/core/smmu.c` (Spark) |
 
 ---