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#270 (code only)

closed derived 39332a6fdc200524 #270

Imported from GitHub aien-dev/aienux#270 (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 2dffd97622379102501da6b0bfca0ee7b0bb8e92 · Head 224f8a251829c9a6f6bb049cfb8079e7b5a0eb08

Apply it

git checkout -b patch-39332a6fdc200524 2dffd97622379102501da6b0bfca0ee7b0bb8e92
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/39332a6fdc200524.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
270
224f8a251829c9a6f6bb049cfb8079e7b5a0eb08
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":270,"url":"https://github.com/aien-dev/aienux/pull/270","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:06Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 35a52d27..d686c65e 100644
--- a/.crumb
+++ b/.crumb
@@ -33,8 +33,8 @@
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
         {
-          "digest": "0d589e6ce680103a666855196f3b224a609fa6f6ba877f92e064c520638f78da",
-          "last_commit": "056b8e7",
+          "digest": "824c5b5926f18ffae7c3f46491ce3bd78758f79ca9fdcb4f6c59b1fadff785f2",
+          "last_commit": "9e69692",
           "name": "native",
           "purpose": "Directory native. Purpose not yet described by a human."
         },
@@ -45,15 +45,15 @@
           "purpose": "Directory scripts. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:fc380cd618b011df8e0ea6b77ad228ff053380c7b1b14f33db1c16ee347c3b89",
-      "compiled_at": "2026-10-06T11:23:44Z",
+      "children_root": "sha256:acdb2f8786b6d63a8e9ac868ed7cfbb6300a4604aa3a722ffccba0261a759339",
+      "compiled_at": "2026-10-06T11:55:32Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:13c1f0db8513f5740a3fa9a47203d8eadc6ff51a04ef77d72cc3b79f65ff8139",
-      "evidence_files": 151,
-      "evidence_root": "sha256:95ba4c8c2656f248386efb82a1b27a6c6054820636ab863080f44aa343ed7fb4",
-      "files": 2873,
-      "generated_at_commit": "056b8e7c700fcafb2a942a17af8a4c61a4f6e961",
-      "source_tree": "sha256:538e659d81885c116ac27c6b86ba1ed4a6b801b475bfd2224c3a478f27e6b730"
+      "digest": "sha256:e5dbf729258b2676a12ae09de0823c3bc6e777941820efa7213004ab9d7dfac4",
+      "evidence_files": 152,
+      "evidence_root": "sha256:a74ab9a4f344734b1737c5c8f029eeec57f10340cf251cf0484903f158c3f418",
+      "files": 2874,
+      "generated_at_commit": "788425caf3125f809254efb433fd5bc036eb6a59",
+      "source_tree": "sha256:0e32a7f299bc4df9090755493ef97ec0a5189fc6879217032e5c16012f95ba6f"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/evidence/ck_gates_cb1404163d23657165e31bc566fb4c4829a9e1ee7a5d5dc4685454b0c2685948.json b/evidence/ck_gates_cb1404163d23657165e31bc566fb4c4829a9e1ee7a5d5dc4685454b0c2685948.json
new file mode 100644
index 00000000..aec57e20
--- /dev/null
+++ b/evidence/ck_gates_cb1404163d23657165e31bc566fb4c4829a9e1ee7a5d5dc4685454b0c2685948.json
@@ -0,0 +1,58 @@
+{
+  "schema": "aienos.ck_gates.v1",
+  "started_utc": "2026-10-06T04:30:16Z",
+  "finished_utc": "2026-10-06T05:08:48Z",
+  "commit": "9d361c013f8ad5d06478cb6027c2cd6634e42ce9",
+  "commit_subject": "ck kernel: two-level SMMU stream table, lazily allocated L2 spans (NEXT-PHASE-3 cut 3b, QEMU/HOST)",
+  "tree_clean_before": true,
+  "tree_clean_after": true,
+  "quiet_flag": "/home/drakestapleton/.claude/jobs/9bfe8553/tmp/locks/quiet-c3bafter",
+  "quiet_flag_present_at_start": false,
+  "host": {"hostname": "spark-b87b", "arch": "aarch64", "kernel": "7.0.0-1019-nvidia", "cpu_model": "Cortex-A725;Cortex-X925"},
+  "qemu": {"binary": "/usr/bin/qemu-system-aarch64", "version": "QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18)"},
+  "firmware": {"aavmf_code": "/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd", "aavmf_code_sha256": "4a4cb7f6d8106bb2a7dd8c763fab14b1810152136fc4304e5b728f0043e84f12", "aavmf_vars": "/usr/share/AAVMF/AAVMF_VARS.fd", "aavmf_vars_sha256": "b3b855c5a80310168051164986855692d1bdb06e67619856177965cd87c6774f"},
+  "nvme_dma_mode": "Confined (QEMU SMMUv3 stage 1, out-of-window DMA faulted); no-SMMU boot denied (NoSmmu); TEST-ONLY bypass image checked separately",
+  "children": [
+    {"name": "boot", "script": "scripts/qemu_ck_boot_test.sh", "present": true, "script_sha256": "d17a7e0f00081e935a804c092c9b05c0bd1f319f5dd5c8bd90f3982e8939c3c8", "exit": "0", "seconds": 6, "log_sha256": "e205a738cf54fe0fa27ada865fd0ebe96eada2470ff50538d4309f3dd1205e75", "log_lines": 24},
+    {"name": "store", "script": "scripts/qemu_ck_store_test.sh", "present": true, "script_sha256": "0b31a44af9388302d5488fdef318a509c4f26c2420f82ceb2fa7f7b698647748", "exit": "0", "seconds": 92, "log_sha256": "7e75ac32dc15e76eec782c1230d798fbb7ed3bded8f2525931efd339e645a05f", "log_lines": 612},
+    {"name": "net", "script": "scripts/qemu_ck_net_test.sh", "present": true, "script_sha256": "ea051cc946c206f92c0c1563b3463b6bebffbce04e361e76d51dd49c1be4a6cf", "exit": "0", "seconds": 18, "log_sha256": "63397cd5f9fa36ef88bde8ae0b8e501767442d8747cd56c6122aaf6d403d4379", "log_lines": 95},
+    {"name": "artifact", "script": "scripts/qemu_ck_artifact_test.sh", "present": true, "script_sha256": "e60f6c4aed822f693a530cb98b2fa4689b7b56e7c0efed5f9bf9ff4e9f75fc67", "exit": "0", "seconds": 33, "log_sha256": "e326b030ec0ebe559901d8514a9d4e708ec7e4c0e2937b14ab4db8a0eb8d7e7b", "log_lines": 215},
+    {"name": "smp", "script": "scripts/qemu_ck_smp_test.sh", "present": true, "script_sha256": "b5665568394f391c17aaa9148bce2358f1145240cc38422c2927664b0ffd41d6", "exit": "0", "seconds": 5, "log_sha256": "ac60e880d03e793c23652fd1b6bcc0e6bdfb9b56daf1c17287db07197ece4171", "log_lines": 16},
+    {"name": "crash", "script": "scripts/qemu_ck_store_crash_test.sh", "present": true, "script_sha256": "3d04ca0775db7e70a244b6a09b19c5adf987f777b6ff630874c42e339add7765", "exit": "0", "seconds": 677, "log_sha256": "4059e2ca3fc2df078693ca717505424da031e32d9b8da1a159ced4e993dc12c6", "log_lines": 239},
+    {"name": "disk", "script": "scripts/qemu_ck_disk_layout_test.sh", "present": true, "script_sha256": "f490548245252b97518e9049ce8e7078f5297c81584b60f08f802cfea6bb3110", "exit": "0", "seconds": 57, "log_sha256": "51793d4325b35bf3a1ec020d43ce97dd7f8537c705327e3439f30408bcf9bc12", "log_lines": 264},
+    {"name": "cont", "script": "scripts/qemu_ck_continuity_test.sh", "present": true, "script_sha256": "30a8eb2dbb949eab29ad046231869a306199908022cb2345151988ea4957cf2e", "exit": "0", "seconds": 185, "log_sha256": "d83efb16942955603a4654da059f82d095587a6358f17b97f5477d1fb49d9c04", "log_lines": 57},
+    {"name": "recov", "script": "scripts/qemu_ck_recovery_test.sh", "present": true, "script_sha256": "89c461e211532f6577d2c88668ae8ca0d32d91f3b29ce6e39f7082a03a45b8cc", "exit": "0", "seconds": 115, "log_sha256": "500cd02050eae8f2f4aa34fdb004ff4d5399751de25de9dfe554ed5cdca32e30", "log_lines": 46},
+    {"name": "allen", "script": "scripts/qemu_ck_allen_test.sh", "present": true, "script_sha256": "0fe58465d5183781b8339f50861fd76f7773051bee939b73fdaede4b7a752355", "exit": "0", "seconds": 202, "log_sha256": "62d63bab7bd3c816f93b0f1efb20091148bd9ec69c984641f93ef6501e5df284", "log_lines": 73},
+    {"name": "kbd", "script": "scripts/qemu_ck_keyboard_test.sh", "present": true, "script_sha256": "c1ac74a30f722379d05326a0f98fa2287529ccd5a8036d79cb062479995672b1", "exit": "0", "seconds": 41, "log_sha256": "705cb703f504640edf2d5837088c4a58ff025369e2a8bd0b5fd59e1bf440e901", "log_lines": 154},
+    {"name": "fpu", "script": "scripts/qemu_ck_fpu_test.sh", "present": true, "script_sha256": "f04fa538752f6864bc2d5f9ff5af6eac71a5e3a005fe9c76b77477012325cc14", "exit": "0", "seconds": 8, "log_sha256": "c341810e5a2d12cd7519d2b9d6fe6d2176e47a63391458b33dc80b7d1c309ed9", "log_lines": 13},
+    {"name": "infer", "script": "scripts/qemu_ck_infer_test.sh", "present": true, "script_sha256": "185c78b8688004dc6a807182c81e319b1598414935934b6c881cfafae5ce31fa", "exit": "0", "seconds": 858, "log_sha256": "359372a7945e99d3f3c42a8326968578ca9e3aa8920fc143b98968862c627ed6", "log_lines": 35},
+    {"name": "screen", "script": "scripts/qemu_ck_screen_test.sh", "present": true, "script_sha256": "b2b71aff7fb9274eb15d8381e44dda9d7b700821fd45a23cde1c9a1132dc6b3f", "exit": "0", "seconds": 15, "log_sha256": "24e43eff37e28db15e4040336d2485aa3a2bdbbad4ee4d9e0b5a59db7536c9a9", "log_lines": 30}
+  ],
+  "gates": [
+    {"id": "M1", "marker": "AIENOS_CK_M1", "source": "boot", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "M3", "marker": "AIENOS_CK_M3", "source": "boot", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "SMMU", "marker": "AIENOS_CK_SMMU", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "NVME_SHUTDOWN", "marker": "AIENOS_CK_NVME_SHUTDOWN", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "P2_ARTIFACT", "marker": "AIENOS_CK_P2_ARTIFACT", "source": "artifact", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "M0_ROLLBACK", "marker": "AIENOS_CK_M0_ROLLBACK", "source": "missing", "verdict": "NOT_RUN", "reason": "MISSING_IMPLEMENTATION: C loader signatures, A/B, BootNext and rollback are parked (native/boot/README.md)"},
+    {"id": "M4_NVME", "marker": "AIENOS_CK_M4_NVME", "source": "store", "verdict": "PASS", "reason": "SMMU-confined NVMe DMA in QEMU (iommu=smmuv3, default build); TEST-ONLY bypass build boot-checked separately"},
+    {"id": "M4_STORE", "marker": "AIENOS_CK_M4_STORE", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "M4_STORE_CRASH", "marker": "AIENOS_CK_M4_STORE_CRASH", "source": "crash", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "M4_CONTINUITY", "marker": "AIENOS_CK_M4_CONTINUITY", "source": "cont", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "M4_RECOVERY", "marker": "AIENOS_CK_M4_RECOVERY", "source": "recov", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "M4_ALLEN", "marker": "AIENOS_CK_M4_ALLEN", "source": "allen", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "ARGUS1_REVOKE", "marker": "AIENOS_CK_ARGUS1_REVOKE", "source": "store", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "KEYBOARD", "marker": "AIENOS_CK_KEYBOARD", "source": "kbd", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "NET", "marker": "AIENOS_CK_NET", "source": "net", "verdict": "PASS", "reason": "QEMU user networking (slirp), virtio-net with ACCESS_PLATFORM required behind the smmuv3 vIOMMU; this PASS covers: attach, UDP TX seen by the host helper, UDP reply RX parsed by M6-A, an out-of-window device DMA refused (F_TRANSLATION, page intact) and recovery by reset, as checked by this run only; QEMU, not hardware"},
+    {"id": "SMP", "marker": "AIENOS_CK_SMP", "source": "smp", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "DISK_LAYOUT", "marker": "AIENOS_CK_DISK_LAYOUT", "source": "disk", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "FPU", "marker": "AIENOS_CK_FPU", "source": "fpu", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "INFER", "marker": "AIENOS_CK_INFER", "source": "infer", "verdict": "PASS", "reason": "child reported PASS, exit 0"},
+    {"id": "SCREEN", "marker": "AIENOS_CK_SCREEN", "source": "screen", "verdict": "PASS", "reason": "child reported PASS, exit 0"}
+  ],
+  "counts": {"total": 20, "pass": 19, "fail": 0, "not_run": 1},
+  "verdict": "NOT_ALL_GATES_PASS",
+  "parity": "native/kernel/GATES.md",
+  "physical": "NOT_RUN",
+  "physical_statement": "QEMU emulator runs only. Nothing here was run on Machine 1 or any GB10; no physical qualification is claimed."
+}
diff --git a/native/.crumb b/native/.crumb
index b4fa58b5..a84faafc 100644
--- a/native/.crumb
+++ b/native/.crumb
@@ -79,8 +79,8 @@
           "purpose": "Directory native/disk. Purpose not yet described by a human."
         },
         {
-          "digest": "2994b89eaffa92f36c9335d87b6142ada4d5d521b4402f4fbde8681be6dbdf4e",
-          "last_commit": "056b8e7",
+          "digest": "772d89376f67bf1c8378f072b802ea2395d608ed6482b132cfc5a56fae6e1bd3",
+          "last_commit": "9e69692",
           "name": "kernel",
           "purpose": "Directory native/kernel. Purpose not yet described by a human."
         },
@@ -109,15 +109,15 @@
           "purpose": "Directory native/store. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:1d92cdd999186575a12435aa6f20cc06cf4fe3afef65765bab90148c42e7ddf6",
-      "compiled_at": "2026-10-06T11:23:44Z",
+      "children_root": "sha256:a0c34acd926a971c12de81fab70875c0e721f00b968e7f3b196fab8f1f68e1e0",
+      "compiled_at": "2026-10-06T11:55:32Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:0d589e6ce680103a666855196f3b224a609fa6f6ba877f92e064c520638f78da",
+      "digest": "sha256:824c5b5926f18ffae7c3f46491ce3bd78758f79ca9fdcb4f6c59b1fadff785f2",
       "evidence_files": 4,
       "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335",
       "files": 317,
-      "generated_at_commit": "056b8e7c700fcafb2a942a17af8a4c61a4f6e961",
-      "source_tree": "sha256:b4e7058f03d3fc95ce4a6af45166b2e046431245b82e56bc4cdd7da2c019b1cd"
+      "generated_at_commit": "788425caf3125f809254efb433fd5bc036eb6a59",
+      "source_tree": "sha256:e8dd1e9d9f55a9600622d0d149fe5783ef50136f3ea322d471fd9cf2b6e5bf83"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/.crumb b/native/kernel/.crumb
index 4623d629..e8ee4ee1 100644
--- a/native/kernel/.crumb
+++ b/native/kernel/.crumb
@@ -57,20 +57,20 @@
           "purpose": "Directory native/kernel/artifact. Purpose not yet described by a human."
         },
         {
-          "digest": "04cdf688c8b8db1c849f62a67d26f5e3d6755cd9e7abceda02ca57ae46ac2475",
-          "last_commit": "056b8e7",
+          "digest": "c820e3275ce15dabd61691a8371c3fdc3a6f43b594af398fcab62ff89e0c0578",
+          "last_commit": "9e69692",
           "name": "core",
           "purpose": "Directory native/kernel/core. Purpose not yet described by a human."
         },
         {
           "digest": "a258da86889a2c724e401240270737100b650ab9f35e53b763ea0737b2a0a204",
-          "last_commit": "056b8e7",
+          "last_commit": "2dffd97",
           "name": "dev",
           "purpose": "Directory native/kernel/dev. Purpose not yet described by a human."
         },
         {
           "digest": "b6d9b7f41a384aadce48d58fe49e4e35cff1909579d5478b4a03a6f4ca7a9c59",
-          "last_commit": "056b8e7",
+          "last_commit": "2dffd97",
           "name": "include",
           "purpose": "Directory native/kernel/include. Purpose not yet described by a human."
         },
@@ -82,13 +82,13 @@
         },
         {
           "digest": "5f3563ae990ea4c130d7f24cb057effd855202f96c89d51d7542e68eba2dbc79",
-          "last_commit": "056b8e7",
+          "last_commit": "2dffd97",
           "name": "svc",
           "purpose": "Directory native/kernel/svc. Purpose not yet described by a human."
         },
         {
-          "digest": "8d9dd989b592bcdc509febaa9ea580f0301eb231910485a716663509733fac92",
-          "last_commit": "056b8e7",
+          "digest": "0fd32ca401eef461e59a9ac01b7879ce928c8057e8c2843d934772af8933e1c7",
+          "last_commit": "9e69692",
           "name": "tests",
           "purpose": "Directory native/kernel/tests. Purpose not yet described by a human."
         },
@@ -99,15 +99,15 @@
           "purpose": "Directory native/kernel/tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:86b35cb18692becd5ac2ad8ecb09f8a56cfba3823631cfff65ef01c3d756e65e",
-      "compiled_at": "2026-10-06T11:23:44Z",
+      "children_root": "sha256:c568be64e6c0a0c52764e6443c0da5eadfdee750b4c31161886f5c13b702776c",
+      "compiled_at": "2026-10-06T11:55:32Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:2994b89eaffa92f36c9335d87b6142ada4d5d521b4402f4fbde8681be6dbdf4e",
+      "digest": "sha256:772d89376f67bf1c8378f072b802ea2395d608ed6482b132cfc5a56fae6e1bd3",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 153,
-      "generated_at_commit": "056b8e7c700fcafb2a942a17af8a4c61a4f6e961",
-      "source_tree": "sha256:d7854182898461dfe15573395274f1fde838d55e624d97b101d97ca399f1dc1f"
+      "generated_at_commit": "788425caf3125f809254efb433fd5bc036eb6a59",
+      "source_tree": "sha256:fe195fc19a8d83b84479281bda9eb7363f0bfce54630bc8910a2d81edf620666"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md
index 10ccdd10..20df2ddf 100644
--- a/native/kernel/GATES.md
+++ b/native/kernel/GATES.md
@@ -105,7 +105,8 @@ stream instead (boots 1-4 of `scripts/qemu_ck_store_test.sh`, default
 `make full` image, QEMU `iommu=smmuv3`, both geometries). Every row below
 therefore DIFFERS in the device named; the property checked is the same.
 The C SMMU service is `core/smmu.c` (port of `crates/aienos-kernel/src/smmu.rs`:
-linear stream table, stage 1 only, global abort set first and never cleared,
+linear stream table, plus a C-only two-level stream table when the SMMU
+supports it (see README), stage 1 only, global abort set first and never cleared,
 every stream in abort until installed) plus `core/smmu_svc.c` (IORT lookup,
 per-stream page tables, `ck_dma_confine` / `ck_dma_unconfine` /
 `ck_dma_faults` in ck.h); host tests in `tests/test_smmu.c`. The IORT
diff --git a/native/kernel/Makefile b/native/kernel/Makefile
index 3a306a41..f9b186d8 100644
--- a/native/kernel/Makefile
+++ b/native/kernel/Makefile
@@ -716,8 +716,32 @@ iort-mutants: $(OUT)/host/test_smmu
 	else echo "mutant flag refused under CK_HARDWARE_STAGING"; fi; \
 	if [ $$fail = 0 ]; then echo "CK_IORT_MUTANTS: PASS"; else echo "CK_IORT_MUTANTS: FAIL"; exit 1; fi
 
-test: $(addprefix $(OUT)/host/,$(TESTS)) handoff-mutant acpi-dev-mutant iort-mutants test-continuity-subject-restart
-	@fail=0; for t in $(filter-out handoff-mutant acpi-dev-mutant iort-mutants test-continuity-subject-restart,$^); do $$t || fail=1; done; \
+# TEST-ONLY mutants of the two-level stream table in core/smmu.c: test_smmu
+# must FAIL against each (SPAN_OVERFLOW: L1STD Span past SPLIT + 1;
+# UNGRANTED_VALID: L1STDs valid before any grant; BAD_L1_PTR: misaligned L1
+# table accepted; L2_NO_FILL: a new L2 page published without abort STEs).
+# Host only (smmu.c refuses them freestanding and with CK_HARDWARE_STAGING).
+SMMU_L2_MUTANTS := CK_SMMU_MUTANT_SPAN_OVERFLOW CK_SMMU_MUTANT_UNGRANTED_VALID CK_SMMU_MUTANT_BAD_L1_PTR CK_SMMU_MUTANT_L2_NO_FILL
+smmu-l2-mutants: $(OUT)/host/test_smmu
+	@mkdir -p $(OUT)/host-mut; fail=0; \
+	$(OUT)/host/test_smmu > $(OUT)/host-mut/smmu-l2-base.log 2>&1 || { echo "unmutated test_smmu fails"; fail=1; }; \
+	for m in $(SMMU_L2_MUTANTS); do \
+	  b=$(OUT)/host-mut/test_smmu_$$m; \
+	  if ! $(HOSTCC) $(HCFLAGS) -D$$m -o $$b $(KDIR)/tests/test_smmu.c $(HOST_SRCS); then \
+	    echo "mutant $$m: does not build (FAIL)"; fail=1; continue; fi; \
+	  if $$b > $$b.log 2>&1; then echo "mutant $$m: SURVIVED (FAIL)"; fail=1; \
+	  elif grep -q "^test_smmu: FAIL" $$b.log; then \
+	    echo "mutant $$m: killed ($$(grep -c '^  FAIL ' $$b.log) checks failed)"; \
+	  else echo "mutant $$m: no FAIL verdict (crashed?) (FAIL)"; fail=1; fi; \
+	done; \
+	if $(HOSTCC) $(HCFLAGS) -DCK_HARDWARE_STAGING=1 -DCK_SMMU_MUTANT_SPAN_OVERFLOW \
+	    -fsyntax-only $(KDIR)/core/smmu.c 2>/dev/null; then \
+	  echo "mutant flag accepted under CK_HARDWARE_STAGING (FAIL)"; fail=1; \
+	else echo "mutant flag refused under CK_HARDWARE_STAGING"; fi; \
+	if [ $$fail = 0 ]; then echo "CK_SMMU_L2_MUTANTS: PASS"; else echo "CK_SMMU_L2_MUTANTS: FAIL"; exit 1; fi
+
+test: $(addprefix $(OUT)/host/,$(TESTS)) handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants test-continuity-subject-restart
+	@fail=0; for t in $(filter-out handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants test-continuity-subject-restart,$^); do $$t || fail=1; done; \
 	if [ $$fail = 0 ]; then echo "CK_CORE_HOST: PASS"; else echo "CK_CORE_HOST: FAIL"; exit 1; fi
 
 sanitize: $(addprefix $(OUT)/host-san/,$(TESTS))
@@ -1098,4 +1122,4 @@ clean:
 	rm -rf $(OUT)
 
 FORCE:
-.PHONY: all full test sanitize handoff-mutant acpi-dev-mutant iort-mutants acpi-scan clean print-kcflags udp-echo tool store-image gpt-image cont-tool owner-gen fb-check continuity-mutants continuity-resolve-mutants FORCE
+.PHONY: all full test sanitize handoff-mutant acpi-dev-mutant iort-mutants smmu-l2-mutants acpi-scan clean print-kcflags udp-echo tool store-image gpt-image cont-tool owner-gen fb-check continuity-mutants continuity-resolve-mutants FORCE
diff --git a/native/kernel/README.md b/native/kernel/README.md
index 2996fa85..eceac1aa 100644
--- a/native/kernel/README.md
+++ b/native/kernel/README.md
@@ -373,11 +373,26 @@ low-water free bytes.
   0-0xffff to streams `0x10000*(n+1)` on the first SMMUv3 (0x13800000), and
   segment 15 on the second SMMUv3. Its NVMe (MEASURED: PCI 0004:01:00.0,
   behind that first SMMU) resolves to stream 0x50000 + (bus 1 << 8 | dev 0
-  << 3 | fn 0 = 0x100) = 0x50100. The linear stream table holds streams
-  0x0-0xfff only, so `ck_dma_confine` still refuses that stream with
-  `CK_SMMU_NOSTREAM` until the two-level stream table lands. The PCI walk
-  itself (`dev/pci.c`) still covers segment 0 only, so every `pci_func`
-  carries segment 0 today.
+  << 3 | fn 0 = 0x100) = 0x50100. The PCI walk itself (`dev/pci.c`) still
+  covers segment 0 only, so every `pci_func` carries segment 0 today.
+- Stream table format: when the SMMU reports two-level support
+  (`SMMU_IDR0.ST_LEVEL == 0b01`), `core/smmu_svc.c` runs a two-level stream
+  table (Arm IHI 0070 H.a, `SMMU_STRTAB_BASE_CFG` FMT 0b01, SPLIT 6, L1STD
+  section 5.1) of `MIN(SMMU_IDR1.SIDSIZE, 20)` StreamID bits, so stream ids
+  up to 0xfffff (the Spark's 0x50100 included) can be granted; otherwise the
+  linear table of 4096 entries as before. Every L1 descriptor starts with
+  Span 0 (its streams are terminated by the SMMU); the first grant in a
+  64-stream span takes one 4 KiB page, fills it with abort STEs, and only
+  then publishes the descriptor (Span 7) with a non-leaf `CMD_CFGI_STE`. Boot
+  prints `smmu: stream table 2-level log2size=.. split=6 (spans allocated per
+  grant)` or `smmu: stream table linear entries=4096`. QEMU 8.2.2
+  `iommu=smmuv3` takes the two-level path (log2size=16), so the existing
+  QEMU SMMU rows exercise it; the Spark SMMU's ST_LEVEL and SIDSIZE are
+  UNKNOWN until a hardware boot reads them (the NVMe working under Linux at
+  stream 0x50100 implies SIDSIZE >= 19, INFERRED). `make smmu-l2-mutants`
+  (run by `make test`) checks that test_smmu fails against an overflowing
+  Span, L1 descriptors valid before any grant, a misaligned L1 table, and an
+  L2 page published without abort STEs.
 
 - The kernel writes only inside the AIENOS partition of the boot disk
   (`dev/disk_part.h`, gate `DISK_LAYOUT`). The GPT is parsed read-only:
diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb
index 9695c699..d2446e90 100644
--- a/native/kernel/core/.crumb
+++ b/native/kernel/core/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-06T11:23:44Z",
+      "compiled_at": "2026-10-06T11:55:32Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:04cdf688c8b8db1c849f62a67d26f5e3d6755cd9e7abceda02ca57ae46ac2475",
+      "digest": "sha256:c820e3275ce15dabd61691a8371c3fdc3a6f43b594af398fcab62ff89e0c0578",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 31,
-      "generated_at_commit": "056b8e7c700fcafb2a942a17af8a4c61a4f6e961",
-      "source_tree": "sha256:9f9a72f2fd50cfa3f7eb109de0c56b6f6f2471d92600b8c56242fcea08938389"
+      "generated_at_commit": "788425caf3125f809254efb433fd5bc036eb6a59",
+      "source_tree": "sha256:e72a04571cd4898c3631b3893de0133c50fa734accc4b30170e14db145e4f054"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/core/smmu.c b/native/kernel/core/smmu.c
index 6eeaad3d..092086c1 100644
--- a/native/kernel/core/smmu.c
+++ b/native/kernel/core/smmu.c
@@ -1,6 +1,18 @@
 /* smmu.c -- see smmu.h. Port of crates/aienos-kernel/src/smmu.rs. */
 #include "smmu.h"
 
+/* TEST-only two-level stream table mutants (make smmu-l2-mutants): each
+ * must make test_smmu FAIL. Host builds only; never part of an image. */
+#if defined(CK_SMMU_MUTANT_SPAN_OVERFLOW) || defined(CK_SMMU_MUTANT_UNGRANTED_VALID) || \
+    defined(CK_SMMU_MUTANT_BAD_L1_PTR) || defined(CK_SMMU_MUTANT_L2_NO_FILL)
+#if !__STDC_HOSTED__
+#error "CK_SMMU_MUTANT_* are host test mutants only"
+#endif
+#ifdef CK_HARDWARE_STAGING
+#error "CK_SMMU_MUTANT_* cannot be combined with CK_HARDWARE_STAGING"
+#endif
+#endif
+
 #define IDR1_SIDSIZE_MASK 0x3fu
 #define IDR1_EVENTQS_SHIFT 16u
 #define IDR1_CMDQS_SHIFT 21u
@@ -31,17 +43,63 @@ static int aligned(const void *p, uint64_t bytes)
     return a != 0 && (a & (bytes - 1u)) == 0;
 }
 
+static uint32_t l1_n(const struct ck_smmu_tables *t) { return 1u << (t->sid_bits - CK_SMMU_SPLIT); }
+
 int ck_smmu_tables_check(const struct ck_smmu_tables *t)
 {
-    if (!pow2(t->ste_n, 1) || !pow2(t->cmd_n, 2) || !pow2(t->evt_n, 2) || t->ste_n > (1u << 16) ||
-        t->cmd_n > (1u << 19) || t->evt_n > (1u << 19) ||
-        !aligned(t->strtab, (uint64_t)t->ste_n * CK_SMMU_STE_BYTES) ||
+    if (!pow2(t->cmd_n, 2) || !pow2(t->evt_n, 2) || t->cmd_n > (1u << 19) || t->evt_n > (1u << 19) ||
         !aligned(t->cmdq, (uint64_t)t->cmd_n * CK_SMMU_CMD_BYTES) ||
         !aligned(t->evtq, (uint64_t)t->evt_n * CK_SMMU_EVT_BYTES))
         return CK_SMMU_EINVAL;
+    if (t->l1) {
+        if (t->sid_bits < CK_SMMU_L2_MIN_BITS || t->sid_bits > CK_SMMU_L2_MAX_BITS || !t->l2_alloc)
+            return CK_SMMU_EINVAL;
+        /* IHI 0070 6.3.24: 2-level base aligned to max(64 bytes, L1 size). */
+        uint64_t l1_bytes = (uint64_t)l1_n(t) * 8u;
+#ifndef CK_SMMU_MUTANT_BAD_L1_PTR
+        if (!aligned(t->l1, l1_bytes < 64u ? 64u : l1_bytes) ||
+            ((uint64_t)(uintptr_t)t->l1 & ~CK_SMMU_L1STD_L2PTR_MASK))
+            return CK_SMMU_EINVAL;
+#else
+        (void)l1_bytes; /* TEST mutant: any L1 pointer accepted */
+#endif
+        return 0;
+    }
+    if (!pow2(t->ste_n, 1) || t->ste_n > (1u << 16) || !aligned(t->strtab, (uint64_t)t->ste_n * CK_SMMU_STE_BYTES))
+        return CK_SMMU_EINVAL;
     return 0;
 }
 
+int ck_smmu_sid_in_range(const struct ck_smmu_tables *t, uint32_t sid)
+{
+    if (t->l1)
+        return t->sid_bits <= CK_SMMU_L2_MAX_BITS && (sid >> t->sid_bits) == 0;
+    return sid < t->ste_n;
+}
+
+uint64_t ck_smmu_l1std(const struct ck_smmu_tables *t, uint32_t sid)
+{
+    if (!t->l1 || !ck_smmu_sid_in_range(t, sid))
+        return 0;
+    return ((volatile const uint64_t *)t->l1)[sid >> CK_SMMU_SPLIT];
+}
+
+/* The STE of `sid`, or NULL when out of range or (two-level) its span has
+ * no L2 table yet (or a descriptor this code did not write: wrong Span or a
+ * zero L2Ptr, which the callers refuse). */
+static volatile uint64_t *ste_at(const struct ck_smmu_tables *t, uint32_t sid)
+{
+    if (!ck_smmu_sid_in_range(t, sid))
+        return 0;
+    if (!t->l1)
+        return (volatile uint64_t *)t->strtab + (uint64_t)sid * 8u;
+    uint64_t d = ck_smmu_l1std(t, sid);
+    if ((d & CK_SMMU_L1STD_SPAN_MASK) != CK_SMMU_L1STD_SPAN || !(d & CK_SMMU_L1STD_L2PTR_MASK))
+        return 0;
+    return (volatile uint64_t *)(uintptr_t)(d & CK_SMMU_L1STD_L2PTR_MASK) +
+           (uint64_t)(sid & (CK_SMMU_L2_STES - 1u)) * 8u;
+}
+
 void ck_smmu_ste_abort(uint64_t ste[8])
 {
     /* V = 1, Config = 0b000: abort every transaction. No bypass builder. */
@@ -185,10 +243,10 @@ static int wait_cr0(const struct ck_smmu_regs *r, uint32_t want, uint32_t spins)
     return CK_SMMU_ETIMEOUT;
 }
 
-static void write_ste_word(const struct ck_smmu_tables *t, uint32_t sid, int word, uint64_t v)
+static void write_ste_word(volatile uint64_t *ste, int word, uint64_t v)
 {
     /* A 64-bit aligned store is single-copy atomic: no torn word 0. */
-    ((volatile uint64_t *)t->strtab)[(uint64_t)sid * 8u + (uint64_t)word] = v;
+    ste[word] = v;
 }
 
 static int invalidate_ste(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t sid,
@@ -207,19 +265,33 @@ static int invalidate_ste(const struct ck_smmu_regs *r, const struct ck_smmu_tab
 
 static int program(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t spins)
 {
-    uint32_t sid_bits = log2u(t->ste_n);
-    if (!(rd(r, CK_SMMU_IDR0) & CK_SMMU_IDR0_S1P))
+    uint32_t sid_bits = t->l1 ? t->sid_bits : log2u(t->ste_n);
+    uint32_t idr0 = rd(r, CK_SMMU_IDR0);
+    if (!(idr0 & CK_SMMU_IDR0_S1P))
+        return CK_SMMU_EUNSUP;
+    if (t->l1 && ((idr0 >> CK_SMMU_IDR0_ST_LEVEL_SHIFT) & CK_SMMU_IDR0_ST_LEVEL_MASK) != 1u)
         return CK_SMMU_EUNSUP;
     uint32_t idr1 = rd(r, CK_SMMU_IDR1);
     if ((idr1 & IDR1_SIDSIZE_MASK) < sid_bits ||
         ((idr1 >> IDR1_CMDQS_SHIFT) & IDR1_QS_MASK) < log2u(t->cmd_n) ||
         ((idr1 >> IDR1_EVENTQS_SHIFT) & IDR1_QS_MASK) < log2u(t->evt_n))
         return CK_SMMU_EUNSUP;
-    uint64_t abort[8];
-    ck_smmu_ste_abort(abort);
-    for (uint32_t sid = 0; sid < t->ste_n; sid++)
-        for (int w = 0; w < 8; w++)
-            write_ste_word(t, sid, w, abort[w]);
+    if (t->l1) {
+        /* Every span invalid (Span 0): its StreamIDs are terminated. */
+        volatile uint64_t *l1 = t->l1;
+        for (uint32_t i = 0; i < l1_n(t); i++)
+#ifndef CK_SMMU_MUTANT_UNGRANTED_VALID
+            l1[i] = 0;
+#else
+            l1[i] = CK_SMMU_L1STD_SPAN; /* TEST mutant: valid span, L2Ptr 0 */
+#endif
+    } else {
+        uint64_t abort[8];
+        ck_smmu_ste_abort(abort);
+        for (uint32_t sid = 0; sid < t->ste_n; sid++)
+            for (int w = 0; w < 8; w++)
+                write_ste_word((volatile uint64_t *)t->strtab + (uint64_t)sid * 8u, w, abort[w]);
+    }
     volatile uint64_t *cq = t->cmdq, *eq = t->evtq;
     for (uint64_t i = 0; i < (uint64_t)t->cmd_n * 2u; i++)
         cq[i] = 0;
@@ -240,8 +312,13 @@ static int program(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t,
     wr64(r, CK_SMMU_EVENTQ_BASE, (uint64_t)(uintptr_t)t->evtq | log2u(t->evt_n));
     wr(r, CK_SMMU_EVENTQ_CONS, 0);
     wr(r, CK_SMMU_EVENTQ_PROD, 0);
-    wr(r, CK_SMMU_STRTAB_BASE_CFG, sid_bits); /* FMT = 0: linear */
-    wr64(r, CK_SMMU_STRTAB_BASE, (uint64_t)(uintptr_t)t->strtab);
+    if (t->l1) {
+        wr(r, CK_SMMU_STRTAB_BASE_CFG, CK_SMMU_STRTAB_FMT_2LVL | (CK_SMMU_SPLIT << 6) | sid_bits);
+        wr64(r, CK_SMMU_STRTAB_BASE, (uint64_t)(uintptr_t)t->l1);
+    } else {
+        wr(r, CK_SMMU_STRTAB_BASE_CFG, sid_bits); /* FMT = 0: linear */
+        wr64(r, CK_SMMU_STRTAB_BASE, (uint64_t)(uintptr_t)t->strtab);
+    }
     wr(r, CK_SMMU_CR0, CK_SMMU_CR0_CMDQEN | CK_SMMU_CR0_EVENTQEN);
     rc = wait_cr0(r, CK_SMMU_CR0_CMDQEN | CK_SMMU_CR0_EVENTQEN, spins);
     if (rc)
@@ -274,31 +351,80 @@ int ck_smmu_enable(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t,
     return rc;
 }
 
+/* Two-level: give the span of `sid` its L2 table. The page is checked
+ * (non-zero, aligned to CK_SMMU_L2_BYTES, inside L2Ptr bits 55:6), filled
+ * with abort STEs, made visible, and only then published in the L1STD
+ * (Span = SPLIT + 1). IHI 0070 5.1.1: an L1STD going from Span 0 to active
+ * needs the non-leaf CMD_CFGI_STE only. */
+static int attach_span(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t sid,
+                       uint32_t spins)
+{
+    if (ck_smmu_l1std(t, sid) != 0)
+        return CK_SMMU_EINVAL; /* a descriptor we did not write: refuse, do not overwrite */
+    uint64_t *page = 0;
+    if (t->l2_alloc(t->l2_ctx, &page) || !page)
+        return CK_SMMU_EINVAL;
+    uint64_t a = (uint64_t)(uintptr_t)page;
+    if ((a & (CK_SMMU_L2_BYTES - 1u)) || (a & ~CK_SMMU_L1STD_L2PTR_MASK))
+        return CK_SMMU_EINVAL;
+#ifndef CK_SMMU_MUTANT_L2_NO_FILL
+    uint64_t abort[8];
+    ck_smmu_ste_abort(abort);
+    for (uint32_t i = 0; i < CK_SMMU_L2_STES; i++)
+        for (int w = 0; w < 8; w++)
+            write_ste_word((volatile uint64_t *)page + (uint64_t)i * 8u, w, abort[w]);
+#endif
+    bar(r); /* every STE of the span is abort before the span goes live */
+#ifndef CK_SMMU_MUTANT_SPAN_OVERFLOW
+    uint64_t d = a | CK_SMMU_L1STD_SPAN;
+#else
+    uint64_t d = a | (CK_SMMU_L1STD_SPAN + 1u); /* TEST mutant: Span past SPLIT + 1 */
+#endif
+    ((volatile uint64_t *)t->l1)[sid >> CK_SMMU_SPLIT] = d;
+    uint64_t c[2][2];
+    ck_smmu_cmd(c[0], CK_SMMU_CMD_CFGI_STE, sid, 0); /* non-leaf: the L1STD */
+    ck_smmu_cmd(c[1], CK_SMMU_CMD_SYNC, 0, 0);
+    bar(r);
+    return ck_smmu_submit(r, t, (const uint64_t (*)[2])c, 2, spins);
+}
+
 int ck_smmu_abort_ste(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t sid,
                       uint32_t spins)
 {
-    if (sid >= t->ste_n)
+    if (!ck_smmu_sid_in_range(t, sid))
         return CK_SMMU_EINVAL;
+    volatile uint64_t *e = ste_at(t, sid);
+    if (!e) {
+        /* Two-level span without an L2 table: Span 0, every StreamID of it
+         * is already terminated. Anything else is not ours: refuse. */
+        return ck_smmu_l1std(t, sid) == 0 ? 0 : CK_SMMU_EINVAL;
+    }
     uint64_t abort[8];
     ck_smmu_ste_abort(abort);
     /* Word 0 first: once V = 1 and Config = abort the rest is ignored. */
     for (int w = 0; w < 8; w++)
-        write_ste_word(t, sid, w, abort[w]);
+        write_ste_word(e, w, abort[w]);
     return invalidate_ste(r, t, sid, spins);
 }
 
 int ck_smmu_install_ste(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t sid,
                         const uint64_t ste[8], uint32_t spins)
 {
-    if (sid >= t->ste_n)
+    if (!ck_smmu_sid_in_range(t, sid))
+        return CK_SMMU_EINVAL;
+    int rc;
+    if (t->l1 && !ste_at(t, sid) && (rc = attach_span(r, t, sid, spins)))
+        return rc;
+    volatile uint64_t *e = ste_at(t, sid);
+    if (!e)
         return CK_SMMU_EINVAL;
-    int rc = ck_smmu_abort_ste(r, t, sid, spins);
+    rc = ck_smmu_abort_ste(r, t, sid, spins);
     if (rc)
         return rc;
     for (int w = 1; w < 8; w++)
-        write_ste_word(t, sid, w, ste[w]);
+        write_ste_word(e, w, ste[w]);
     bar(r); /* words 1..7 visible before word 0 makes the entry live */
-    write_ste_word(t, sid, 0, ste[0]);
+    write_ste_word(e, 0, ste[0]);
     return invalidate_ste(r, t, sid, spins);
 }
 
diff --git a/native/kernel/core/smmu.h b/native/kernel/core/smmu.h
index b73bba8f..d297b413 100644
--- a/native/kernel/core/smmu.h
+++ b/native/kernel/core/smmu.h
@@ -1,6 +1,7 @@
 /* smmu.h -- Arm SMMUv3 programming for the AIENOS C kernel, ported from the
  * Rust reference crates/aienos-kernel/src/smmu.rs (linear stream table,
- * stage-1 translation only, one linear context descriptor per stream).
+ * stage-1 translation only, one linear context descriptor per stream). The
+ * two-level stream table (FMT = 2-level) is C only, from Arm IHI 0070 H.a.
  *
  * Pure logic over a register-access callback and table memory, so the host
  * tests drive it against a model SMMU. The kernel glue (core/smmu_svc.c)
@@ -57,6 +58,29 @@
 #define CK_SMMU_CMD_TLBI_NSNH_ALL 0x30u
 #define CK_SMMU_CMD_SYNC 0x46u
 
+/* Two-level stream table (Arm IHI 0070 H.a: SMMU_STRTAB_BASE_CFG 6.3.25,
+ * L1STD 5.1, SMMU_IDR0.ST_LEVEL). FMT = 0b01 in bits 17:16; SPLIT in bits
+ * 10:6 (6 = "4KB leaf tables"); LOG2SIZE in bits 5:0. The L1 table holds
+ * 2^(LOG2SIZE - SPLIT) 8-byte L1STDs indexed by StreamID[LOG2SIZE-1:SPLIT];
+ * each L2 table is indexed by StreamID[SPLIT-1:0]. L1STD: Span bits 4:0
+ * (0 = invalid: every StreamID of that span is terminated; 1..11 = 2^(Span-1)
+ * STEs; at most SPLIT + 1), L2Ptr bits 55:6, the L2 table aligned to its
+ * size. Here SPLIT is fixed at 6: one 4 KiB page of 64 STEs per span, Span
+ * = 7. LOG2SIZE is bounded to CK_SMMU_L2_MIN_BITS..CK_SMMU_L2_MAX_BITS so
+ * the L1 table is at most 128 KiB. */
+#define CK_SMMU_IDR0_ST_LEVEL_SHIFT 27u
+#define CK_SMMU_IDR0_ST_LEVEL_MASK 0x3u
+#define CK_SMMU_IDR1_SIDSIZE_MASK 0x3fu
+#define CK_SMMU_STRTAB_FMT_2LVL (1u << 16)
+#define CK_SMMU_SPLIT 6u
+#define CK_SMMU_L2_STES (1u << CK_SMMU_SPLIT)                   /* 64 */
+#define CK_SMMU_L2_BYTES (CK_SMMU_L2_STES * CK_SMMU_STE_BYTES)  /* 4096 */
+#define CK_SMMU_L1STD_SPAN_MASK 0x1full
+#define CK_SMMU_L1STD_L2PTR_MASK 0x00ffffffffffffc0ull         /* bits 55:6 */
+#define CK_SMMU_L1STD_SPAN (CK_SMMU_SPLIT + 1u)                  /* 2^(7-1) = 64 STEs */
+#define CK_SMMU_L2_MIN_BITS (CK_SMMU_SPLIT + 1u)
+#define CK_SMMU_L2_MAX_BITS 20u
+
 /* Event record types (word 0 bits 7:0). */
 #define CK_SMMU_EVT_F_TRANSLATION 0x10u
 #define CK_SMMU_EVT_F_ADDR_SIZE 0x11u
@@ -82,8 +106,14 @@ struct ck_smmu_regs {
     void (*barrier)(void *ctx); /* table writes visible before the next register write */
 };
 
-/* Linear stream table + queues. Entry counts are powers of two; every base
- * is aligned to its own size (min 32 bytes). Pointers are bus addresses. */
+/* Stream table + queues. Entry counts are powers of two; every base is
+ * aligned to its own size (min 32 bytes). Pointers are bus addresses.
+ * Linear (l1 == NULL): strtab holds ste_n STEs.
+ * Two-level (l1 != NULL): strtab and ste_n are unused; l1 holds
+ * 2^(sid_bits - CK_SMMU_SPLIT) L1STDs, aligned to the L1 size (min 64
+ * bytes). Every L1STD starts invalid (Span 0); the first install into a span
+ * takes one CK_SMMU_L2_BYTES page from l2_alloc (aligned to its size),
+ * fills it with abort STEs and only then publishes the L1STD. */
 struct ck_smmu_tables {
     uint64_t *strtab; /* ste_n x 8 words */
     uint32_t ste_n;
@@ -91,6 +121,10 @@ struct ck_smmu_tables {
     uint32_t cmd_n;
     uint64_t *evtq;   /* evt_n x 4 words */
     uint32_t evt_n;
+    uint64_t *l1;     /* two-level: 2^(sid_bits - CK_SMMU_SPLIT) L1STDs */
+    uint32_t sid_bits;
+    int (*l2_alloc)(void *ctx, uint64_t **page); /* 0 ok; one zeroed or dirty page */
+    void *l2_ctx;
 };
 
 struct ck_smmu_event {
@@ -103,6 +137,13 @@ struct ck_smmu_event {
 /* 0 if the geometry and alignment are valid, else CK_SMMU_EINVAL. */
 int ck_smmu_tables_check(const struct ck_smmu_tables *t);
 
+/* 1 if `sid` can be given an STE in these tables (linear: sid < ste_n;
+ * two-level: sid < 2^sid_bits), else 0. */
+int ck_smmu_sid_in_range(const struct ck_smmu_tables *t, uint32_t sid);
+/* Two-level only: the L1STD covering `sid`, or 0 when out of range or
+ * linear. */
+uint64_t ck_smmu_l1std(const struct ck_smmu_tables *t, uint32_t sid);
+
 /* Descriptor builders. */
 void ck_smmu_ste_abort(uint64_t ste[8]);
 void ck_smmu_ste_stage1(uint64_t ste[8], uint64_t cd_addr);
@@ -122,14 +163,16 @@ int ck_smmu_submit(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t,
 
 /* Bring-up with every stream in abort:
  *  1. GBPA.ABORT set and latched (else return without touching CR0);
- *  2. IDR0.S1P, IDR1 SIDSIZE / CMDQS / EVENTQS checked against the tables;
- *  3. all STEs abort, queues zeroed, barrier;
+ *  2. IDR0.S1P, IDR1 SIDSIZE / CMDQS / EVENTQS checked against the tables
+ *     (two-level also needs IDR0.ST_LEVEL == 0b01);
+ *  3. all STEs abort (two-level: every L1STD Span 0), queues zeroed, barrier;
  *  4. CR0 = 0 (ack), queues + stream table programmed, queues enabled (ack),
  *     CFGI_ALL + TLBI_NSNH_ALL + SYNC, SMMUEN (ack).
  * Any error after step 1 writes CR0 = 0 and returns it. */
 int ck_smmu_enable(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t spins);
 
 /* Point stream `sid` at `ste`: abort + invalidate first, write words 1..7,
+ * (two-level: a span with no L2 table first gets one, see ck_smmu_tables),
  * barrier, then word 0, then CFGI_STE + TLBI_NSNH_ALL + SYNC. */
 int ck_smmu_install_ste(const struct ck_smmu_regs *r, const struct ck_smmu_tables *t, uint32_t sid,
                         const uint64_t ste[8], uint32_t spins);
diff --git a/native/kernel/core/smmu_svc.c b/native/kernel/core/smmu_svc.c
index 2ba1b336..a54bc759 100644
--- a/native/kernel/core/smmu_svc.c
+++ b/native/kernel/core/smmu_svc.c
@@ -2,7 +2,9 @@
  * friends) over core/smmu.c, the IORT parser and the DMA pool. Kernel only
  * (the host tests drive core/smmu.c directly against a model SMMU).
  *
- * Memory: stream table (4096 STEs, 256 KiB), command and event queues, the
+ * Memory: stream table (two-level when the SMMU supports it: an L1 table of
+ * at most 128 KiB plus one 4 KiB L2 page per granted span; else linear, 4096
+ * STEs, 256 KiB), command and event queues, the
  * context descriptors and every stage-1 table come from ck_dma_alloc, which
  * is Normal Non-cacheable, so a dsb orders them before register writes. */
 #include "ck_internal.h"
@@ -54,6 +56,41 @@ static int pt_alloc(void *ctx, uint64_t *phys)
     return ck_dma_alloc(4096, 4096, phys) ? 0 : -1;
 }
 
+static int l2_alloc(void *ctx, uint64_t **page)
+{
+    (void)ctx;
+    uint64_t p;
+    *page = ck_dma_alloc(CK_SMMU_L2_BYTES, CK_SMMU_L2_BYTES, &p);
+    return *page ? 0 : -1;
+}
+
+/* Stream table format: two-level when the SMMU supports it
+ * (IDR0.ST_LEVEL == 0b01), sized to MIN(IDR1.SIDSIZE, CK_SMMU_L2_MAX_BITS)
+ * StreamID bits, so the DGX Spark's PCI streams (up to 0xfffff, MEASURED
+ * from its IORT) fit; L2 spans are allocated per grant. Otherwise the
+ * linear table of STE_N entries. 0 ok, -1 allocation failed. */
+static int alloc_strtab(void)
+{
+    uint64_t p;
+    uint32_t idr0 = r_rd32(0, CK_SMMU_IDR0), sidsize = r_rd32(0, CK_SMMU_IDR1) & CK_SMMU_IDR1_SIDSIZE_MASK;
+    if (((idr0 >> CK_SMMU_IDR0_ST_LEVEL_SHIFT) & CK_SMMU_IDR0_ST_LEVEL_MASK) == 1u && sidsize >= CK_SMMU_L2_MIN_BITS) {
+        uint32_t bits = sidsize < CK_SMMU_L2_MAX_BITS ? sidsize : CK_SMMU_L2_MAX_BITS;
+        uint32_t l1_bytes = (1u << (bits - CK_SMMU_SPLIT)) * 8u;
+        if (l1_bytes < 64u)
+            l1_bytes = 64u;
+        g.t.sid_bits = bits;
+        g.t.l2_alloc = l2_alloc;
+        g.t.l1 = ck_dma_alloc(l1_bytes, l1_bytes, &p);
+        ck_printf("smmu: stream table 2-level log2size=%u split=%u (spans allocated per grant)\n", bits,
+                  CK_SMMU_SPLIT);
+        return g.t.l1 ? 0 : -1;
+    }
+    g.t.ste_n = STE_N;
+    g.t.strtab = ck_dma_alloc(STE_N * CK_SMMU_STE_BYTES, STE_N * CK_SMMU_STE_BYTES, &p);
+    ck_printf("smmu: stream table linear entries=%u\n", STE_N);
+    return g.t.strtab ? 0 : -1;
+}
+
 static int bring_up(void)
 {
     if (g.state)
@@ -73,14 +110,13 @@ static int bring_up(void)
     g.base = g.iort.base;
     ck_mmio_map(g.base, CK_SMMU_MMIO_BYTES);
     uint64_t p;
-    g.t.ste_n = STE_N;
+    int st = alloc_strtab(); /* first, as before: the largest aligned block */
     g.t.cmd_n = QUEUE_N;
     g.t.evt_n = QUEUE_N;
-    g.t.strtab = ck_dma_alloc(STE_N * CK_SMMU_STE_BYTES, STE_N * CK_SMMU_STE_BYTES, &p);
     g.t.cmdq = ck_dma_alloc(4096, 4096, &p);
     g.t.evtq = ck_dma_alloc(4096, 4096, &p);
     g.cds = ck_dma_alloc(4096, 4096, &p);
-    if (!g.t.strtab || !g.t.cmdq || !g.t.evtq || !g.cds) {
+    if (st || !g.t.cmdq || !g.t.evtq || !g.cds) {
         ck_printf("smmu: table allocation failed (fail closed)\n");
         return g.state;
     }
@@ -136,8 +172,8 @@ int ck_dma_confine_named(const char *acpi_name, uint64_t phys, uint64_t len, str
 static int confine_sid(uint32_t sid, uint64_t phys, uint64_t len, struct ck_dma_confinement *out)
 {
     int rc;
-    if (sid >= STE_N)
-        return CK_SMMU_NOSTREAM;
+    if (!ck_smmu_sid_in_range(&g.t, sid))
+        return CK_SMMU_NOSTREAM; /* beyond the stream table this SMMU runs */
     int slot = -1;
     for (int i = 0; i < CK_DMA_MAX_STREAMS; i++) {
         if (g.used[i] && g.sid[i] == sid)
diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb
index 28b88e64..b22fec47 100644
--- a/native/kernel/tests/.crumb
+++ b/native/kernel/tests/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-06T11:23:44Z",
+      "compiled_at": "2026-10-06T11:55:32Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:8d9dd989b592bcdc509febaa9ea580f0301eb231910485a716663509733fac92",
+      "digest": "sha256:0fd32ca401eef461e59a9ac01b7879ce928c8057e8c2843d934772af8933e1c7",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 26,
-      "generated_at_commit": "056b8e7c700fcafb2a942a17af8a4c61a4f6e961",
-      "source_tree": "sha256:90ab73387bb3ae4e8d0887fef0d9557efb5225728e1a081b7656294b5602eacf"
+      "generated_at_commit": "788425caf3125f809254efb433fd5bc036eb6a59",
+      "source_tree": "sha256:d9c30071c4af9fad1e7e9dfad14a3a5a7cc29c03f24c12bf3056df39e36dad3b"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/tests/test_smmu.c b/native/kernel/tests/test_smmu.c
index 6bf4f985..faaad7e5 100644
--- a/native/kernel/tests/test_smmu.c
+++ b/native/kernel/tests/test_smmu.c
@@ -104,6 +104,7 @@ static struct ck_smmu_tables T;
 static void reset(void)
 {
     memset(&M, 0, sizeof M);
+    memset(&T, 0, sizeof T);
     memset(&mem, 0xee, sizeof mem);
     M.idr0 = CK_SMMU_IDR0_S1P;
     M.idr1 = 16u | (19u << 16) | (19u << 21);
@@ -501,6 +502,153 @@ static void test_iort_cap_overlap(void)
     CHECK(ck_iort_stream_id(&s, 1, 0x10, &sid) == 0 && sid == 0x5010);
 }
 
+/* ---- two-level stream table (Arm IHI 0070 H.a 6.3.25, 5.1) ------------- */
+#define L2_SID_BITS 20u
+#define L1_N (1u << (L2_SID_BITS - CK_SMMU_SPLIT))
+#define POOL_N 4
+static struct {
+    uint64_t l1[L1_N + 16] __attribute__((aligned(L1_N * 8)));
+    uint64_t page[POOL_N][CK_SMMU_L2_STES * 8] __attribute__((aligned(CK_SMMU_L2_BYTES)));
+} l2mem;
+static int pool_next, pool_misalign;
+static int pool_alloc(void *ctx, uint64_t **page)
+{
+    (void)ctx;
+    if (pool_next >= POOL_N) return -1;
+    *page = l2mem.page[pool_next++] + (pool_misalign ? 8 : 0);
+    return 0;
+}
+
+/* Independent model of the SMMU's stream table walk (IHI 0070 3.3.1,
+ * 5.1.1): -1 terminated (out of range, invalid span, outside the span,
+ * STE.V = 0), -2 a valid span whose L2 table is at address 0, else the STE
+ * Config (0 abort, 5 stage-1 translate). */
+static int walk(uint32_t sid)
+{
+    uint32_t cfg = M.strtab_cfg, split = (cfg >> 6) & 0x1f, log2size = cfg & 0x3f;
+    if (((cfg >> 16) & 3) != 1 || (sid >> log2size)) return -1;
+    const uint64_t *l1 = (const uint64_t *)(uintptr_t)(M.strtab & 0x00ffffffffffffc0ull);
+    uint64_t d = l1[sid >> split];
+    uint32_t span = (uint32_t)(d & 0x1f);
+    if (span == 0 || span > 11 || span > split + 1) return -1;
+    uint32_t idx = sid & ((1u << split) - 1u);
+    if (idx >= (1u << (span - 1))) return -1;
+    uint64_t l2 = d & 0x00ffffffffffffc0ull & ~((1ull << (6 + span - 1)) - 1ull);
+    if (l2 == 0) return -2; /* the SMMU would fetch STEs from physical address 0 */
+    const uint64_t *ste = (const uint64_t *)(uintptr_t)l2 + (uint64_t)idx * 8u;
+    if (!(ste[0] & 1)) return -1;
+    return (int)((ste[0] >> 1) & 7);
+}
+static void reset_l2(void)
+{
+    reset();
+    memset(&l2mem, 0xff, sizeof l2mem); /* dirty pages: the attach must fill them */
+    pool_next = 0;
+    pool_misalign = 0;
+    M.idr0 = CK_SMMU_IDR0_S1P | (1u << CK_SMMU_IDR0_ST_LEVEL_SHIFT);
+    M.idr1 = L2_SID_BITS | (19u << 16) | (19u << 21);
+    T.strtab = 0; T.ste_n = 0;
+    T.l1 = l2mem.l1; T.sid_bits = L2_SID_BITS;
+    T.l2_alloc = pool_alloc; T.l2_ctx = 0;
+}
+static int saw_cmd(uint8_t op, uint32_t sid, uint64_t w1)
+{
+    for (int i = 0; i < M.ncmd; i++)
+        if ((M.cmds[i][0] & 0xff) == op && (uint32_t)(M.cmds[i][0] >> 32) == sid && M.cmds[i][1] == w1) return 1;
+    return 0;
+}
+
+static void test_two_level(void)
+{
+    uint64_t ste[8];
+    ck_smmu_ste_stage1(ste, 0x40001000ull);
+    reset_l2();
+    CHECK(ck_smmu_tables_check(&T) == 0);
+    CHECK(ck_smmu_enable(&R, &T, 100) == 0);
+    CHECK(M.strtab_cfg == ((1u << 16) | (6u << 6) | 20u)); /* FMT 2-level, SPLIT 6, LOG2SIZE 20 */
+    CHECK(M.strtab == (uint64_t)(uintptr_t)l2mem.l1);
+    int all_invalid = 1;
+    for (uint32_t i = 0; i < L1_N; i++)
+        if (l2mem.l1[i] != 0) all_invalid = 0;
+    CHECK(all_invalid);
+    CHECK(pool_next == 0); /* lazy: no L2 table before the first grant */
+    CHECK(walk(0x0) == -1 && walk(0x50100) == -1);
+    /* Grant 0x0-0x5 (the USB named components) and 0x50100 (the NVMe). */
+    for (uint32_t sid = 0; sid <= 5; sid++)
+        CHECK(ck_smmu_install_ste(&R, &T, sid, ste, 100) == 0);
+    CHECK(pool_next == 1); /* one span covers 0x0-0x3f */
+    M.ncmd = 0;
+    CHECK(ck_smmu_install_ste(&R, &T, 0x50100, ste, 100) == 0);
+    CHECK(pool_next == 2);
+    CHECK(ck_smmu_l1std(&T, 0x50100) == ((uint64_t)(uintptr_t)l2mem.page[1] | 7u)); /* Span 7 = 64 STEs */
+    CHECK(l2mem.l1[0x50100 >> 6] == ck_smmu_l1std(&T, 0x50100));
+    CHECK(saw_cmd(CK_SMMU_CMD_CFGI_STE, 0x50100, 0)); /* non-leaf: the L1STD */
+    CHECK(saw_cmd(CK_SMMU_CMD_CFGI_STE, 0x50100, 1)); /* leaf: the STE */
+    for (uint32_t sid = 0; sid <= 5; sid++)
+        CHECK(walk(sid) == 5);
+    CHECK(walk(0x50100) == 5);
+    /* Refused: the neighbour in the same span aborts, other spans and
+     * out-of-range ids are terminated. */
+    CHECK(walk(0x50101) == 0);
+    CHECK(walk(0x6) == 0 && walk(0x3f) == 0);
+    CHECK(walk(0x40) == -1 && walk(0x50140) == -1 && walk(0x500ff) == -1);
+    CHECK(walk(0x100000) == -1);
+    CHECK(ck_smmu_sid_in_range(&T, 0xfffff) == 1 && ck_smmu_sid_in_range(&T, 0x100000) == 0);
+    CHECK(ck_smmu_install_ste(&R, &T, 0x100000, ste, 100) == CK_SMMU_EINVAL);
+    CHECK(pool_next == 2);
+    /* Revoke: back to abort; aborting an unattached span allocates nothing. */
+    CHECK(ck_smmu_abort_ste(&R, &T, 0x50100, 100) == 0 && walk(0x50100) == 0);
+    CHECK(ck_smmu_abort_ste(&R, &T, 0x80, 100) == 0 && walk(0x80) == -1 && pool_next == 2);
+    /* A descriptor the kernel did not write is refused, never overwritten. */
+    l2mem.l1[2] = 0x1234;
+    CHECK(ck_smmu_install_ste(&R, &T, 0x80, ste, 100) == CK_SMMU_EINVAL && l2mem.l1[2] == 0x1234);
+    CHECK(ck_smmu_abort_ste(&R, &T, 0x80, 100) == CK_SMMU_EINVAL);
+    CHECK(pool_next == 2);
+}
+
+static void test_two_level_refusals(void)
+{
+    uint64_t ste[8];
+    ck_smmu_ste_stage1(ste, 0x40001000ull);
+    /* Bad L1 pointer: not aligned to the L1 size (128 KiB here). */
+    reset_l2();
+    T.l1 = l2mem.l1 + 1;
+    CHECK(ck_smmu_tables_check(&T) == CK_SMMU_EINVAL);
+    CHECK(ck_smmu_enable(&R, &T, 100) == CK_SMMU_EINVAL && M.cr0 == 0 && M.wn == 0);
+    reset_l2();
+    T.l1 = l2mem.l1 + 8; /* 64-byte aligned only */
+    CHECK(ck_smmu_enable(&R, &T, 100) == CK_SMMU_EINVAL);
+    /* LOG2SIZE bounds and a missing allocator. */
+    reset_l2();
+    T.sid_bits = CK_SMMU_L2_MAX_BITS + 1;
+    CHECK(ck_smmu_tables_check(&T) == CK_SMMU_EINVAL);
+    T.sid_bits = CK_SMMU_SPLIT;
+    CHECK(ck_smmu_tables_check(&T) == CK_SMMU_EINVAL);
+    reset_l2();
+    T.l2_alloc = 0;
+    CHECK(ck_smmu_tables_check(&T) == CK_SMMU_EINVAL);
+    /* The SMMU must report 2-level support and enough StreamID bits. */
+    reset_l2();
+    M.idr0 = CK_SMMU_IDR0_S1P;
+    CHECK(ck_smmu_enable(&R, &T, 100) == CK_SMMU_EUNSUP && last_cr0() == 0);
+    reset_l2();
+    M.idr1 = 16u | (19u << 16) | (19u << 21);
+    CHECK(ck_smmu_enable(&R, &T, 100) == CK_SMMU_EUNSUP);
+    /* Bad L2 pointer from the allocator: refused, span stays invalid. */
+    reset_l2();
+    CHECK(ck_smmu_enable(&R, &T, 100) == 0);
+    pool_misalign = 1;
+    CHECK(ck_smmu_install_ste(&R, &T, 0x50100, ste, 100) == CK_SMMU_EINVAL);
+    CHECK(ck_smmu_l1std(&T, 0x50100) == 0 && walk(0x50100) == -1);
+    /* Allocator exhausted: refused, span stays invalid. */
+    pool_misalign = 0;
+    pool_next = POOL_N;
+    CHECK(ck_smmu_install_ste(&R, &T, 0x50100, ste, 100) == CK_SMMU_EINVAL && walk(0x50100) == -1);
+    /* The linear path is unchanged by the two-level fields being zero. */
+    reset();
+    CHECK(ck_smmu_enable(&R, &T, 100) == 0 && M.strtab_cfg == 4u && M.strtab == (uint64_t)(uintptr_t)mem.ste);
+}
+
 int main(void)
 {
     test_layouts();
@@ -513,5 +661,7 @@ int main(void)
     test_iort();
     test_iort_spark_shape();
     test_iort_cap_overlap();
+    test_two_level();
+    test_two_level_refusals();
     return ck_t_verdict("test_smmu");
 }