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

closed derived 93690defbb0a4821 #267

Imported from GitHub aien-dev/aienux#267 (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 20587476bf0d4b7577cc3b62857a9166300681bf · Head 4bbc7e66f4e28b91c523acf8f4b296dfe2141e71

Apply it

git checkout -b patch-93690defbb0a4821 20587476bf0d4b7577cc3b62857a9166300681bf
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/93690defbb0a4821.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
267
4bbc7e66f4e28b91c523acf8f4b296dfe2141e71
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":267,"url":"https://github.com/aien-dev/aienux/pull/267","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:05Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 5c12134e..3da141cc 100644
--- a/.crumb
+++ b/.crumb
@@ -28,32 +28,32 @@
         },
         {
           "digest": "d2b7dc151c8acb7896ad59cb1bf525b7a380502eda063a9dc24bc83d60d76d07",
-          "last_commit": "32256ba",
+          "last_commit": "2058747",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
         {
-          "digest": "57bcb42087257a7b2754c893ba6ca5bb8f8312d740057332065edcc9f984fa51",
-          "last_commit": "bbad5e4",
+          "digest": "5c12ec8f30db11dfd3faa66837610a3639cb256608864623ee71c297ed176124",
+          "last_commit": "2b4fd9f",
           "name": "native",
           "purpose": "Directory native. Purpose not yet described by a human."
         },
         {
-          "digest": "987eb5d8a450f5aaf1f821e428d30c06538cc5135d943892339157f9359e6938",
-          "last_commit": "32256ba",
+          "digest": "e8e8c21a3f1b0e2a2df96918fd438edf57c0f38095d04c9abc529225c4da9363",
+          "last_commit": "f921666",
           "name": "scripts",
           "purpose": "Directory scripts. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:6991afcf01ff2965aba6140ec23e294dcad019846fbb9670895ee4b172e86d60",
-      "compiled_at": "2026-10-05T19:26:03Z",
+      "children_root": "sha256:0398c76942ffe114dad9c4b3aec2fe5ce98e9b1f592411512bb8cd048ae6c7b3",
+      "compiled_at": "2026-10-06T01:42:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:01d9117f8b03793a45b6ffc91c879be4997664e927541ea392413937238d02b8",
-      "evidence_files": 147,
-      "evidence_root": "sha256:3f1c80574189eaded43ead3929d21a74c01f77dee31e7b2e2bd3858e67155dc7",
-      "files": 2857,
-      "generated_at_commit": "32256ba94a0bbabbe8f7ba201e7126b57fe4e4ea",
-      "source_tree": "sha256:c30d817e6a60a3ac5aa893fad88acd8e8f81ca7c39ebef83e3afa990f1d1d5fa"
+      "digest": "sha256:e3c013fa59d843e3834df9f3748d07229862e72ad5ff9be2352dc3d0666f5cc0",
+      "evidence_files": 149,
+      "evidence_root": "sha256:e682703b498863c134532be1f72e10bebee3a00764307206e1f410fb2bf0390a",
+      "files": 2863,
+      "generated_at_commit": "2b4fd9f620e23e1be64f34e531ceac198e51321c",
+      "source_tree": "sha256:f6408e48d33dc70c59e7e4225cae9379ed91599d3f6d0423002e80254650785f"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/ROADMAP.md b/ROADMAP.md
index 76d17153..2a7370db 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -17,10 +17,13 @@ NOT_RUN, BLOCKED_HARDWARE, BLOCKED_OPERATOR, MISSING_IMPLEMENTATION.
 C kernel series  #194 34c6053 .. #204 c3878bb   IMPLEMENTED / NOT QUALIFIED
     evidence class: QEMU, plus GitHub ARM64 CI (which is still QEMU).
     No physical boot of the C kernel has happened ("physical": NOT_RUN).
-    newest ck_gates receipt: evidence/ck_gates_bb4040322b026f5f561733fdcaf900770070f2281800b0e3603c2aa2c670b7ff.json
-        run at 4f56a96; verdict NOT_ALL_GATES_PASS
-        9 PASS / 0 FAIL / 5 NOT_RUN of 14 gates
-        NOT_RUN: M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD
+    newest ck_gates receipt: evidence/ck_gates_bc306a04d8ba513b2364fbee644f37375dc686ccead97c8759191b76ebec94eb.json
+        run at f921666 (NEXT-PHASE-3 cut 1, C keyboard + recovery access); verdict NOT_ALL_GATES_PASS
+        19 PASS / 0 FAIL / 1 NOT_RUN of 20 gates
+        NOT_RUN: M0_ROLLBACK
+        KEYBOARD PASS in QEMU only; the Spark's USB controllers are ACPI platform
+        xHCI devices, not PCI, so the C driver does not reach them yet
+        (native/kernel/README.md, "Operator input and recovery access").
     M0_ROLLBACK is still MISSING_IMPLEMENTATION in the C kernel (the C loader
         BootNext / A-B / rollback is parked, native/boot/README.md), despite
         the title of #204 ("P2_ARTIFACT loader and M0_ROLLBACK gates"). #204
diff --git a/evidence/ck_gates_79a843817161b68d71889201bd4407a3b4e432ac808503b017836f71abc3f2db.json b/evidence/ck_gates_79a843817161b68d71889201bd4407a3b4e432ac808503b017836f71abc3f2db.json
new file mode 100644
index 00000000..0bcc0d9f
--- /dev/null
+++ b/evidence/ck_gates_79a843817161b68d71889201bd4407a3b4e432ac808503b017836f71abc3f2db.json
@@ -0,0 +1,57 @@
+{
+  "schema": "aienos.ck_gates.v1",
+  "started_utc": "2026-10-06T00:43:27Z",
+  "finished_utc": "2026-10-06T01:21:30Z",
+  "commit": "20587476bf0d4b7577cc3b62857a9166300681bf",
+  "commit_subject": "trust1: attended package + host-only evidence checker (HOST VALIDATION ONLY) (#265)",
+  "tree_clean_before": true,
+  "tree_clean_after": true,
+  "quiet_flag": "/home/drakestapleton/.claude/jobs/9bfe8553/tmp/locks/quiet-never-present",
+  "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": 7, "log_sha256": "2128262af907d9c7eb6197a491475c691a07951601892c9ad4ef79e58303b0e4", "log_lines": 24},
+    {"name": "store", "script": "scripts/qemu_ck_store_test.sh", "present": true, "script_sha256": "0b31a44af9388302d5488fdef318a509c4f26c2420f82ceb2fa7f7b698647748", "exit": "0", "seconds": 94, "log_sha256": "9a2ab5d2454b019eee928a770b9f4972bc3c724829b73001caced8867544f323", "log_lines": 612},
+    {"name": "net", "script": "scripts/qemu_ck_net_test.sh", "present": true, "script_sha256": "ea051cc946c206f92c0c1563b3463b6bebffbce04e361e76d51dd49c1be4a6cf", "exit": "0", "seconds": 19, "log_sha256": "a6260be2fbd2cd1adeab3c29f1751189a868e2ad1c4ce45cfb7398b1128c59a4", "log_lines": 95},
+    {"name": "artifact", "script": "scripts/qemu_ck_artifact_test.sh", "present": true, "script_sha256": "e60f6c4aed822f693a530cb98b2fa4689b7b56e7c0efed5f9bf9ff4e9f75fc67", "exit": "0", "seconds": 32, "log_sha256": "c38d2ea404e8cba8b01390f34164a3268b1129a0b3b3aa6d2057b942ca881242", "log_lines": 215},
+    {"name": "smp", "script": "scripts/qemu_ck_smp_test.sh", "present": true, "script_sha256": "b5665568394f391c17aaa9148bce2358f1145240cc38422c2927664b0ffd41d6", "exit": "0", "seconds": 6, "log_sha256": "a939f1dbc28fb64bff10eeee93827e95cbdd885dbcb3875ea7bb99b074289749", "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": "7d0aa4df9492f41f1cd7ff6a741b1b35d93477666450dbc0f2cc4a5e6a854f69", "log_lines": 264},
+    {"name": "cont", "script": "scripts/qemu_ck_continuity_test.sh", "present": true, "script_sha256": "30a8eb2dbb949eab29ad046231869a306199908022cb2345151988ea4957cf2e", "exit": "0", "seconds": 184, "log_sha256": "3e83194b2af36eefa07395756f6256c687d74c47ed3fb38ef9dbcd4ccb8fcc50", "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": 201, "log_sha256": "c1dda978d3fe0448152472a863122d9468e6bb1b1b72cab6ba0edca818b6a909", "log_lines": 73},
+    {"name": "fpu", "script": "scripts/qemu_ck_fpu_test.sh", "present": true, "script_sha256": "f04fa538752f6864bc2d5f9ff5af6eac71a5e3a005fe9c76b77477012325cc14", "exit": "0", "seconds": 8, "log_sha256": "180f3449ba9e0416381a5ad179e31773915bc038c6a857889181b71a2dda7e4f", "log_lines": 13},
+    {"name": "infer", "script": "scripts/qemu_ck_infer_test.sh", "present": true, "script_sha256": "185c78b8688004dc6a807182c81e319b1598414935934b6c881cfafae5ce31fa", "exit": "0", "seconds": 865, "log_sha256": "aec9a1470b9a18071a9f8cc6897d3b3a4fed5c0210552f7e9ec608f4343b851a", "log_lines": 35},
+    {"name": "screen", "script": "scripts/qemu_ck_screen_test.sh", "present": true, "script_sha256": "b2b71aff7fb9274eb15d8381e44dda9d7b700821fd45a23cde1c9a1132dc6b3f", "exit": "0", "seconds": 16, "log_sha256": "e8c93515d71de0e33a06be0a1c89ccc3a90bf9c6b4fafcdff56d238c06de4e97", "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": "missing", "verdict": "NOT_RUN", "reason": "MISSING_IMPLEMENTATION: no xHCI/USB HID keyboard driver in the C kernel"},
+    {"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": 18, "fail": 0, "not_run": 2},
+  "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/evidence/ck_gates_bc306a04d8ba513b2364fbee644f37375dc686ccead97c8759191b76ebec94eb.json b/evidence/ck_gates_bc306a04d8ba513b2364fbee644f37375dc686ccead97c8759191b76ebec94eb.json
new file mode 100644
index 00000000..38ad0b7f
--- /dev/null
+++ b/evidence/ck_gates_bc306a04d8ba513b2364fbee644f37375dc686ccead97c8759191b76ebec94eb.json
@@ -0,0 +1,58 @@
+{
+  "schema": "aienos.ck_gates.v1",
+  "started_utc": "2026-10-06T01:02:45Z",
+  "finished_utc": "2026-10-06T01:41:24Z",
+  "commit": "f921666189e67fbc80cc511d84d9991ec76c26b4",
+  "commit_subject": "ck kernel: operator keyboard input + recovery-access hook (KEYBOARD gate)",
+  "tree_clean_before": true,
+  "tree_clean_after": true,
+  "quiet_flag": "/home/drakestapleton/.claude/jobs/9bfe8553/tmp/locks/quiet-after",
+  "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": "d84fad57f52001096bd9836e946688e83ebcfc3529244dd44935f341bcd6b021", "log_lines": 24},
+    {"name": "store", "script": "scripts/qemu_ck_store_test.sh", "present": true, "script_sha256": "0b31a44af9388302d5488fdef318a509c4f26c2420f82ceb2fa7f7b698647748", "exit": "0", "seconds": 92, "log_sha256": "91777bdda6ee01a831fc2b725c2ad2f2423ddae948602fdde2768c716a4ca278", "log_lines": 612},
+    {"name": "net", "script": "scripts/qemu_ck_net_test.sh", "present": true, "script_sha256": "ea051cc946c206f92c0c1563b3463b6bebffbce04e361e76d51dd49c1be4a6cf", "exit": "0", "seconds": 18, "log_sha256": "89a33d6e25cf9fd4505682d9fa026fbc6089cec7569b7debc57f59e3299de029", "log_lines": 95},
+    {"name": "artifact", "script": "scripts/qemu_ck_artifact_test.sh", "present": true, "script_sha256": "e60f6c4aed822f693a530cb98b2fa4689b7b56e7c0efed5f9bf9ff4e9f75fc67", "exit": "0", "seconds": 32, "log_sha256": "3048b3102b9717479ab8a84fc92f071feccc6b3012cafef72eb09a03bcf821eb", "log_lines": 215},
+    {"name": "smp", "script": "scripts/qemu_ck_smp_test.sh", "present": true, "script_sha256": "b5665568394f391c17aaa9148bce2358f1145240cc38422c2927664b0ffd41d6", "exit": "0", "seconds": 6, "log_sha256": "a77325713ed95008f4d0b7b3219a81bb34f586fd7ce611e7e49b964182730a73", "log_lines": 16},
+    {"name": "crash", "script": "scripts/qemu_ck_store_crash_test.sh", "present": true, "script_sha256": "3d04ca0775db7e70a244b6a09b19c5adf987f777b6ff630874c42e339add7765", "exit": "0", "seconds": 674, "log_sha256": "4059e2ca3fc2df078693ca717505424da031e32d9b8da1a159ced4e993dc12c6", "log_lines": 239},
+    {"name": "disk", "script": "scripts/qemu_ck_disk_layout_test.sh", "present": true, "script_sha256": "f490548245252b97518e9049ce8e7078f5297c81584b60f08f802cfea6bb3110", "exit": "0", "seconds": 58, "log_sha256": "6108e33abf86da00c50a9be4584fb46c2bf2b64066e8c2e336a3479951ac3b2c", "log_lines": 264},
+    {"name": "cont", "script": "scripts/qemu_ck_continuity_test.sh", "present": true, "script_sha256": "30a8eb2dbb949eab29ad046231869a306199908022cb2345151988ea4957cf2e", "exit": "0", "seconds": 183, "log_sha256": "36f966d91a69dbfb8cbfc4c9f4a7380b8f38de43576fde02d071a573255bfde1", "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": "65ad8f36a4f5b69690613a9ecd0d0b02237d39d5ed45a95d8aab954dcbcf0247", "log_lines": 73},
+    {"name": "kbd", "script": "scripts/qemu_ck_keyboard_test.sh", "present": true, "script_sha256": "c1ac74a30f722379d05326a0f98fa2287529ccd5a8036d79cb062479995672b1", "exit": "0", "seconds": 41, "log_sha256": "db9d7eb041c35ae940331e8fe3bf4886ba1d361ba1828233fdedad9e38e87341", "log_lines": 154},
+    {"name": "fpu", "script": "scripts/qemu_ck_fpu_test.sh", "present": true, "script_sha256": "f04fa538752f6864bc2d5f9ff5af6eac71a5e3a005fe9c76b77477012325cc14", "exit": "0", "seconds": 8, "log_sha256": "b2ed54b462c8b536e16de7b9e7bcedd1d27c3de1f434b844596054e8a91e0598", "log_lines": 13},
+    {"name": "infer", "script": "scripts/qemu_ck_infer_test.sh", "present": true, "script_sha256": "185c78b8688004dc6a807182c81e319b1598414935934b6c881cfafae5ce31fa", "exit": "0", "seconds": 867, "log_sha256": "efcaa9979bd6ebd14fef0d0f0cbce8006eb50ceedecf61fa03e901eb3aad5492", "log_lines": 35},
+    {"name": "screen", "script": "scripts/qemu_ck_screen_test.sh", "present": true, "script_sha256": "b2b71aff7fb9274eb15d8381e44dda9d7b700821fd45a23cde1c9a1132dc6b3f", "exit": "0", "seconds": 16, "log_sha256": "954d39096c2437d4c4c1373b76f9f09c2a5aed5abed163592108abc52dccde02", "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 7185c767..5d7ec0e8 100644
--- a/native/.crumb
+++ b/native/.crumb
@@ -79,8 +79,8 @@
           "purpose": "Directory native/disk. Purpose not yet described by a human."
         },
         {
-          "digest": "2c2bc865ef98c8a21d12d898dc3341f434b63ac869cb0a79d740b6793e5d6ba7",
-          "last_commit": "9d41efc",
+          "digest": "e2bbca7edcc6a7f38cdd2287cd8ed3dfc10e33b674f771a689f0c6d7d26fb682",
+          "last_commit": "f921666",
           "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:8900a8b3f9b6a7bbf659441719855046e5f8e312d14af8515e3b11efa6822646",
-      "compiled_at": "2026-10-05T04:07:45Z",
+      "children_root": "sha256:dc7d8a5fe8b7cec6d8c4d5b039db6f337c2969022aeb261b5dacaa3d07e16a5d",
+      "compiled_at": "2026-10-06T01:42:01Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:57bcb42087257a7b2754c893ba6ca5bb8f8312d740057332065edcc9f984fa51",
+      "digest": "sha256:5c12ec8f30db11dfd3faa66837610a3639cb256608864623ee71c297ed176124",
       "evidence_files": 4,
       "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335",
-      "files": 306,
-      "generated_at_commit": "4dee261c83eab79cd1e12ca2c71183c2f0000930",
-      "source_tree": "sha256:46c900c28f4d2c8824530a0c1240a9bf30e869bb8631c8c49ce851843ac2de37"
+      "files": 310,
+      "generated_at_commit": "f921666189e67fbc80cc511d84d9991ec76c26b4",
+      "source_tree": "sha256:c32c59720817576798a7212f48e9f37ff32c9bc9bedb01745939da1250532a7c"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/.crumb b/native/kernel/.crumb
index 0ac478d5..01d70120 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": "dd6ebb445202c084d41a923774ff81d2c0c384393b7383c92ed09e77028d2307",
-          "last_commit": "46f22fe",
+          "digest": "e5ebaf34e03225eabc74a1b335f9aea4635942690cd0d8aeb22cfa6addd4e833",
+          "last_commit": "f921666",
           "name": "core",
           "purpose": "Directory native/kernel/core. Purpose not yet described by a human."
         },
         {
-          "digest": "23eaffd404d1c16455030fd1c27ba14fa3311714528b336db3f59451e880819e",
-          "last_commit": "44de11f",
+          "digest": "914c089b5c7d4cf9f5ffd86440ae5a8250bb7e518c497aa65e9829797b1f1e57",
+          "last_commit": "f921666",
           "name": "dev",
           "purpose": "Directory native/kernel/dev. Purpose not yet described by a human."
         },
         {
-          "digest": "dd460494a52e8cc9d2b05d75f86d71e8c387090c04ebcb7c448730dc765d39f1",
-          "last_commit": "9daa5e1",
+          "digest": "67502074fde0b499b68d22d8498c2e410e365f1d9f2dc69b890fac52a56a2d93",
+          "last_commit": "f921666",
           "name": "include",
           "purpose": "Directory native/kernel/include. Purpose not yet described by a human."
         },
@@ -81,8 +81,8 @@
           "purpose": "Directory native/kernel/mm. Purpose not yet described by a human."
         },
         {
-          "digest": "f24db6711bf88a0d7c48375f6f979fd589306a9266c697c5f25d4e8a2dbdb90d",
-          "last_commit": "9d41efc",
+          "digest": "2c634b363be2e02a04c0fdb3cf56c88bebf0a86ee172f3416989df3764ea7a0d",
+          "last_commit": "f921666",
           "name": "svc",
           "purpose": "Directory native/kernel/svc. 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:2030704d394ed4b573afc5f97226836308cfab5e9d7f6e4279deb2170cb42628",
-      "compiled_at": "2026-10-05T04:07:45Z",
+      "children_root": "sha256:0b4520412eaa0fbd41c3c2686b6a590d39a836ca4875d3e317730a40e384989c",
+      "compiled_at": "2026-10-06T01:42:01Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:2c2bc865ef98c8a21d12d898dc3341f434b63ac869cb0a79d740b6793e5d6ba7",
+      "digest": "sha256:e2bbca7edcc6a7f38cdd2287cd8ed3dfc10e33b674f771a689f0c6d7d26fb682",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 142,
-      "generated_at_commit": "4dee261c83eab79cd1e12ca2c71183c2f0000930",
-      "source_tree": "sha256:67252ad126c5e094ac77917b4e8e207ecb1cfe9ddae8f50d6a6b0afb29ff19c2"
+      "files": 146,
+      "generated_at_commit": "f921666189e67fbc80cc511d84d9991ec76c26b4",
+      "source_tree": "sha256:ee6bfdcb90b79757e6dd8bf893def42c954f46042882cca2216467c2ddaf5bcf"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/GATES.md b/native/kernel/GATES.md
index 8fa047c9..17824546 100644
--- a/native/kernel/GATES.md
+++ b/native/kernel/GATES.md
@@ -25,7 +25,7 @@ C gates (one line each from `ck_gates.sh`): `M1` and `M3` (from
 `scripts/qemu_ck_net_test.sh`; rows 102-106 and 110-112; the script now also checks the virtio-net SMMU fence (ACCESS_PLATFORM required, out-of-window device DMA refused), rows 102 and 110-112 are QEMU PASS on this branch from the committed forge log `evidence/ck_net_qemu_8bdbc2e46b85d04c422f9d2830c1c4b263e254b3cfecfe21ff0063c9e33c86e8.log`, hardware NOT_RUN), the kernel entropy rows 107-109 (M1 via `scripts/lib_ck_m1_checks.sh`, ARGUS1_REVOKE and M4_STORE via the Store gate boot 7),
 `DISK_LAYOUT` (C-only, from `scripts/qemu_ck_disk_layout_test.sh`, rows 118-123: QEMU PASS at 741b2b8 before the merge with main 8555049, rerun pending at the merged head; row 123 host test), and the NOT_RUN gates
 `SMP` (C-only, from `scripts/qemu_ck_smp_test.sh`, rows 113-117, NOT_RUN pending forge receipt), `M0_ROLLBACK`, `M4_STORE_CRASH` (now read from `scripts/qemu_ck_store_crash_test.sh`, rows 73-80; NOT_RUN until a forge receipt exists),
-`M4_CONTINUITY`, `M4_RECOVERY`, `M4_ALLEN` (C-only, from `scripts/qemu_ck_allen_test.sh`, rows A1-A30; QEMU PASS, hardware NOT_RUN), `KEYBOARD`, `FPU` (C-only, from `scripts/qemu_ck_fpu_test.sh`, rows 124-128; QEMU PASS, hardware NOT_RUN), `INFER` (C-only, from `scripts/qemu_ck_infer_test.sh`, rows 129-139; QEMU PASS, hardware NOT_RUN), and `SCREEN` (C-only, from `scripts/qemu_ck_screen_test.sh`, rows 140-145; QEMU PASS, hardware NOT_RUN).
+`M4_CONTINUITY`, `M4_RECOVERY`, `M4_ALLEN` (C-only, from `scripts/qemu_ck_allen_test.sh`, rows A1-A30; QEMU PASS, hardware NOT_RUN), `KEYBOARD` (from `scripts/qemu_ck_keyboard_test.sh`, rows 25-32 and C-only 30a-30c; QEMU PASS, hardware NOT_RUN), `FPU` (C-only, from `scripts/qemu_ck_fpu_test.sh`, rows 124-128; QEMU PASS, hardware NOT_RUN), `INFER` (C-only, from `scripts/qemu_ck_infer_test.sh`, rows 129-139; QEMU PASS, hardware NOT_RUN), and `SCREEN` (C-only, from `scripts/qemu_ck_screen_test.sh`, rows 140-145; QEMU PASS, hardware NOT_RUN).
 
 `M4_NVME` and `SMMU` PASS in the SMMU-confined mode (default `make full`
 image, QEMU `iommu=smmuv3`). The unconfined bypass build
@@ -121,40 +121,67 @@ per-stream page tables, `ck_dma_confine` / `ck_dma_unconfine` /
 
 ## SEED-0A keyboard: scripts/qemu_keyboard_test.sh (SMMU=1 and SMMU=0) -> CK `KEYBOARD`
 
-C child script: `scripts/qemu_ck_keyboard_test.sh` (DMA-safety rows only; both
-modes in one run, boot `kbd-smmu` with QEMU `iommu=smmuv3` and boot
-`kbd-nosmmu` without; same devices as the Rust gate: `qemu-xhci` + `usb-kbd`,
-plus an NVMe disk for the normal full boot). It prints one
+C child script: `scripts/qemu_ck_keyboard_test.sh`. Three boots in one run,
+same devices as the Rust gate (`qemu-xhci` + `usb-kbd`, plus an NVMe disk for
+the normal full boot): `kbd-smmu` with QEMU `iommu=smmuv3`, `kbd-nosmmu`
+without, and `kbd-recovery` (SMMU on). Keys are injected by the script through
+the QEMU monitor (`sendkey`, as the Rust gate does); the kernel never fakes the
+device. Boot `kbd-smmu` sends no key in the recovery window, then the lines
+`abc`, `help`, `el`, `mem`, 65 `x` keys (one past the 64-key line bound) and
+`exit`. Boot `kbd-recovery` sends `r` in the recovery window. It prints one
 `KEYBOARD_ROW <n>: PASS|FAIL|NOT_RUN` line per row, then
-`AIENOS_CK_KEYBOARD_DMA: PASS|FAIL (rows 25-28,31,32)` and always
-`AIENOS_CK_KEYBOARD: NOT_RUN (MISSING_IMPLEMENTATION: ...)`: the gate stays
-NOT_RUN until rows 29-30 exist. C code: the post-exit bus-master sweep
-`pci_sweep_bus_master` (native/kernel/dev/pci.c, port of the Rust
-`dma_gate::sweep_bus_master`, run at the start of the devices stage before any
-device gets DMA) and the xHCI DMA fence `native/kernel/dev/xhci_fence.c`
-(same SMMU gate as NVMe and virtio-net: `ck_dma_confine` window first, then
-memory decode + bus master; no SMMU means no DMA, no bypass build; controller
-halted, bus master revoked, stream back to abort). No USB HID driver and no
-console shell. Mutation self-test: `scripts/qemu_ck_keyboard_test.sh
---mutation` builds `make full CK_TEST_XHCI_MUTATION=<m>` (TEST-ONLY, refused
-with `CK_HARDWARE_STAGING=1` and with `CK_QEMU_UNSAFE_DMA=1`, by the Makefile
-and by an `#error`; the default image is checked to carry no mutation banner)
-and requires bm-left-on -> row 27, no-revoke -> row 31, grant-no-smmu -> row 28,
-no-sweep -> row 26 to FAIL. Host tests (`stage_test`): sweep on a fake ECAM
-(endpoints cleared, bridges untouched, multi-function rule, every bus) and the
-fence fail-closed paths (no SMMU, bus master left on). Hardware NOT_RUN: no
-physical xHCI or SMMU run.
+`AIENOS_CK_KEYBOARD_DMA: PASS|FAIL (rows 25-28,31,32)` and
+`AIENOS_CK_KEYBOARD: PASS|FAIL|NOT_RUN` (NOT_RUN with exit 3 while the QEMU
+gate lock is held, while the quiet flag exists, or when `AIENOS_QEMU_SMMU`
+selects only one mode). `scripts/ck_gates.sh` takes KEYBOARD from this child
+only.
+
+C code: the post-exit bus-master sweep `pci_sweep_bus_master`
+(native/kernel/dev/pci.c), the xHCI DMA fence `native/kernel/dev/xhci_fence.c`
+(`ck_dma_confine` window first, then memory decode + bus master; no SMMU means
+no DMA, no bypass build; controller halted, bus master revoked, stream back to
+abort), and inside that fence the polled keyboard driver
+`native/kernel/dev/usb_kbd.c` (xHCI reset, command and event rings, Enable
+Slot, Address Device, configuration descriptor, Configure Endpoint,
+SET_PROTOCOL boot, interrupt IN transfers; port of the Rust
+`crates/aienos-kernel/src/usb/xhci` and `crates/aienos-boot/src/usb_keyboard.rs`)
+with its pure logic in `native/kernel/dev/usb_hid.c` (boot report decode to a
+fixed US keymap, descriptor walk, bounded line editor, the Rust shell commands,
+the recovery-access decision and identity digest). Every ring, context and
+buffer lives in the fence's DMA region, the controller stream's only SMMU
+window. The recovery choice is acted on by `native/kernel/dev/devices.c`
+after the xHCI revoke: virtio-net and NVMe DMA released, then the recovery
+console stub prints the identity digest and halts. Operator-facing
+description and the physical attended-boot procedure:
+`native/kernel/README.md`, section "Operator input and recovery access (C
+kernel)".
+
+Mutation self-test: `scripts/qemu_ck_keyboard_test.sh --mutation` builds
+`make full CK_TEST_XHCI_MUTATION=<m>` (TEST-ONLY, refused with
+`CK_HARDWARE_STAGING=1` and with `CK_QEMU_UNSAFE_DMA=1`, by the Makefile and by
+an `#error`; the default image is checked to carry no mutation banner) and
+requires bm-left-on -> row 27, no-revoke -> row 31, grant-no-smmu -> row 28,
+no-sweep -> row 26 to FAIL. Host tests (`stage_test`): sweep on a fake ECAM,
+the fence fail-closed paths, and the operator input logic (keymap, report
+decode with held keys and rollover, descriptor walk with malformed lengths,
+line editor overflow refusal, shell output texts, recovery decision, identity
+digest). One deliberate difference from Rust: the Rust shell drops keys past
+its 64-byte line; the C editor refuses the whole line (row 30c). Hardware
+NOT_RUN: no physical xHCI, keyboard or SMMU run.
 
 | # | Rust check (pattern) | CK gate | Status |
 | --- | --- | --- | --- |
-| 25 | xHCI found before exit (`keyboard: xhci `) | KEYBOARD | NOT_RUN (pending forge receipt; C would be DIFFERS: found after exit on the ECAM walk, class 0x0c0330, `keyboard: xhci 0000:BB:DD.F mmio 0x.. (found post-exit on the ECAM walk)`, both boots) |
-| 26 | bus-master sweep after exit (`dma_sweep: seg `, no `dma_sweep: bme STUCK`) | KEYBOARD | NOT_RUN (pending forge receipt; C would be DIFFERS: same line text as Rust, `dma_sweep: seg 0000 bus .. functions=N ... still_enabled=0`, no `dma_sweep: bme STUCK`, and stricter: the sweep must come before the first `dma_gate: ` line and before `keyboard: xhci `; both boots; mutation no-sweep) |
-| 27 | xHCI bus master off before the DMA gate (`xhci_pci: command=0x.. bus_master=off`) | KEYBOARD | NOT_RUN (pending forge receipt; C would be IDENTICAL prefix `xhci_pci: command=0x.... bus_master=off`, plus the order check: before `dma_gate: xhci `; both boots; mutation bm-left-on) |
-| 28 | fail-closed without SMMU (`dma_gate: xhci denied (NoSmmu)...`, `keyboard: unavailable (...)`, no grant, no `keyboard: ready`) | KEYBOARD | NOT_RUN (pending forge receipt; C would be IDENTICAL lines `dma_gate: xhci denied (NoSmmu), bus master stays off` and `keyboard: unavailable (SMMU DMA isolation not active)`, absent `dma_gate: xhci granted` and `keyboard: ready`, plus C-only: COMMAND read back after the deny `bus_master=off`, no xHCI SMMU window; boot kbd-nosmmu; mutation grant-no-smmu) |
-| 29 | keyboard attached and typed line echoed (`keyboard: ready`, `keyboard_echo:`, `keyboard_line:`, `keyboard: done (enter)`) | KEYBOARD | NOT_RUN (MISSING_IMPLEMENTATION: no USB HID driver in the C kernel; the image prints `keyboard: hid NOT_IMPLEMENTED ...`) |
-| 30 | shell commands (`commands: help mem el report uptime exit`, `EL1`, `conventional_memory_kb:`, `keyboard: done (exit)`) | KEYBOARD | NOT_RUN (MISSING_IMPLEMENTATION: no console shell) |
-| 31 | xHCI bus master revoked after the phase (`dma_gate: xhci bus master revoked`) | KEYBOARD | NOT_RUN (pending forge receipt; C would be DIFFERS (stronger): the same line after `smmu_dma_window: xhci only, translation active ...` and `dma_gate: xhci granted (Confined), bus master on`, controller halted first (`xhci: halt before revoke ... halted=yes`), COMMAND read back `xhci_pci: after phase command=0x.... bus_master=off`, `smmu: xhci stream 0x.. returned to abort (rc=0)`, in that order and before `devices: xhci=fenced (rc=0)`; no HID phase runs between grant and revoke; boot kbd-smmu; mutation no-revoke) |
-| 32 | no panic or fault | KEYBOARD | NOT_RUN (pending forge receipt; C would be IDENTICAL: `report_kind: (panic\|fault)` absent, plus `report_kind: final`, QEMU exit 0 and every M1 check of scripts/lib_ck_m1_checks.sh, both boots) |
+| 25 | xHCI found before exit (`keyboard: xhci `) | KEYBOARD | QEMU PASS, DIFFERS: found after exit on the ECAM walk, class 0x0c0330, `keyboard: xhci 0000:BB:DD.F mmio 0x.. (found post-exit on the ECAM walk)`, all three boots |
+| 26 | bus-master sweep after exit (`dma_sweep: seg `, no `dma_sweep: bme STUCK`) | KEYBOARD | QEMU PASS, DIFFERS: same line text as Rust, and stricter: the sweep must come before the first `dma_gate: ` line and before `keyboard: xhci `; all three boots; mutation no-sweep |
+| 27 | xHCI bus master off before the DMA gate (`xhci_pci: command=0x.. bus_master=off`) | KEYBOARD | QEMU PASS, IDENTICAL prefix `xhci_pci: command=0x.... bus_master=off`, plus the order check: before `dma_gate: xhci `; all three boots; mutation bm-left-on |
+| 28 | fail-closed without SMMU (`dma_gate: xhci denied (NoSmmu)...`, `keyboard: unavailable (...)`, no grant, no `keyboard: ready`) | KEYBOARD | QEMU PASS, IDENTICAL lines `dma_gate: xhci denied (NoSmmu), bus master stays off` and `keyboard: unavailable (SMMU DMA isolation not active)`, absent `dma_gate: xhci granted` and `keyboard: ready`, plus C-only: COMMAND read back after the deny `bus_master=off`, no xHCI SMMU window; boot kbd-nosmmu; mutation grant-no-smmu |
+| 29 | keyboard attached and typed line echoed (`keyboard: ready`, `keyboard_echo:`, `keyboard_line:`, `keyboard: done (enter)`) | KEYBOARD | QEMU PASS, DIFFERS: same four line prefixes (`keyboard: ready (port P, slot S, endpoint 0x81)`, `keyboard_echo: abc`, `keyboard_line: abc`, `keyboard: done (enter)`), plus C-only order checks: attached after `dma_gate: xhci granted (Confined)` and the line before the revoke; boots kbd-smmu (and attach in kbd-recovery) |
+| 30 | shell commands (`commands: help mem el report uptime exit`, `EL1`, `conventional_memory_kb:`, `keyboard: done (exit)`) | KEYBOARD | QEMU PASS, IDENTICAL output texts (`commands: help mem el report uptime exit`, `EL1`, `conventional_memory_kb: N`, `keyboard: done (exit)`), plus exit before the revoke; boot kbd-smmu |
+| 30a | (C only) recovery window: no key means normal boot | KEYBOARD | C only, QEMU PASS: `recovery_access: waiting 5000 ms ...` after `keyboard: ready`, `recovery_access: choice=normal reason=timeout` before the shell, no recovery console (boot kbd-smmu); without an SMMU `recovery_access: unavailable (no operator keyboard: xhci=denied); choice=normal reason=no-keyboard` and no wait (boot kbd-nosmmu) |
+| 30b | (C only) key `r` selects the recovery console stub | KEYBOARD | C only, QEMU PASS: `recovery_access: choice=recovery reason=key-r` before the xHCI revoke, `devices: recovery halt nvme=released virtio_net=released xhci=released`, `recovery_console: identity build_sha256=<hex>` equal to the digest the script recomputes from the commit, `recovery_console: halted`, no shell, no Store stage, no final report, no panic, QEMU still running 3 s later (halted, not reset); boot kbd-recovery |
+| 30c | (C only) overlong line fails closed | KEYBOARD | C only, QEMU PASS: 65 keys then Enter gives `keyboard_line: overflow (line refused: 65 keys typed, limit 64)` and `keyboard: done (overflow)`; no `keyboard_line:` with that text and no command run from it; boot kbd-smmu (Rust silently truncates instead) |
+| 31 | xHCI bus master revoked after the phase (`dma_gate: xhci bus master revoked`) | KEYBOARD | QEMU PASS, DIFFERS (stronger): the same line after `smmu_dma_window: xhci only, translation active ...` and `dma_gate: xhci granted (Confined), bus master on`, controller halted first (`xhci: halt before revoke ... halted=yes`), COMMAND read back `xhci_pci: after phase command=0x.... bus_master=off`, `smmu: xhci stream 0x.. returned to abort (rc=0)`, in that order and before the end of the xHCI phase; boots kbd-smmu and kbd-recovery; mutation no-revoke |
+| 32 | no panic or fault | KEYBOARD | QEMU PASS, IDENTICAL: `report_kind: (panic\|fault)` absent, plus `report_kind: final`, QEMU exit 0 and every M1 check of scripts/lib_ck_m1_checks.sh; boots kbd-smmu and kbd-nosmmu |
 
 ## SEED-0B / P2-5 artifact loader: scripts/qemu_artifact_test.sh -> CK `P2_ARTIFACT` (scripts/qemu_ck_artifact_test.sh)
 
@@ -518,7 +545,7 @@ corruption is covered only by the host test `dev/tests/disk_part_test.c`
 
 ## Summary counts
 
-**C kernel receipt tally (QEMU only, no physical run):** Newest: `evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json` (full `ck_gates.sh` at 640522a, ALLEN native genesis branch, 20 CK gates with `M4_ALLEN`): 15 PASS, 0 FAIL, 5 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION; FPU, INFER, SCREEN: the shared QEMU gate lock was held by another run). Before it: `evidence/ck_gates_ad05e004e30237e57e72fc1d3362cfe2b31af9b99451d9d2bb2414238e4d6590.json` (full `ck_gates.sh` at 2e44c0b, L6-C branch, 19 CK gates with `SCREEN`): 17 PASS, 0 FAIL, 2 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION). Earlier: 16 CK gates since the merge of main 8555049 (#224 adds `SMP`, #226 moves `M4_STORE_CRASH` to its own child script) into the CK-4 branch. The newest full receipt, `evidence/ck_gates_d80363cc871372963743ae85fc08c6fa4608f9870c4e06e8988f21950c73ace6.json` (full `ck_gates.sh` run at 741b2b8, the CK-4 branch after merging main #221 and #225; log CK-4-184524.log, `AIENOS_CK_GATES: NOT_ALL_GATES_PASS (pass=10 fail=0 not_run=5 of 15; physical NOT_RUN)`), predates that merge: by it, 10 of 16 CK gates PASS (the 9 of the earlier receipt plus `DISK_LAYOUT`), 6 NOT_RUN (M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD; and SMP, not in that receipt, NOT_RUN pending forge receipt), 0 FAIL. No `ck_gates.sh` run exists at the merged head yet; `M4_STORE_CRASH` stays NOT_RUN until a forge receipt. `DISK_LAYOUT` also PASSed alone (log CK-4-184423.log, translation-bypass mutant killed); the Store, NET and artifact gates boot GPT images now and PASS in the same receipt. The receipt before it was 9 of 14 CK gates PASS, 5 NOT_RUN, 0 FAIL (`evidence/ck_gates_929f287e9c950c45c7dcd569c7caa03709ea62ecfe393635b435058afa969c54.json`, run at 41aa0e6, which adds the kernel entropy rows 107-109; that commit was then rebased onto #210, which changed only README.md and CONTRIBUTING.md). The row counts below are per Rust-parity row, not per gate.
+**C kernel receipt tally (QEMU only, no physical run):** Newest: `evidence/ck_gates_bc306a04d8ba513b2364fbee644f37375dc686ccead97c8759191b76ebec94eb.json` (full `ck_gates.sh` at f921666, NEXT-PHASE-3 cut 1 branch, KEYBOARD from its own child): 19 PASS, 0 FAIL, 1 NOT_RUN (M0_ROLLBACK: MISSING_IMPLEMENTATION); KEYBOARD PASS (rows 25-32 and C-only 30a-30c, QEMU only, hardware NOT_RUN). Baseline for that change, same runner on main 2058747: `evidence/ck_gates_79a843817161b68d71889201bd4407a3b4e432ac808503b017836f71abc3f2db.json`: 18 PASS, 0 FAIL, 2 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION). Rows 25-32 move from NOT_RUN to QEMU PASS (8 rows: IDENTICAL 4, DIFFERS 4 by their parity labels) and C-only rows 30a-30c are added as QEMU PASS; the older row recounts below predate this change. Before it: `evidence/ck_gates_1ecf5bcd303bf88422dd0542f14851c931f5d52276838fa182c812f3c73f3c1b.json` (full `ck_gates.sh` at 640522a, ALLEN native genesis branch, 20 CK gates with `M4_ALLEN`): 15 PASS, 0 FAIL, 5 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION; FPU, INFER, SCREEN: the shared QEMU gate lock was held by another run). Before it: `evidence/ck_gates_ad05e004e30237e57e72fc1d3362cfe2b31af9b99451d9d2bb2414238e4d6590.json` (full `ck_gates.sh` at 2e44c0b, L6-C branch, 19 CK gates with `SCREEN`): 17 PASS, 0 FAIL, 2 NOT_RUN (M0_ROLLBACK, KEYBOARD: MISSING_IMPLEMENTATION). Earlier: 16 CK gates since the merge of main 8555049 (#224 adds `SMP`, #226 moves `M4_STORE_CRASH` to its own child script) into the CK-4 branch. The newest full receipt, `evidence/ck_gates_d80363cc871372963743ae85fc08c6fa4608f9870c4e06e8988f21950c73ace6.json` (full `ck_gates.sh` run at 741b2b8, the CK-4 branch after merging main #221 and #225; log CK-4-184524.log, `AIENOS_CK_GATES: NOT_ALL_GATES_PASS (pass=10 fail=0 not_run=5 of 15; physical NOT_RUN)`), predates that merge: by it, 10 of 16 CK gates PASS (the 9 of the earlier receipt plus `DISK_LAYOUT`), 6 NOT_RUN (M0_ROLLBACK, M4_STORE_CRASH, M4_CONTINUITY, M4_RECOVERY, KEYBOARD; and SMP, not in that receipt, NOT_RUN pending forge receipt), 0 FAIL. No `ck_gates.sh` run exists at the merged head yet; `M4_STORE_CRASH` stays NOT_RUN until a forge receipt. `DISK_LAYOUT` also PASSed alone (log CK-4-184423.log, translation-bypass mutant killed); the Store, NET and artifact gates boot GPT images now and PASS in the same receipt. The receipt before it was 9 of 14 CK gates PASS, 5 NOT_RUN, 0 FAIL (`evidence/ck_gates_929f287e9c950c45c7dcd569c7caa03709ea62ecfe393635b435058afa969c54.json`, run at 41aa0e6, which adds the kernel entropy rows 107-109; that commit was then rebased onto #210, which changed only README.md and CONTRIBUTING.md). The row counts below are per Rust-parity row, not per gate.
 
 Rows 118-123 (DISK_LAYOUT, C-only, CK-4; numbered 113-118 on the CK-4 branch before the merge with main, which gave 113-117 to SMP) are 5 QEMU PASS (118-122, receipt `ck_gates_d80363...` at 741b2b8, before the merge with main 8555049) and 1 host-test PASS (123), none NOT_RUN. With them, rows 1-123 plus the M4 continuity/recovery sub-rows: IDENTICAL 28, DIFFERS 39, NOT_RUN 91, PASS 6 (C-only DISK_LAYOUT, hardware NOT_RUN) (91 from the SMP line next; recounted from the table at the merge commit, status = each row's first status cell, escaped pipes read as text: 28 IDENTICAL, 39 DIFFERS, 87 NOT_RUN (82 + SMP 113-117), 9 QEMU PASS (NET 102, 110-112, counted as NOT_RUN as below, and DISK_LAYOUT 118-122), 1 PASS (123); sub-rows 24a and 24b not counted).
 
diff --git a/native/kernel/README.md b/native/kernel/README.md
index ec883a60..0e0893d4 100644
--- a/native/kernel/README.md
+++ b/native/kernel/README.md
@@ -95,6 +95,137 @@ The kernel is partition-unaware. At every boot it writes and restores the last
 areas hold the protective MBR, the primary GPT and the backup GPT. Details and
 the operator-facing warning: `docs/TRUST-1-OPERATOR-STEPS.md`.
 
+## Operator input and recovery access (C kernel)
+
+Status: **QEMU only.** CK gate `KEYBOARD` (rows 25-32 and 30a-30c in
+`GATES.md`) runs in QEMU; no physical keyboard, xHCI controller or SMMU has
+been exercised by this code. Hardware NOT_RUN.
+
+What is implemented (NEXT-PHASE-3 cut 1):
+
+- **Device discovery.** The devices stage finds the USB host controller on
+  the PCI ECAM walk by class code 0x0c0330 (xHCI), after ExitBootServices and
+  after the bus-master sweep. It gets DMA only through the xHCI DMA fence
+  (`dev/xhci_fence.c`): SMMU window first, no SMMU means no DMA. Then
+  `dev/usb_kbd.c` resets the controller, finds the first connected port with
+  a USB HID boot keyboard, addresses it, configures its interrupt IN
+  endpoint and polls it. Polled only: no interrupts, no scheduler, no Store.
+- **Key decode** to one small fixed US keymap (`dev/usb_hid.c`): a-z (with
+  Shift: A-Z), 0-9, space, `-`, `.`, `/`, Enter, Backspace, Escape. Every
+  other key is ignored. A held key produces one event, not a repeat.
+- **Line input** with echo and a bound of 64 characters. One key past the
+  bound makes the whole line fail closed: at Enter it is refused
+  (`keyboard_line: overflow (line refused: N keys typed, limit 64)`) and never
+  run. The Rust shell drops the extra keys instead; this is the one deliberate
+  difference. The line feeds the same six commands as the Rust shell: `help`,
+  `mem`, `el`, `report`, `uptime`, `exit`.
+- **Recovery-access hook.** Right after the keyboard is ready the kernel
+  prints `recovery_access: waiting 5000 ms for an operator key (r = recovery
+  console; any other key or no key = normal boot)` and records the first key:
+  `r` gives `recovery_access: choice=recovery reason=key-r`, any other key
+  gives `choice=normal reason=other-key`, no key gives `choice=normal
+  reason=timeout`. Without a usable keyboard it prints `recovery_access:
+  unavailable (no operator keyboard: xhci=<state>); choice=normal
+  reason=no-keyboard` and does not wait.
+- **Recovery console: a stub.** On `r` the xHCI is halted and fenced, then
+  the NVMe and virtio-net DMA are released, then the screen shows
+  `recovery_console: STUB ...`, `recovery_console: identity
+  build_sha256=<64 hex> commit=<commit> (image build identity; not an owner
+  or machine identity)` and `recovery_console: halted (no device DMA live;
+  power-cycle to leave)`. The digest is SHA-256 over
+  `AIENOS-CK-RECOVERY-IDENTITY-V1`, one zero byte, and the commit the image
+  was built from, so anyone can recompute it from the commit. The CPU then
+  stops for good. It never touches the disk and has no commands.
+
+Bus. The Rust kernel and both QEMU gates use a PCI xHCI controller
+(`qemu-xhci`, class 0x0c0330) with a `usb-kbd` attached. The C driver looks
+only there.
+
+**The Spark's USB controllers are not on PCI.** Read on this Spark under
+Ubuntu on 2026-10-05 (sysfs, read-only): no PCI function has class 0x0c03.
+The USB buses hang off six ACPI platform devices, `NVDA8000:00` to
+`NVDA8000:04` and `NVDA8001:00`, bound by Linux `xhci_plat_hcd` through the
+ACPI id `PNP0D15` (an xHCI controller), each behind the SMMUv3 at
+0x13800000. The DGX Spark hardware guide lists four USB Type-C ports on the
+rear panel and is silent on the controller behind them. Consequence
+(INFERRED, high confidence): on the Spark this cut finds no controller and
+prints `keyboard: unavailable (no xHCI controller)` and `recovery_access:
+unavailable (no operator keyboard: xhci=absent); choice=normal
+reason=no-keyboard`. The xHCI register work in `dev/usb_kbd.c` follows the
+xHCI specification and should carry over (UNVERIFIED, medium confidence),
+but the Spark needs discovery from the ACPI tables (DSDT `PNP0D15` devices
+and their IORT stream ids) instead of the PCI walk. That is the next cut,
+not this one. Which of the six controllers serves which rear port is
+UNKNOWN.
+
+### Physical attended boot: what it will look like
+
+Do not run this until two things exist, because without them the run proves
+only the "no keyboard" line above: (1) ACPI discovery of the Spark's
+platform xHCI controllers, and (2) a staging command for the full hardware
+image (today `scripts/stage_one_time_boot_ck.sh` stages only the inference
+image, which has no devices stage and so no keyboard). The steps below are
+the procedure that run will follow, so it can be reviewed now.
+
+Ground rules: nothing here changes firmware settings, Secure Boot keys or the
+TPM. The boot is one-time (BootNext): the next restart returns to Ubuntu on
+its own. If anything looks different from "What you should see", write down
+or photograph the screen and hand it to the orchestrator. Do not retry or
+improvise.
+
+1. **Plug in.** At the Spark, with Ubuntu running:
+   - the HDMI monitor on the rear HDMI port (the kernel writes to the screen;
+     there is no other console you can see);
+   - a plain wired USB keyboard in one rear USB Type-C port (use a USB-A to
+     USB-C adapter if needed; a wireless or Bluetooth keyboard will not work,
+     and a keyboard with a built-in hub may not);
+   - the AIENOSRECOV recovery stick, so the firmware's recovery entry
+     (Boot0004) is there if anything goes wrong.
+
+   *You should see:* nothing changes on screen yet.
+
+2. **Stage the one-time boot** with the staging command the orchestrator
+   names for that run (it will be a `--dry-run` first, then `--apply`, in the
+   style of `scripts/stage_one_time_boot_ck.sh`). *Changes:* it copies the
+   image to the EFI system partition and sets BootNext once; it never
+   reboots. *You should see:* the dry run's list of commands, then the apply
+   ending without `FAIL`.
+
+3. **Restart** with `sudo reboot`. Do not touch the keyboard until the screen
+   shows AIENOS lines (white text on black, starting with the boot report).
+
+4. **Normal boot (do nothing).** Watch for, in order:
+   `keyboard: xhci ...`, `dma_gate: xhci granted (Confined), bus master on`,
+   `keyboard: ready (port P, slot S, endpoint 0x81)`, then
+   `recovery_access: waiting 5000 ms ...`. Keep your hands off for those 5
+   seconds. *You should see:* `recovery_access: choice=normal reason=timeout`,
+   then `keyboard: shell ready` and the prompt `aienos> `.
+
+5. **Type a line.** Type `help` and press Enter. *You should see:* the
+   letters appear as you type, then `keyboard_line: help` and `commands: help
+   mem el report uptime exit`. Type `exit` and press Enter. *You should see:*
+   `keyboard: done (exit)`, `dma_gate: xhci bus master revoked`, and later
+   `report_kind: final`. The screen holds the last report, then the Spark
+   restarts into Ubuntu by itself.
+
+6. **Recovery boot (second attended boot, staged again as in step 2).** This
+   time, as soon as `recovery_access: waiting 5000 ms ...` appears, press
+   `r` once. *You should see:* `recovery_access: choice=recovery
+   reason=key-r`, `devices: recovery halt nvme=released
+   virtio_net=released xhci=released`, `recovery_console: STUB ...`,
+   `recovery_console: identity build_sha256=<64 hex> commit=<commit>` and
+   `recovery_console: halted (no device DMA live; power-cycle to leave)`. The
+   machine then stays on that screen. Photograph it. Then hold the power
+   button until the Spark turns off, wait ten seconds, and press it again.
+   *You should see:* Ubuntu starts as usual (BootNext was used up).
+
+What success looks like: steps 4 to 6 show exactly those lines, the identity
+digest on the photo equals the one the orchestrator recomputes from the
+commit, and Ubuntu comes back after each boot with nothing changed on its
+disk. Any `report_kind: panic` or `report_kind: fault`, a missing
+`bus master revoked` line, or a keyboard that is ready but ignores typing is
+a FAIL to report, not to retry.
+
 ## Boot sequence
 
 1. UEFI stub: pre-exit report on ConOut, memory map, `ExitBootServices`.
diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb
index 153a0395..ff5d2c4c 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-04T17:01:01Z",
+      "compiled_at": "2026-10-06T01:02:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:dd6ebb445202c084d41a923774ff81d2c0c384393b7383c92ed09e77028d2307",
+      "digest": "sha256:e5ebaf34e03225eabc74a1b335f9aea4635942690cd0d8aeb22cfa6addd4e833",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 28,
-      "generated_at_commit": "1e28ff5b9ba3193a14e6063175d81e39d545e11f",
-      "source_tree": "sha256:604b927e35574ac0641a25f1901ac114185120b7801fb3f036fbd59a1fa413fc"
+      "generated_at_commit": "20587476bf0d4b7577cc3b62857a9166300681bf",
+      "source_tree": "sha256:d856e6b4eb46f3348ada53d964701e8a69c5f58a832db6c0265c9e49e3e43d2f"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/core/kmain.c b/native/kernel/core/kmain.c
index e6c4df95..e13001fb 100644
--- a/native/kernel/core/kmain.c
+++ b/native/kernel/core/kmain.c
@@ -12,12 +12,29 @@
 #include "ck_internal.h"
 #include "entropy.h"
 #include "handoff_check.h"
+#include "frames.h"
 
 #define TTBR_BADDR_MASK 0x0000fffffffffffeull
 
 static struct ck_handoff *hand;
 const struct ck_handoff *ck_handoff_get(void) { return hand; }
 
+/* ck.h operator shell facts. The conventional-memory total is summed once at
+ * kernel entry, while the firmware memory-map copy is still reachable. */
+static uint64_t conventional_kb;
+unsigned ck_exception_level(void) { return ck_current_el(); }
+uint64_t ck_conventional_memory_kb(void) { return conventional_kb; }
+static void sum_conventional(const struct ck_handoff *h)
+{
+    uint64_t pages = 0;
+    if (!h->memory_map || h->desc_size < sizeof(struct ck_efi_desc)) return;
+    for (uint64_t off = 0; off + h->desc_size <= h->map_size; off += h->desc_size) {
+        const struct ck_efi_desc *d = (const struct ck_efi_desc *)(uintptr_t)(h->memory_map + off);
+        if (d->type == CK_EFI_CONVENTIONAL && d->pages <= (1ull << 36)) pages += d->pages;
+    }
+    conventional_kb = pages * 4u;
+}
+
 const void *ck_acpi_find(const char sig[4])
 {
     return hand && hand->rsdp ? ck_acpi_lookup(hand->rsdp, sig) : 0;
@@ -224,6 +241,7 @@ void ck_kernel_entry(struct ck_handoff *h)
     const char *why;
     if (ck_handoff_check(h, &why) != 0)
         ck_panic("handoff: %s", why);
+    sum_conventional(h);
     ck_psci_configure(ck_acpi_find("FACP"));
     ck_set_stage("mm_build");
     uint64_t sp = ck_mm_build(h);
diff --git a/native/kernel/dev/.crumb b/native/kernel/dev/.crumb
index 69e42bfc..8546283f 100644
--- a/native/kernel/dev/.crumb
+++ b/native/kernel/dev/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-04T13:47:18Z",
+      "compiled_at": "2026-10-06T01:02:24Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:23eaffd404d1c16455030fd1c27ba14fa3311714528b336db3f59451e880819e",
+      "digest": "sha256:914c089b5c7d4cf9f5ffd86440ae5a8250bb7e518c497aa65e9829797b1f1e57",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 20,
-      "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512",
-      "source_tree": "sha256:d109060ee90c91766fca39f05860ca5c651a4f43cadb0e188e9cf83acc05d5b6"
+      "files": 24,
+      "generated_at_commit": "0a3c4a4561b78f46b992596dbbf4cee446c8c9a1",
+      "source_tree": "sha256:811db9300c61e8a70dce6db0476745c17c1d860495c8921f4dd96470ebffd6cd"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/dev/devices.c b/native/kernel/dev/devices.c
index efe141ca..03ab5b2f 100644
--- a/native/kernel/dev/devices.c
+++ b/native/kernel/dev/devices.c
@@ -7,6 +7,7 @@
 #include "virtio_net.h"
 #include "net_bind.h"
 #include "xhci_fence.h"
+#include "usb_kbd.h"
 
 static pci_system g_pci;
 static ck_nvme g_nvme;
@@ -64,11 +65,23 @@ int ck_stage_devices(void)
     int netrc = (vrc == 0 && vf) ? ck_net_bind_selftest(vf, &caps) : 1;
     ck_printf("devices: pci=ok nvme=%s virtio_net=%s\n", g_nvme.bound ? "bound" : "unbound",
               vrc != 0 ? "caps-refused" : !vf ? "absent" : netrc == 0 ? "selftest-ok" : "selftest-failed");
-    /* xHCI: DMA fence only (bus master off before the gate, SMMU-confined grant
-     * or fail-closed deny, halt, revoke, stream back to abort); no USB HID
-     * driver yet. Reported, never a devices-stage failure. */
+    /* xHCI: DMA fence (bus master off before the gate, SMMU-confined grant or
+     * fail-closed deny, halt, revoke, stream back to abort) with the operator
+     * keyboard phase inside the grant (usb_kbd.c). Reported, never a
+     * devices-stage failure. */
     int xrc = ck_xhci_fence(&g_pci);
     ck_printf("devices: xhci=%s (rc=%d)\n", ck_xhci_state(), xrc);
+    ck_kbd_recovery_report(ck_xhci_state());
+    if (ck_kbd_recovery_requested()) {
+        /* Recovery access chosen: the xHCI is already revoked; release every
+         * other device's DMA before the stub halts (no Store stage runs). */
+        if (ck_net_live()) ck_net_release();
+        ck_dev_nvme_release();
+        ck_printf("devices: recovery halt nvme=%s virtio_net=%s xhci=%s\n", g_nvme.bm_on || g_nvme.confined ? "LIVE" : "released",
+                  ck_net_live() ? "LIVE" : "released", ck_xhci_live() ? "LIVE" : "released");
+        if (!g_nvme.bm_on && !g_nvme.confined && !ck_net_live() && !ck_xhci_live()) ck_recovery_console_stub();
+        ck_panic("recovery access: device DMA still live, refusing to halt with it");
+    }
     if (nrc == -1) return 0;  /* no NVMe present: not a devices failure; Store reports it */
     return nrc;
 }
diff --git a/native/kernel/dev/usb_hid.c b/native/kernel/dev/usb_hid.c
new file mode 100644
index 00000000..f6372c0c
--- /dev/null
+++ b/native/kernel/dev/usb_hid.c
@@ -0,0 +1,231 @@
+/* usb_hid.c -- operator input pure logic (see usb_hid.h). Freestanding. */
+#include "usb_hid.h"
+#include "sha256.h"
+
+#define USAGE_ENTER 0x28u
+#define USAGE_ESCAPE 0x29u
+#define USAGE_BACKSPACE 0x2au
+#define USAGE_SPACE 0x2cu
+#define USAGE_MINUS 0x2du
+#define USAGE_PERIOD 0x37u
+#define USAGE_SLASH 0x38u
+#define MOD_ANY_SHIFT 0x22u /* left shift bit 1, right shift bit 5 */
+
+ck_key_event ck_hid_usage(uint8_t usage, int shift)
+{
+    ck_key_event ev = {CK_KEY_NONE, 0};
+    if (usage >= 0x04 && usage <= 0x1d) { /* a..z */
+        ev.kind = CK_KEY_CHAR;
+        ev.c = (char)((shift ? 'A' : 'a') + (usage - 0x04));
+    } else if (usage >= 0x1e && usage <= 0x27) { /* 1..9, 0 */
+        if (shift) return ev;
+        ev.kind = CK_KEY_CHAR;
+        ev.c = usage == 0x27 ? '0' : (char)('1' + (usage - 0x1e));
+    } else if (usage == USAGE_ENTER) {
+        ev.kind = CK_KEY_ENTER;
+    } else if (usage == USAGE_ESCAPE) {
+        ev.kind = CK_KEY_ESCAPE;
+    } else if (usage == USAGE_BACKSPACE) {
+        ev.kind = CK_KEY_BACKSPACE;
+    } else if (!shift && (usage == USAGE_SPACE || usage == USAGE_MINUS || usage == USAGE_PERIOD || usage == USAGE_SLASH)) {
+        ev.kind = CK_KEY_CHAR;
+        ev.c = usage == USAGE_SPACE ? ' ' : usage == USAGE_MINUS ? '-' : usage == USAGE_PERIOD ? '.' : '/';
+    }
+    return ev;
+}
+
+unsigned ck_hid_decode(ck_hid_decoder *d, const uint8_t *report, size_t len, ck_key_event out[CK_HID_MAX_KEYS])
+{
+    if (!d || !report || len != CK_HID_REPORT_LEN) return 0;
+    const uint8_t *u = report + 2;
+    if (u[0] == 0x01) return 0; /* ErrorRollOver: keep the previous state */
+    int shift = (report[0] & MOD_ANY_SHIFT) != 0;
+    unsigned n = 0;
+    for (unsigned i = 0; i < CK_HID_MAX_KEYS; i++) {
+        if (u[i] == 0) continue;
+        int held = 0;
+        for (unsigned j = 0; j < CK_HID_MAX_KEYS; j++) held |= d->previous[j] == u[i];
+        if (held) continue;
+        ck_key_event ev = ck_hid_usage(u[i], shift);
+        if (ev.kind != CK_KEY_NONE) out[n++] = ev;
+    }
+    for (unsigned i = 0; i < CK_HID_MAX_KEYS; i++) d->previous[i] = u[i];
+    return n;
+}
+
+int ck_usb_find_boot_kbd(const uint8_t *b, size_t len, ck_boot_kbd *out)
+{
+    if (!b || !out || len < 9 || b[0] < 9 || b[1] != 2) return -1;
+    size_t total = (size_t)b[2] | ((size_t)b[3] << 8);
+    if (total > len) total = len;
+    uint8_t configuration = b[5];
+    int iface = -1;
+    size_t at = 0;
+    while (at + 2 <= total) {
+        size_t l = b[at];
+        if (l < 2 || at + l > total) return -1;
+        const uint8_t *d = b + at;
+        if (d[1] == 4 && l >= 9) { /* interface */
+            iface = (d[5] == 3 && d[6] == 1 && d[7] == 1) ? d[2] : -1;
+        } else if (d[1] == 5 && l >= 7) { /* endpoint */
+            if (iface >= 0 && (d[2] & 0x80u) && (d[3] & 0x3u) == 3u) {
+                out->configuration = configuration;
+                out->interface = (uint8_t)iface;
+                out->endpoint = d[2];
+                out->max_packet = (uint16_t)(((unsigned)d[4] | ((unsigned)d[5] << 8)) & 0x7ffu);
+                out->interval = d[6];
+                return out->max_packet ? 0 : -1;
+            }
+        }
+        at += l;
+    }
+    return -1;
+}
+
+void ck_line_reset(ck_line *l)
+{
+    for (unsigned i = 0; i <= CK_LINE_CAP; i++) l->buf[i] = 0;
+    l->len = 0;
+    l->typed = 0;
+    l->overflow = 0;
+}
+
+int ck_line_feed(ck_line *l, ck_key_event ev, void (*echo)(char c))
+{
+    switch (ev.kind) {
+    case CK_KEY_CHAR:
+        l->typed++;
+        if (l->len >= CK_LINE_CAP) {
+            l->overflow = 1; /* fail closed: this line will be refused at Enter */
+            return CK_LINE_MORE;
+        }
+        l->buf[l->len++] = ev.c;
+        l->buf[l->len] = 0;
+        if (echo) echo(ev.c);
+        return CK_LINE_MORE;
+    case CK_KEY_BACKSPACE:
+        if (l->len > 0 && !l->overflow) {
+            l->buf[--l->len] = 0;
+            if (echo) echo('\b');
+        }
+        return CK_LINE_MORE;
+    case CK_KEY_ESCAPE:
+        ck_line_reset(l);
+        return CK_LINE_MORE;
+    case CK_KEY_ENTER:
+        if (l->overflow) {
+            unsigned typed = l->typed;
+            ck_line_reset(l);
+            l->typed = typed; /* reported by the caller, then reset again */
+            l->overflow = 1;
+            return CK_LINE_OVERFLOW;
+        }
+        l->buf[l->len] = 0;
+        return CK_LINE_DONE;
+    default:
+        return CK_LINE_MORE;
+    }
+}
+
+static int is_space(char c) { return c == ' ' || c == '\t'; }
+static int word_is(const char *w, size_t n, const char *lit)
+{
+    size_t i = 0;
+    for (; i < n; i++)
+        if (lit[i] == 0 || lit[i] != w[i]) return 0;
+    return lit[i] == 0;
+}
+
+/* Splits like Rust split_ascii_whitespace; first and flen give the first word. */
+static int parse(const char *s, size_t len, const char **first, size_t *flen)
+{
+    if (len > CK_LINE_CAP) return CK_SH_INVALID;
+    const char *w[3] = {0, 0, 0};
+    size_t wl[3] = {0, 0, 0};
+    unsigned nw = 0;
+    size_t i = 0;
+    while (i < len) {
+        while (i < len && is_space(s[i])) i++;
+        if (i >= len) break;
+        size_t st = i;
+        while (i < len && !is_space(s[i])) i++;
+        if (nw == 2) return CK_SH_INVALID; /* a third word */
+        w[nw] = s + st;
+        wl[nw] = i - st;
+        nw++;
+    }
+    if (nw == 0) return CK_SH_EMPTY;
+    if (wl[0] > 16 || (nw == 2 && wl[1] > 16)) return CK_SH_INVALID;
+    *first = w[0];
+    *flen = wl[0];
+    if (word_is(w[0], wl[0], "help")) return CK_SH_HELP;
+    if (word_is(w[0], wl[0], "mem")) return CK_SH_MEM;
+    if (word_is(w[0], wl[0], "el")) return CK_SH_EL;
+    if (word_is(w[0], wl[0], "report")) return CK_SH_REPORT;
+    if (word_is(w[0], wl[0], "uptime")) return CK_SH_UPTIME;
+    if (word_is(w[0], wl[0], "exit")) return CK_SH_EXIT;
+    return CK_SH_UNKNOWN;
+}
+
+int ck_shell_parse(const char *line, size_t len)
+{
+    const char *f = 0;
+    size_t fl = 0;
+    return parse(line, len, &f, &fl);
+}
+
+int ck_shell_run(const char *line, const ck_shell_ctx *ctx, void (*out)(const char *fmt, ...))
+{
+    size_t len = 0;
+    while (line[len] && len <= CK_LINE_CAP) len++;
+    const char *f = 0;
+    size_t fl = 0;
+    switch (parse(line, len, &f, &fl)) {
+    case CK_SH_HELP: out("commands: help mem el report uptime exit\n"); return 0;
+    case CK_SH_MEM: out("conventional_memory_kb: %llu\n", (unsigned long long)ctx->conventional_memory_kb); return 0;
+    case CK_SH_EL: out("EL%u\n", ctx->exception_level); return 0;
+    case CK_SH_REPORT:
+        out("report_kind: shell\naienos_commit: %s\nkernel: C (native/kernel)\n", ctx->commit ? ctx->commit : "unknown");
+        return 0;
+    case CK_SH_UPTIME: out("uptime_ms: %llu\n", (unsigned long long)ctx->uptime_ms); return 0;
+    case CK_SH_EXIT: return 1;
+    case CK_SH_UNKNOWN: {
+        char name[17];
+        size_t i = 0;
+        for (; i < fl && i < 16; i++) name[i] = f[i];
+        name[i] = 0;
+        out("unknown command: %s\n", name);
+        return 0;
+    }
+    default: out("invalid command line\n"); return 0;
+    }
+}
+
+int ck_recovery_decide(int have_key, ck_key_event ev)
+{
+    if (!have_key) return CK_RECOVERY_NORMAL_TIMEOUT;
+    if (ev.kind == CK_KEY_CHAR && (ev.c == 'r' || ev.c == 'R')) return CK_RECOVERY_CONSOLE;
+    return CK_RECOVERY_NORMAL_KEY;
+}
+
+const char *ck_recovery_name(int choice)
+{
+    switch (choice) {
+    case CK_RECOVERY_CONSOLE: return "recovery reason=key-r";
+    case CK_RECOVERY_NORMAL_KEY: return "normal reason=other-key";
+    default: return "normal reason=timeout";
+    }
+}
+
+void ck_recovery_identity(const char *commit, uint8_t out[32])
+{
+    static const char dom[] = "AIENOS-CK-RECOVERY-IDENTITY-V1"; /* hashed with its NUL */
+    sha256_ctx c;
+    sha256_init(&c);
+    sha256_update(&c, (const uint8_t *)dom, sizeof dom);
+    size_t n = 0;
+    if (commit)
+        while (commit[n] && n < 64) n++;
+    sha256_update(&c, (const uint8_t *)(commit ? commit : ""), n);
+    sha256_final(&c, out);
+}
diff --git a/native/kernel/dev/usb_hid.h b/native/kernel/dev/usb_hid.h
new file mode 100644
index 00000000..573d37e9
--- /dev/null
+++ b/native/kernel/dev/usb_hid.h
@@ -0,0 +1,103 @@
+/* usb_hid.h -- pure logic of the C kernel operator input (no MMIO, host
+ * tested in svc/tests/stage_test.c): USB HID boot-keyboard report decode to a
+ * small fixed keymap, the configuration-descriptor walk that finds a boot
+ * keyboard, the operator line editor (bounded, fails closed on overflow), the
+ * console shell commands of the Rust SEED-0A keyboard gate, and the
+ * recovery-access key decision.
+ *
+ * Behaviour follows the Rust reference where the Rust gate
+ * (scripts/qemu_keyboard_test.sh) observes it: crates/aienos-kernel/src/usb/
+ * hid.rs (BootKeyboardDecoder: an event per newly pressed usage, rollover
+ * reports ignored), usb/descriptor.rs (find_boot_keyboard) and shell.rs
+ * (LINE_CAPACITY 64, TOKEN_CAPACITY 16, commands help mem el report uptime
+ * exit). One deliberate difference: the Rust line silently drops keys past
+ * its capacity; this editor refuses the whole line instead (fail closed).
+ * Freestanding. QEMU is not hardware: nothing here is physically qualified. */
+#ifndef AIENOS_CK_USB_HID_H
+#define AIENOS_CK_USB_HID_H
+#include <stddef.h>
+#include <stdint.h>
+
+/* ---- HID boot keyboard report (HID 1.11 appendix B.1) ---- */
+#define CK_HID_REPORT_LEN 8u
+#define CK_HID_MAX_KEYS 6u
+enum ck_key_kind { CK_KEY_NONE = 0, CK_KEY_CHAR, CK_KEY_ENTER, CK_KEY_BACKSPACE, CK_KEY_ESCAPE };
+typedef struct {
+    uint8_t kind; /* enum ck_key_kind */
+    char c;       /* CK_KEY_CHAR only */
+} ck_key_event;
+typedef struct {
+    uint8_t previous[CK_HID_MAX_KEYS];
+} ck_hid_decoder;
+
+/* Fixed keymap (US layout, the only one): usages a-z (shift: A-Z), 1-0,
+ * space, '-', '.', '/', Enter, Backspace, Escape. Every other usage, and
+ * shifted digits or punctuation, yields nothing. */
+ck_key_event ck_hid_usage(uint8_t usage, int shift);
+/* Decode one 8-byte report: one event per usage that was not pressed in the
+ * previous report (key repeat is not generated). A phantom/rollover report
+ * (first usage 0x01) and a report of the wrong length change nothing.
+ * Returns the number of events written to out (at most CK_HID_MAX_KEYS). */
+unsigned ck_hid_decode(ck_hid_decoder *d, const uint8_t *report, size_t len, ck_key_event out[CK_HID_MAX_KEYS]);
+
+/* ---- configuration descriptor: first boot keyboard ---- */
+typedef struct {
+    uint8_t configuration;   /* bConfigurationValue */
+    uint8_t interface;       /* bInterfaceNumber of class 3 / subclass 1 / protocol 1 */
+    uint8_t endpoint;        /* bEndpointAddress of its first interrupt IN endpoint */
+    uint16_t max_packet;     /* wMaxPacketSize bits 10:0 */
+    uint8_t interval;        /* bInterval */
+} ck_boot_kbd;
+/* 0 and *out filled, or -1 (no boot keyboard interface with an interrupt IN
+ * endpoint, or a malformed descriptor: every length is bounds checked, the
+ * walk never reads past min(len, wTotalLength)). */
+int ck_usb_find_boot_kbd(const uint8_t *cfg, size_t len, ck_boot_kbd *out);
+
+/* ---- operator line editor ---- */
+#define CK_LINE_CAP 64u /* Rust shell LINE_CAPACITY */
+enum { CK_LINE_MORE = 0, CK_LINE_DONE = 1, CK_LINE_OVERFLOW = 2 };
+typedef struct {
+    char buf[CK_LINE_CAP + 1];
+    unsigned len;
+    unsigned typed;   /* printable keys typed into this line, kept or not */
+    int overflow;     /* a key arrived with the buffer full: line refused */
+} ck_line;
+void ck_line_reset(ck_line *l);
+/* Feed one key. Printable keys are appended and echoed (echo(c) for the
+ * character, echo('\b') for a rubbed-out one; echo may be NULL). Enter ends
+ * the line: CK_LINE_DONE with buf NUL-terminated, or CK_LINE_OVERFLOW when
+ * any key was lost to the bound (the line is then emptied and must not be
+ * used). Escape clears the line. */
+int ck_line_feed(ck_line *l, ck_key_event ev, void (*echo)(char c));
+
+/* ---- console shell (Rust shell.rs commands) ---- */
+enum { CK_SH_INVALID = -1, CK_SH_UNKNOWN = 0, CK_SH_HELP, CK_SH_MEM, CK_SH_EL, CK_SH_REPORT, CK_SH_UPTIME, CK_SH_EXIT,
+       CK_SH_EMPTY };
+/* Rust parse_line: at most CK_LINE_CAP bytes, first word at most 16 bytes, at
+ * most one argument of at most 16 bytes; else CK_SH_INVALID. An all-blank
+ * line is CK_SH_EMPTY (Rust: None, "invalid command line"). */
+int ck_shell_parse(const char *line, size_t len);
+typedef struct {
+    uint64_t conventional_memory_kb;
+    unsigned exception_level;
+    uint64_t uptime_ms;
+    const char *commit;
+} ck_shell_ctx;
+/* Run one line; output goes through out(). Returns 1 when the line was
+ * "exit". Output texts are the Rust ones ("commands: help mem el report
+ * uptime exit", "conventional_memory_kb: N", "EL1", "uptime_ms: N",
+ * "unknown command: X", "invalid command line"). */
+int ck_shell_run(const char *line, const ck_shell_ctx *ctx, void (*out)(const char *fmt, ...));
+
+/* ---- recovery access ---- */
+enum { CK_RECOVERY_NORMAL_TIMEOUT = 0, CK_RECOVERY_NORMAL_KEY = 1, CK_RECOVERY_CONSOLE = 2 };
+/* The first key the operator presses in the recovery window decides: 'r' or
+ * 'R' selects the recovery console, any other key continues the normal boot.
+ * have_key == 0 (no key before the window closed) continues normally. */
+int ck_recovery_decide(int have_key, ck_key_event ev);
+const char *ck_recovery_name(int choice);
+/* Identity digest the recovery console stub prints: SHA-256 over
+ * "AIENOS-CK-RECOVERY-IDENTITY-V1" || 0x00 || commit (the image build
+ * identity; not an owner or machine identity, which do not exist yet). */
+void ck_recovery_identity(const char *commit, uint8_t out[32]);
+#endif
diff --git a/native/kernel/dev/usb_kbd.c b/native/kernel/dev/usb_kbd.c
new file mode 100644
index 00000000..a0a0345c
--- /dev/null
+++ b/native/kernel/dev/usb_kbd.c
@@ -0,0 +1,590 @@
+/* usb_kbd.c -- polled xHCI boot-keyboard driver, operator line input,
+ * console shell and recovery-access hook (see usb_kbd.h). Freestanding.
+ * Register and structure layouts: xHCI 1.2 (sections 5.3-5.6 registers,
+ * 6.2 contexts, 6.4 TRBs, 6.5 event ring segment table), USB 2.0 chapter 9
+ * (standard requests), HID 1.11 (SET_PROTOCOL, SET_IDLE). */
+#include "usb_kbd.h"
+#include "usb_hid.h"
+#include "ck.h"
+
+#define PG 4096u
+#define RING_N 256u /* TRBs per 4 KiB ring page */
+
+/* DMA region layout, one 4 KiB page each. */
+enum { P_DCBAA = 0, P_DEVCTX, P_INCTX, P_CMD, P_EVT, P_ERST, P_EP0, P_INTR, P_BUF, P_SPARRAY, P_SP0 };
+#define BUF_REPORT 0u
+#define BUF_DESC 512u
+#define DESC_MAX 255u
+
+/* Capability registers. */
+#define CAP_LENGTH 0x00u
+#define CAP_HCSPARAMS1 0x04u
+#define CAP_HCSPARAMS2 0x08u
+#define CAP_HCCPARAMS1 0x10u
+#define CAP_DBOFF 0x14u
+#define CAP_RTSOFF 0x18u
+/* Operational registers. */
+#define OP_USBCMD 0x00u
+#define OP_USBSTS 0x04u
+#define OP_PAGESIZE 0x08u
+#define OP_CRCR 0x18u
+#define OP_DCBAAP 0x30u
+#define OP_CONFIG 0x38u
+#define OP_PORTSC(p) (0x400u + 0x10u * ((p) - 1u))
+#define CMD_RS 0x1u
+#define CMD_HCRST 0x2u
+#define STS_HCH 0x1u
+#define STS_HSE 0x4u
+#define STS_CNR 0x800u
+/* Interrupter 0 (runtime base + 0x20). */
+#define IR0_ERSTSZ 0x28u
+#define IR0_ERSTBA 0x30u
+#define IR0_ERDP 0x38u
+/* PORTSC */
+#define PS_CCS 0x1u
+#define PS_PED 0x2u
+#define PS_PR 0x10u
+#define PS_PP 0x200u
+#define PS_PRC 0x200000u
+#define PS_CHANGES 0x00fe0000u
+#define PS_KEEP (PS_PP | 0x0e000000u) /* PP and the wake enables: RW, not RW1C */
+/* TRB types */
+#define T_NORMAL 1u
+#define T_SETUP 2u
+#define T_DATA 3u
+#define T_STATUS 4u
+#define T_LINK 6u
+#define T_ENABLE_SLOT 9u
+#define T_DISABLE_SLOT 10u
+#define T_ADDRESS 11u
+#define T_CONFIGURE 12u
+#define T_EVALUATE 13u
+#define T_EV_TRANSFER 32u
+#define T_EV_COMMAND 33u
+#define TRB_TYPE(t) ((uint32_t)(t) << 10)
+#define TRB_IOC 0x20u
+#define TRB_ISP 0x4u
+#define TRB_IDT 0x40u
+#define TRB_TC 0x2u
+#define CC_SUCCESS 1u
+#define CC_SHORT 13u
+/* Endpoint types (context) */
+#define EP_CONTROL 4u
+#define EP_INTR_IN 7u
+
+typedef struct {
+    volatile uint32_t *t;
+    uint64_t phys;
+    uint32_t i, c;
+} ring;
+
+typedef struct {
+    volatile uint8_t *base;
+    uint32_t op, rt, db;
+    uint8_t *mem;
+    uint64_t phys;
+    unsigned ctx, max_ports;
+    ring cmd, ep0, intr;
+    uint32_t ev_i, ev_c;
+    uint8_t slot, port, speed, dci;
+    uint16_t mps0;
+    ck_boot_kbd kbd;
+    int ep_halted;
+    const char *why;
+    uint32_t last_code;
+} kbd;
+
+static kbd g_k;
+static int g_offered;       /* the recovery choice was offered (keyboard ready) */
+static int g_choice = -1;   /* CK_RECOVERY_* once decided */
+
+static uint32_t rd(uint32_t off) { return *(volatile uint32_t *)(g_k.base + off); }
+static void wr(uint32_t off, uint32_t v) { *(volatile uint32_t *)(g_k.base + off) = v; }
+static void wr64(uint32_t off, uint64_t v)
+{
+    wr(off, (uint32_t)v);
+    wr(off + 4u, (uint32_t)(v >> 32));
+}
+static uint8_t *page(unsigned p) { return g_k.mem + (size_t)p * PG; }
+static uint64_t page_phys(unsigned p) { return g_k.phys + (uint64_t)p * PG; }
+static void zero(uint8_t *p, size_t n)
+{
+    for (size_t i = 0; i < n; i++) ((volatile uint8_t *)p)[i] = 0;
+}
+
+static int fail(int rc, const char *why)
+{
+    g_k.why = why;
+    return rc;
+}
+
+/* Bounded poll: returns 1 once cond() holds, 0 when ms ran out. */
+#define WAIT_MS(ms, cond)                                                  \
+    ({                                                                     \
+        uint64_t t0_ = ck_time_us();                                       \
+        int ok_ = 0;                                                       \
+        for (;;) {                                                         \
+            if (cond) { ok_ = 1; break; }                                  \
+            if (ck_time_us() - t0_ > (uint64_t)(ms) * 1000u) break;        \
+            ck_udelay(20);                                                 \
+        }                                                                  \
+        ok_;                                                               \
+    })
+
+static void ring_init(ring *r, unsigned p)
+{
+    zero(page(p), PG);
+    r->t = (volatile uint32_t *)page(p);
+    r->phys = page_phys(p);
+    r->i = 0;
+    r->c = 1;
+}
+
+/* Producer side: writes the control word (cycle bit) last; the last slot of
+ * the page is a Link TRB back to the start with Toggle Cycle. */
+static uint64_t ring_push(ring *r, uint32_t p0, uint32_t p1, uint32_t st, uint32_t ctl)
+{
+    volatile uint32_t *e = r->t + r->i * 4u;
+    uint64_t at = r->phys + (uint64_t)r->i * 16u;
+    e[0] = p0;
+    e[1] = p1;
+    e[2] = st;
+    ck_mb();
+    e[3] = (ctl & ~1u) | r->c;
+    if (++r->i == RING_N - 1u) {
+        volatile uint32_t *l = r->t + r->i * 4u;
+        l[0] = (uint32_t)r->phys;
+        l[1] = (uint32_t)(r->phys >> 32);
+        l[2] = 0;
+        ck_mb();
+        l[3] = TRB_TYPE(T_LINK) | TRB_TC | r->c;
+        r->i = 0;
+        r->c ^= 1u;
+    }
+    return at;
+}
+
+static void doorbell(unsigned target, uint32_t value)
+{
+    ck_mb();
+    wr(g_k.db + 4u * target, value);
+}
+
+/* Consumer side of the event ring; 1 and ev filled when an event was there. */
+static int ev_next(uint32_t ev[4])
+{
+    volatile uint32_t *e = (volatile uint32_t *)page(P_EVT) + g_k.ev_i * 4u;
+    if ((e[3] & 1u) != g_k.ev_c) return 0;
+    for (int i = 0; i < 4; i++) ev[i] = e[i];
+    if (++g_k.ev_i == RING_N) {
+        g_k.ev_i = 0;
+        g_k.ev_c ^= 1u;
+    }
+    wr64(g_k.rt + IR0_ERDP, (page_phys(P_EVT) + (uint64_t)g_k.ev_i * 16u) | 0x8u /* EHB */);
+    return 1;
+}
+static uint64_t ev_ptr(const uint32_t ev[4]) { return (uint64_t)ev[0] | ((uint64_t)ev[1] << 32); }
+static uint32_t ev_type(const uint32_t ev[4]) { return (ev[3] >> 10) & 0x3fu; }
+static uint32_t ev_code(const uint32_t ev[4]) { return ev[2] >> 24; }
+
+static int command(uint32_t p0, uint32_t p1, uint32_t ctl, uint32_t out[4], const char *step)
+{
+    uint64_t at = ring_push(&g_k.cmd, p0, p1, 0, ctl);
+    doorbell(0, 0);
+    uint32_t ev[4];
+    uint64_t t0 = ck_time_us();
+    while (ck_time_us() - t0 < 1000000u) {
+        if (!ev_next(ev)) {
+            ck_udelay(20);
+            continue;
+        }
+        if (ev_type(ev) != T_EV_COMMAND || ev_ptr(ev) != at) continue; /* port status changes etc. */
+        g_k.last_code = ev_code(ev);
+        if (out)
+            for (int i = 0; i < 4; i++) out[i] = ev[i];
+        return ev_code(ev) == CC_SUCCESS ? 0 : fail(CK_KBD_E_FAILED, step);
+    }
+    return fail(CK_KBD_E_TIMEOUT, step);
+}
+
+/* Waits for the transfer event of the TRB at `at` on (slot, dci). An error
+ * completion on an earlier TRB of the same TD ends the wait as a failure. */
+static int transfer_wait(uint64_t at, uint8_t dci, uint32_t ms, const char *step)
+{
+    uint32_t ev[4];
+    uint64_t t0 = ck_time_us();
+    while (ck_time_us() - t0 < (uint64_t)ms * 1000u) {
+        if (!ev_next(ev)) {
+            ck_udelay(20);
+            continue;
+        }
+        if (ev_type(ev) != T_EV_TRANSFER || (ev[3] >> 24) != g_k.slot || ((ev[3] >> 16) & 0x1fu) != dci) continue;
+        uint32_t cc = ev_code(ev);
+        g_k.last_code = cc;
+        if (cc != CC_SUCCESS && cc != CC_SHORT) return fail(CK_KBD_E_FAILED, step);
+        if (ev_ptr(ev) == at) return 0;
+    }
+    return fail(CK_KBD_E_TIMEOUT, step);
+}
+
+static int control(uint8_t rtype, uint8_t req, uint16_t val, uint16_t idx, uint16_t len, uint64_t buf, const char *step)
+{
+    int in = (rtype & 0x80u) != 0;
+    uint32_t trt = len ? (in ? 3u : 2u) : 0u;
+    ring_push(&g_k.ep0, (uint32_t)rtype | ((uint32_t)req << 8) | ((uint32_t)val << 16), (uint32_t)idx | ((uint32_t)len << 16),
+              8u, TRB_TYPE(T_SETUP) | TRB_IDT | (trt << 16));
+    if (len)
+        ring_push(&g_k.ep0, (uint32_t)buf, (uint32_t)(buf >> 32), len, TRB_TYPE(T_DATA) | (in ? (1u << 16) : 0u));
+    uint64_t st = ring_push(&g_k.ep0, 0, 0, 0, TRB_TYPE(T_STATUS) | TRB_IOC | ((len && in) ? 0u : (1u << 16)));
+    doorbell(g_k.slot, 1);
+    return transfer_wait(st, 1, 1000, step);
+}
+
+static volatile uint32_t *ictx(unsigned index) { return (volatile uint32_t *)(page(P_INCTX) + (size_t)index * g_k.ctx); }
+
+static void ep0_context(uint32_t add, unsigned entries)
+{
+    zero(page(P_INCTX), PG);
+    ictx(0)[1] = add;
+    ictx(1)[0] = ((uint32_t)g_k.speed << 20) | ((uint32_t)entries << 27);
+    ictx(1)[1] = (uint32_t)g_k.port << 16;
+    volatile uint32_t *ep = ictx(2);
+    ep[1] = (3u << 1) | (EP_CONTROL << 3) | ((uint32_t)g_k.mps0 << 16);
+    uint64_t dq = g_k.ep0.phys + (uint64_t)g_k.ep0.i * 16u;
+    ep[2] = (uint32_t)dq | g_k.ep0.c;
+    ep[3] = (uint32_t)(dq >> 32);
+    ep[4] = 8u;
+}
+
+static uint32_t intr_interval(uint8_t speed, uint8_t b)
+{
+    if (speed >= 3) { /* high / super speed: 2^(bInterval-1) microframes */
+        uint32_t v = b ? (uint32_t)b - 1u : 0u;
+        return v > 15u ? 15u : v;
+    }
+    /* full / low speed: bInterval frames of 1 ms = 8 microframes each */
+    uint32_t f = b ? b : 1u, e = 0;
+    while ((1u << (e + 1u)) <= f * 8u && e < 15u) e++;
+    return e < 3u ? 3u : e > 10u ? 10u : e;
+}
+
+static int reset_port(uint8_t p)
+{
+    uint32_t off = g_k.op + OP_PORTSC(p);
+    uint32_t s = rd(off);
+    if (!(s & PS_PED)) {
+        wr(off, (s & PS_KEEP) | PS_PR);
+        if (!WAIT_MS(500, rd(off) & PS_PRC)) return fail(CK_KBD_E_TIMEOUT, "port reset");
+        ck_udelay(10000); /* USB 2.0 7.1.7.5 reset recovery, 10 ms */
+    }
+    s = rd(off);
+    wr(off, (s & PS_KEEP) | (s & PS_CHANGES));
+    if (!(s & PS_PED)) return fail(CK_KBD_E_UNSUP, "port did not enable");
+    g_k.speed = (uint8_t)((s >> 10) & 0xfu);
+    return 0;
+}
+
+static int attach(uint8_t p)
+{
+    int rc = reset_port(p);
+    if (rc) return rc;
+    g_k.port = p;
+    uint32_t ev[4];
+    if ((rc = command(0, 0, TRB_TYPE(T_ENABLE_SLOT), ev, "Enable Slot"))) return rc;
+    g_k.slot = (uint8_t)(ev[3] >> 24);
+    if (g_k.slot == 0) return fail(CK_KBD_E_UNSUP, "slot id 0");
+    zero(page(P_DEVCTX), PG);
+    ((volatile uint64_t *)page(P_DCBAA))[g_k.slot] = page_phys(P_DEVCTX);
+    ring_init(&g_k.ep0, P_EP0);
+    g_k.mps0 = g_k.speed == 4 ? 512u : g_k.speed == 3 ? 64u : 8u;
+    ep0_context(0x3u, 1);
+    if ((rc = command((uint32_t)page_phys(P_INCTX), (uint32_t)(page_phys(P_INCTX) >> 32),
+                      TRB_TYPE(T_ADDRESS) | ((uint32_t)g_k.slot << 24), 0, "Address Device")))
+        return rc;
+    uint8_t *desc = page(P_BUF) + BUF_DESC;
+    uint64_t desc_phys = page_phys(P_BUF) + BUF_DESC;
+    zero(desc, DESC_MAX + 1u);
+    if ((rc = control(0x80, 6, 0x0100, 0, 8, desc_phys, "GET_DESCRIPTOR(device)"))) return rc;
+    if (desc[0] >= 8 && desc[1] == 1 && desc[7]) {
+        uint16_t m = g_k.speed == 4 ? (uint16_t)(1u << (desc[7] > 9 ? 9 : desc[7])) : desc[7];
+        if (m != g_k.mps0) {
+            g_k.mps0 = m;
+            ep0_context(0x2u, 1);
+            if ((rc = command((uint32_t)page_phys(P_INCTX), (uint32_t)(page_phys(P_INCTX) >> 32),
+                              TRB_TYPE(T_EVALUATE) | ((uint32_t)g_k.slot << 24), 0, "Evaluate Context")))
+                return rc;
+        }
+    }
+    zero(desc, DESC_MAX + 1u);
+    if ((rc = control(0x80, 6, 0x0200, 0, DESC_MAX, desc_phys, "GET_DESCRIPTOR(configuration)"))) return rc;
+    if (ck_usb_find_boot_kbd(desc, DESC_MAX, &g_k.kbd)) return fail(CK_KBD_E_NOKBD, "no boot keyboard interface");
+    uint8_t n = g_k.kbd.endpoint & 0x0fu;
+    if (n == 0) return fail(CK_KBD_E_NOKBD, "endpoint 0");
+    g_k.dci = (uint8_t)(2u * n + 1u);
+    /* xHCI 4.3.5: Configure Endpoint, then SET_CONFIGURATION. */
+    ring_init(&g_k.intr, P_INTR);
+    zero(page(P_INCTX), PG);
+    ictx(0)[1] = 1u | (1u << g_k.dci);
+    ictx(1)[0] = ((uint32_t)g_k.speed << 20) | ((uint32_t)g_k.dci << 27);
+    ictx(1)[1] = (uint32_t)g_k.port << 16;
+    volatile uint32_t *ep = ictx(1u + g_k.dci);
+    ep[0] = intr_interval(g_k.speed, g_k.kbd.interval) << 16;
+    ep[1] = (3u << 1) | (EP_INTR_IN << 3) | ((uint32_t)g_k.kbd.max_packet << 16);
+    ep[2] = (uint32_t)g_k.intr.phys | 1u;
+    ep[3] = (uint32_t)(g_k.intr.phys >> 32);
+    ep[4] = CK_HID_REPORT_LEN | ((uint32_t)g_k.kbd.max_packet << 16);
+    if ((rc = command((uint32_t)page_phys(P_INCTX), (uint32_t)(page_phys(P_INCTX) >> 32),
+                      TRB_TYPE(T_CONFIGURE) | ((uint32_t)g_k.slot << 24), 0, "Configure Endpoint")))
+        return rc;
+    if ((rc = control(0x00, 9, g_k.kbd.configuration, 0, 0, 0, "SET_CONFIGURATION"))) return rc;
+    if ((rc = control(0x21, 0x0b, 0, g_k.kbd.interface, 0, 0, "SET_PROTOCOL(boot)"))) return rc;
+    (void)control(0x21, 0x0a, 0, g_k.kbd.interface, 0, 0, "SET_IDLE"); /* optional: some keyboards stall it */
+    return 0;
+}
+
+static uint64_t g_armed;
+static void arm(void)
+{
+    g_armed = ring_push(&g_k.intr, (uint32_t)(page_phys(P_BUF) + BUF_REPORT), (uint32_t)((page_phys(P_BUF) + BUF_REPORT) >> 32),
+                        CK_HID_REPORT_LEN, TRB_TYPE(T_NORMAL) | TRB_IOC | TRB_ISP);
+    doorbell(g_k.slot, g_k.dci);
+}
+
+/* One completed report into rep (8 bytes), or 0 when none is waiting. */
+static int poll_report(uint8_t rep[CK_HID_REPORT_LEN])
+{
+    uint32_t ev[4];
+    while (ev_next(ev)) {
+        if (ev_type(ev) != T_EV_TRANSFER || (ev[3] >> 24) != g_k.slot || ((ev[3] >> 16) & 0x1fu) != g_k.dci) continue;
+        uint32_t cc = ev_code(ev);
+        if (cc != CC_SUCCESS && cc != CC_SHORT) {
+            g_k.last_code = cc;
+            g_k.ep_halted = 1;
+            return 0;
+        }
+        uint32_t got = CK_HID_REPORT_LEN - (ev[2] & 0xffffffu);
+        const volatile uint8_t *b = page(P_BUF) + BUF_REPORT;
+        for (unsigned i = 0; i < CK_HID_REPORT_LEN; i++) rep[i] = i < got ? b[i] : 0;
+        arm();
+        return got >= 3u;
+    }
+    return 0;
+}
+
+static int start(volatile uint8_t *bar0, uint8_t *mem, uint64_t phys, size_t bytes)
+{
+    g_k.base = bar0;
+    g_k.mem = mem;
+    g_k.phys = phys;
+    g_k.why = "";
+    if (!bar0 || !mem || bytes < (size_t)CK_KBD_DMA_PAGES * PG || (phys & (PG - 1u)))
+        return fail(CK_KBD_E_ARG, "DMA region too small or unaligned");
+    uint32_t cap = rd(CAP_LENGTH), hcs1 = rd(CAP_HCSPARAMS1), hcs2 = rd(CAP_HCSPARAMS2), hcc1 = rd(CAP_HCCPARAMS1);
+    if (cap == 0xffffffffu || (cap & 0xffu) < 0x20u) return fail(CK_KBD_E_ARG, "xHCI registers absent");
+    g_k.op = cap & 0xffu;
+    g_k.rt = rd(CAP_RTSOFF) & ~0x1fu;
+    g_k.db = rd(CAP_DBOFF) & ~0x3u;
+    g_k.max_ports = hcs1 >> 24;
+    g_k.ctx = (hcc1 & 0x4u) ? 64u : 32u;
+    uint32_t sp = ((hcs2 >> 27) & 0x1fu) | (((hcs2 >> 21) & 0x1fu) << 5);
+    if (sp > CK_KBD_MAX_SCRATCHPADS) return fail(CK_KBD_E_UNSUP, "controller asks for more scratchpad pages than the window holds");
+    if (!(hcc1 & 0x1u) && phys + bytes > 0x100000000ull) return fail(CK_KBD_E_UNSUP, "DMA above 4 GiB on a 32-bit controller");
+    if (!(rd(g_k.op + OP_PAGESIZE) & 0x1u)) return fail(CK_KBD_E_UNSUP, "4 KiB pages not supported");
+    /* USB legacy support capability (xHCI 7.1): take ownership from firmware. */
+    uint32_t x = (hcc1 >> 16) << 2;
+    for (unsigned guard = 0; x && guard < 64; guard++) {
+        uint32_t v = rd(x);
+        if ((v & 0xffu) == 1u) {
+            if (v & (1u << 16)) {
+                wr(x, v | (1u << 24));
+                int ok = WAIT_MS(1000, !(rd(x) & (1u << 16)));
+                ck_printf("xhci: legacy handoff bios_owned=%s\n", ok ? "released" : "STILL SET");
+                if (!ok) return fail(CK_KBD_E_TIMEOUT, "firmware kept the controller (legacy handoff)");
+            }
+            wr(x + 4u, rd(x + 4u) & 0x1fff1feeu); /* SMI enables off; RW1C status bits 31:29 written 0 */
+            break;
+        }
+        uint32_t next = (v >> 8) & 0xffu;
+        x = next ? x + (next << 2) : 0;
+    }
+    /* The fence left it halted; reset (5.4.1: HCRST only while HCH = 1). */
+    if (!(rd(g_k.op + OP_USBSTS) & STS_HCH)) return fail(CK_KBD_E_ARG, "controller not halted before reset");
+    wr(g_k.op + OP_USBCMD, CMD_HCRST);
+    if (!WAIT_MS(1000, !(rd(g_k.op + OP_USBCMD) & CMD_HCRST) && !(rd(g_k.op + OP_USBSTS) & STS_CNR)))
+        return fail(CK_KBD_E_TIMEOUT, "controller reset");
+    zero(mem, (size_t)CK_KBD_DMA_PAGES * PG);
+    if (sp) {
+        volatile uint64_t *arr = (volatile uint64_t *)page(P_SPARRAY);
+        for (uint32_t i = 0; i < sp; i++) arr[i] = page_phys(P_SP0 + i);
+        ((volatile uint64_t *)page(P_DCBAA))[0] = page_phys(P_SPARRAY);
+    }
+    ring_init(&g_k.cmd, P_CMD);
+    g_k.ev_i = 0;
+    g_k.ev_c = 1;
+    volatile uint32_t *erst = (volatile uint32_t *)page(P_ERST);
+    erst[0] = (uint32_t)page_phys(P_EVT);
+    erst[1] = (uint32_t)(page_phys(P_EVT) >> 32);
+    erst[2] = RING_N;
+    erst[3] = 0;
+    ck_mb();
+    wr(g_k.op + OP_CONFIG, (rd(g_k.op + OP_CONFIG) & ~0xffu) | 1u);
+    wr64(g_k.op + OP_DCBAAP, page_phys(P_DCBAA));
+    wr64(g_k.op + OP_CRCR, page_phys(P_CMD) | 1u);
+    wr(g_k.rt + IR0_ERSTSZ, 1);
+    wr64(g_k.rt + IR0_ERDP, page_phys(P_EVT));
+    wr64(g_k.rt + IR0_ERSTBA, page_phys(P_ERST));
+    wr(g_k.op + OP_USBCMD, CMD_RS);
+    if (!WAIT_MS(100, !(rd(g_k.op + OP_USBSTS) & STS_HCH))) return fail(CK_KBD_E_TIMEOUT, "controller run");
+    if (rd(g_k.op + OP_USBSTS) & STS_HSE) return fail(CK_KBD_E_FAILED, "host system error");
+    ck_printf("xhci: running ports=%u context_bytes=%u scratchpads=%u dma_pages=%u\n", g_k.max_ports, g_k.ctx, sp,
+              (unsigned)CK_KBD_DMA_PAGES);
+    /* Connections are re-reported after the reset: give them a bounded moment. */
+    (void)WAIT_MS(500, ({
+                      int any_ = 0;
+                      for (unsigned p_ = 1; p_ <= g_k.max_ports; p_++) any_ |= rd(g_k.op + OP_PORTSC(p_)) & PS_CCS;
+                      any_;
+                  }));
+    int rc = fail(CK_KBD_E_NOKBD, "no boot keyboard on any connected port");
+    for (unsigned p = 1; p <= g_k.max_ports && p <= 255u; p++) {
+        if (!(rd(g_k.op + OP_PORTSC(p)) & PS_CCS)) continue;
+        g_k.slot = 0;
+        rc = attach((uint8_t)p);
+        if (rc == 0) break;
+        ck_printf("keyboard: port %u not usable (%s, completion %u)\n", p, g_k.why, g_k.last_code);
+        if (g_k.slot) (void)command(0, 0, TRB_TYPE(T_DISABLE_SLOT) | ((uint32_t)g_k.slot << 24), 0, "Disable Slot");
+        g_k.slot = 0;
+    }
+    if (rc) return rc;
+    arm();
+    return 0;
+}
+
+static void echo(char c)
+{
+    if (c == '\b')
+        ck_puts("\b \b");
+    else
+        ck_printf("%c", c);
+}
+
+static void shell_out(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    ck_vprintf(fmt, ap);
+    va_end(ap);
+}
+
+/* Next key event, waiting at most ms; 1 and *ev filled, or 0. */
+static int next_key(ck_hid_decoder *d, ck_key_event *pend, unsigned *npend, unsigned *ipend, uint32_t ms, ck_key_event *ev)
+{
+    uint64_t t0 = ck_time_us();
+    for (;;) {
+        if (*ipend < *npend) {
+            *ev = pend[(*ipend)++];
+            return 1;
+        }
+        uint8_t rep[CK_HID_REPORT_LEN];
+        if (poll_report(rep)) {
+            *npend = ck_hid_decode(d, rep, sizeof rep, pend);
+            *ipend = 0;
+            continue;
+        }
+        if (g_k.ep_halted || ck_time_us() - t0 >= (uint64_t)ms * 1000u) return 0;
+        ck_udelay(100);
+    }
+}
+
+int ck_kbd_phase(volatile uint8_t *bar0, uint8_t *mem, uint64_t phys, size_t bytes)
+{
+    int rc = start(bar0, mem, phys, bytes);
+    if (rc) {
+        ck_printf("keyboard: unavailable (%s, rc=%d, completion %u)\n", g_k.why, rc, g_k.last_code);
+        return rc;
+    }
+    ck_printf("keyboard: ready (port %u, slot %u, endpoint 0x%02x)\n", g_k.port, g_k.slot, g_k.kbd.endpoint);
+
+    ck_hid_decoder dec = {{0}};
+    ck_key_event pend[CK_HID_MAX_KEYS], ev = {0, 0};
+    unsigned np = 0, ip = 0;
+    /* Recovery access: bounded wait for one operator key. */
+    g_offered = 1;
+    ck_printf("recovery_access: waiting %u ms for an operator key (r = recovery console; any other key or no key = "
+              "normal boot)\n",
+              (unsigned)CK_KBD_RECOVERY_WAIT_MS);
+    int have = next_key(&dec, pend, &np, &ip, CK_KBD_RECOVERY_WAIT_MS, &ev);
+    g_choice = ck_recovery_decide(have, ev);
+    ck_printf("recovery_access: choice=%s\n", ck_recovery_name(g_choice));
+    if (g_choice == CK_RECOVERY_CONSOLE) return CK_KBD_OK; /* the fence revokes; devices.c runs the stub */
+    np = ip = 0;
+
+    ck_printf("keyboard: shell ready (%u s, idle %u s)\n", (unsigned)(CK_KBD_SHELL_MS / 1000u),
+              (unsigned)(CK_KBD_SHELL_IDLE_MS / 1000u));
+    ck_line line;
+    ck_line_reset(&line);
+    uint64_t t0 = ck_time_us();
+    const char *reason = "timeout";
+    ck_puts("aienos> ");
+    for (;;) {
+        uint64_t used = (ck_time_us() - t0) / 1000u;
+        if (used >= CK_KBD_SHELL_MS) break;
+        uint32_t left = (uint32_t)(CK_KBD_SHELL_MS - used);
+        if (!next_key(&dec, pend, &np, &ip, left < CK_KBD_SHELL_IDLE_MS ? left : CK_KBD_SHELL_IDLE_MS, &ev)) {
+            reason = g_k.ep_halted ? "endpoint halted" : (ck_time_us() - t0) / 1000u >= CK_KBD_SHELL_MS ? "timeout" : "idle";
+            break;
+        }
+        int r = ck_line_feed(&line, ev, echo);
+        if (r == CK_LINE_OVERFLOW) {
+            ck_printf("\nkeyboard_line: overflow (line refused: %u keys typed, limit %u)\n", line.typed, (unsigned)CK_LINE_CAP);
+            ck_puts("keyboard: done (overflow)\n");
+            ck_line_reset(&line);
+            ck_puts("aienos> ");
+            continue;
+        }
+        if (r != CK_LINE_DONE) continue;
+        ck_printf("\nkeyboard_echo: %s\nkeyboard_line: %s\nkeyboard: done (enter)\n", line.buf, line.buf);
+        ck_shell_ctx ctx = {ck_conventional_memory_kb(), ck_exception_level(), (ck_time_us() - t0) / 1000u, ck_commit()};
+        int ex = ck_shell_run(line.buf, &ctx, shell_out);
+        ck_line_reset(&line);
+        if (ex) {
+            reason = "exit";
+            break;
+        }
+        ck_puts("aienos> ");
+    }
+    ck_printf("\nkeyboard: done (%s)\n", reason);
+    return CK_KBD_OK;
+}
+
+void ck_kbd_recovery_report(const char *xhci_state)
+{
+    if (g_offered) return;
+    g_choice = CK_RECOVERY_NORMAL_TIMEOUT;
+    ck_printf("recovery_access: unavailable (no operator keyboard: xhci=%s); choice=normal reason=no-keyboard\n",
+              xhci_state ? xhci_state : "absent");
+}
+
+int ck_kbd_recovery_requested(void) { return g_choice == CK_RECOVERY_CONSOLE; }
+
+void ck_recovery_console_stub(void)
+{
+    uint8_t id[32];
+    char hex[65];
+    static const char hx[] = "0123456789abcdef";
+    ck_recovery_identity(ck_commit(), id);
+    for (int i = 0; i < 32; i++) {
+        hex[2 * i] = hx[id[i] >> 4];
+        hex[2 * i + 1] = hx[id[i] & 0xfu];
+    }
+    hex[64] = 0;
+    ck_puts("recovery_console: STUB (NEXT-PHASE-3 cut 1: the console itself is not built; no commands)\n");
+    ck_printf("recovery_console: identity build_sha256=%s commit=%s (image build identity; not an owner or machine "
+              "identity)\n",
+              hex, ck_commit());
+    ck_puts("recovery_console: halted (no device DMA live; power-cycle to leave)\n");
+    for (;;) {
+#if defined(__aarch64__)
+        __asm__ volatile("msr daifset, #0xf\n\twfi" ::: "memory");
+#endif
+    }
+}
diff --git a/native/kernel/dev/usb_kbd.h b/native/kernel/dev/usb_kbd.h
new file mode 100644
index 00000000..431b42ac
--- /dev/null
+++ b/native/kernel/dev/usb_kbd.h
@@ -0,0 +1,70 @@
+/* usb_kbd.h -- operator keyboard for the AIENOS C kernel: a polled xHCI
+ * driver for one USB HID boot keyboard, the operator line input, the console
+ * shell of the Rust SEED-0A keyboard gate, and the recovery-access hook.
+ * Port of crates/aienos-kernel/src/usb/xhci (controller.rs, ring.rs,
+ * context.rs, trb.rs) and crates/aienos-boot/src/usb_keyboard.rs (run), with
+ * the same console lines where the Rust gate greps them.
+ *
+ * Runs only inside the xHCI DMA fence (xhci_fence.c), between the
+ * SMMU-confined grant and the revoke: every ring, context and buffer lives
+ * in the fence's DMA region, which is the controller stream's only SMMU
+ * window. No SMMU confinement means this code never runs (fail closed).
+ * Polled only: no interrupt, no scheduler, no Store.
+ *
+ * Boot flow (devices stage, after NVMe and virtio-net):
+ *   1. reset and start the controller, find the first connected port with a
+ *      boot keyboard, address it, configure its interrupt IN endpoint
+ *      ("keyboard: ready (port P, slot S, endpoint 0xEE)");
+ *   2. recovery access: wait at most CK_KBD_RECOVERY_WAIT_MS for one key.
+ *      'r' selects the recovery console, any other key or no key continues
+ *      ("recovery_access: choice=...");
+ *   3. normal boot: the console shell ("aienos> ", lines echoed, Enter ends a
+ *      line: "keyboard_echo:", "keyboard_line:", "keyboard: done (enter)",
+ *      then the command output) until "exit", CK_KBD_SHELL_IDLE_MS without a
+ *      key, CK_KBD_SHELL_MS in all, or a halted endpoint;
+ *   4. the fence then halts the controller and revokes its DMA. A recovery
+ *      choice is acted on by devices.c after that revoke: every device DMA
+ *      released, then ck_recovery_console_stub (identity digest, halt).
+ * QEMU is not hardware: nothing here is physically qualified. */
+#ifndef AIENOS_CK_USB_KBD_H
+#define AIENOS_CK_USB_KBD_H
+#include <stddef.h>
+#include <stdint.h>
+
+#ifndef CK_KBD_RECOVERY_WAIT_MS
+#define CK_KBD_RECOVERY_WAIT_MS 5000u
+#endif
+#ifndef CK_KBD_SHELL_MS
+#define CK_KBD_SHELL_MS 60000u
+#endif
+#ifndef CK_KBD_SHELL_IDLE_MS
+#define CK_KBD_SHELL_IDLE_MS 15000u
+#endif
+/* Pages of the fence's DMA region the driver uses (4 KiB each). */
+#define CK_KBD_DMA_PAGES 16u
+#define CK_KBD_MAX_SCRATCHPADS 6u
+
+enum {
+    CK_KBD_OK = 0,
+    CK_KBD_E_ARG = -651,     /* bad region or registers */
+    CK_KBD_E_UNSUP = -652,   /* controller needs something this driver lacks */
+    CK_KBD_E_TIMEOUT = -653, /* a bounded wait ran out */
+    CK_KBD_E_FAILED = -654,  /* a command or transfer completed with an error */
+    CK_KBD_E_NOKBD = -655,   /* no boot keyboard on any connected port */
+};
+
+/* Steps 1-3 on a controller the fence has granted (bus master on, stream
+ * confined) and halted. mem/phys: the fence's DMA region (identity mapped,
+ * Normal Non-cacheable, CK_KBD_DMA_PAGES pages). Never touches PCI config
+ * or the SMMU; the caller revokes afterwards whatever this returns. */
+int ck_kbd_phase(volatile uint8_t *bar0, uint8_t *mem, uint64_t phys, size_t bytes);
+/* After the devices stage's xHCI step: prints the recovery-access line when
+ * the phase never offered it (no keyboard: absent, denied, failed). */
+void ck_kbd_recovery_report(const char *xhci_state);
+/* 1 when the operator chose the recovery console. */
+int ck_kbd_recovery_requested(void);
+/* Recovery console, cut-1 stub: prints the image identity digest and halts
+ * this CPU for good (interrupts masked, WFI). The caller must have released
+ * every device's DMA first. Never returns. */
+__attribute__((noreturn)) void ck_recovery_console_stub(void);
+#endif
diff --git a/native/kernel/dev/xhci_fence.c b/native/kernel/dev/xhci_fence.c
index b54630c1..9c30e22b 100644
--- a/native/kernel/dev/xhci_fence.c
+++ b/native/kernel/dev/xhci_fence.c
@@ -1,6 +1,7 @@
 /* xhci_fence.c -- xHCI DMA fence (see xhci_fence.h). Freestanding. */
 #include "xhci_fence.h"
 #include "ck.h"
+#include "usb_kbd.h"
 
 #if defined(CK_TEST_XHCI_MUTATION) && defined(CK_HARDWARE_STAGING)
 #error "CK_TEST_XHCI_MUTATION (TEST-ONLY xHCI DMA fence mutation) cannot be combined with CK_HARDWARE_STAGING"
@@ -200,8 +201,11 @@ int ck_xhci_fence(const pci_system *pci)
     ck_printf("xhci: caplength=0x%02x hciversion=0x%04x dma_window=0x%llx+0x%x\n", cap & 0xffu, cap >> 16,
               (unsigned long long)g_dma_phys, (unsigned)CK_XHCI_DMA_BYTES);
     int hrc = halt("halted after grant");
-    /* Rows 29-30 (USB HID attach, typed line, console shell) are not built. */
-    ck_printf("keyboard: hid NOT_IMPLEMENTED (no USB HID driver or console shell in the C kernel; DMA fence only)\n");
+    /* Rows 29-30 and the recovery-access hook (usb_kbd.c): the polled HID
+     * boot-keyboard driver runs only here, inside the confined grant, on the
+     * fence's DMA region; the release below halts and revokes whatever it
+     * returns. A controller that would not halt is never driven. */
+    if (hrc == 0) (void)ck_kbd_phase(x->bar0, g_dma_mem, g_dma_phys, CK_XHCI_DMA_BYTES);
     x->state = hrc ? "halt-failed" : "fenced";
     ck_xhci_release();
     return hrc ? CK_XHCI_E_HALT : CK_XHCI_OK;
diff --git a/native/kernel/dev/xhci_fence.h b/native/kernel/dev/xhci_fence.h
index 4deb067d..2368c833 100644
--- a/native/kernel/dev/xhci_fence.h
+++ b/native/kernel/dev/xhci_fence.h
@@ -20,9 +20,9 @@
  *      isolation not active)". There is no unconfined bypass for the xHCI,
  *      not even in the TEST-ONLY CK_QEMU_UNSAFE_DMA=1 build;
  *   4. with the grant: map BAR0 and make sure the controller is halted
- *      (USBCMD.R/S = 0, USBSTS.HCH = 1, bounded wait); nothing is put on the
- *      controller's rings: there is NO USB HID driver and no console shell in
- *      the C kernel yet (rows 29-30 stay NOT_RUN, MISSING_IMPLEMENTATION);
+ *      (USBCMD.R/S = 0, USBSTS.HCH = 1, bounded wait); then, only if it
+ *      halted, the operator phase of usb_kbd.c runs on this DMA region: HID
+ *      boot keyboard, recovery-access hook and console shell (rows 29-30);
  *   5. release, in the NVMe halt order: controller halted while it can
  *      still DMA, bus master off with read-back ("dma_gate: xhci bus master
  *      revoked"), the controller's COMMAND register read back again
@@ -42,9 +42,9 @@
 #define AIENOS_CK_XHCI_FENCE_H
 #include "pci.h"
 
-/* DMA region the controller is confined to (its only SMMU window). Sized for
- * the HID cut that will follow (DCBAA, command/event rings, ERST, device and
- * input contexts, one interrupt-IN buffer); nothing uses it yet. */
+/* DMA region the controller is confined to (its only SMMU window): the 16
+ * pages of usb_kbd.c (DCBAA, device and input contexts, command and event
+ * rings, ERST, EP0 and interrupt-IN rings, buffer, up to 6 scratchpads). */
 #define CK_XHCI_DMA_BYTES (64u * 1024u)
 #define CK_XHCI_CLASS 0x0c0330u
 /* xHCI 1.2 section 5.4.1: the controller halts within 16 ms of R/S = 0. */
diff --git a/native/kernel/include/.crumb b/native/kernel/include/.crumb
index 8d863078..13692160 100644
--- a/native/kernel/include/.crumb
+++ b/native/kernel/include/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-04T13:47:18Z",
+      "compiled_at": "2026-10-06T01:02:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:dd460494a52e8cc9d2b05d75f86d71e8c387090c04ebcb7c448730dc765d39f1",
+      "digest": "sha256:67502074fde0b499b68d22d8498c2e410e365f1d9f2dc69b890fac52a56a2d93",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 1,
-      "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512",
-      "source_tree": "sha256:94644cca5eb6c6dbdbbd31b954883579277abb6c0c2f25fcf822c625971deba0"
+      "generated_at_commit": "20587476bf0d4b7577cc3b62857a9166300681bf",
+      "source_tree": "sha256:5a733890470cd8be98d366d5ead40c39c9de64daa8a0d0ea3e02f2acda692e84"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/include/ck.h b/native/kernel/include/ck.h
index 4bcbb767..91462a18 100644
--- a/native/kernel/include/ck.h
+++ b/native/kernel/include/ck.h
@@ -59,6 +59,12 @@ void ck_udelay(uint32_t us);
 /* Boot facts. */
 const char *ck_commit(void);  /* git commit the image was built from */
 uint32_t ck_boot_count_hint(void); /* 0; Store keeps the real count */
+/* Operator shell facts (added for the keyboard cut, NEXT-PHASE-3): the
+ * exception level the kernel runs at now, and the UEFI conventional memory
+ * (type 7) the firmware memory map reported at entry, in KiB (Rust shell
+ * "mem" / "el"). */
+unsigned ck_exception_level(void);
+uint64_t ck_conventional_memory_kb(void);
 
 /* Interrupts (added by core, Lane 18). GICv3, group 1, routed to the boot
  * CPU. Handlers run in IRQ context with interrupts masked; the core
diff --git a/native/kernel/stage.mk b/native/kernel/stage.mk
index 2caa7435..7d6c7460 100644
--- a/native/kernel/stage.mk
+++ b/native/kernel/stage.mk
@@ -21,6 +21,7 @@ STAGE_OUT ?= $(abspath $(STAGE_DIR)/../../target/stage)
 # Own sources (image).
 STAGE_OWN_SRCS := $(STAGE_DIR)/dev/pci.c $(STAGE_DIR)/dev/disk_part.c $(STAGE_DIR)/dev/nvme_bind.c $(STAGE_DIR)/dev/nvme_shutdown.c $(STAGE_DIR)/dev/virtio_net.c \
                   $(STAGE_DIR)/dev/net_bind.c $(STAGE_DIR)/dev/net_udp.c $(STAGE_DIR)/dev/xhci_fence.c \
+                  $(STAGE_DIR)/dev/usb_hid.c $(STAGE_DIR)/dev/usb_kbd.c \
                   $(STAGE_DIR)/dev/devices.c $(STAGE_DIR)/svc/security.c $(STAGE_DIR)/svc/store_boot.c \
                   $(STAGE_DIR)/svc/artifact_store.c $(STAGE_DIR)/svc/store_crash.c
 # Native modules, compiled unmodified.
@@ -60,7 +61,7 @@ STAGE_FREE_FLAGS := -std=gnu11 -O2 -Wall -Wextra -Werror -ffreestanding -nostdli
 # The only undefined symbols the stages may leave for the core: ck.h services.
 STAGE_ALLOWED_U := ck_puts ck_printf ck_vprintf ck_panic ck_alloc ck_free ck_dma_alloc ck_mmio_map \
   ck_dma_confine ck_dma_unconfine ck_dma_faults \
-  ck_mb ck_acpi_find ck_time_us ck_udelay ck_commit \
+  ck_mb ck_acpi_find ck_time_us ck_udelay ck_commit ck_exception_level ck_conventional_memory_kb \
   ck_entropy_fill ck_entropy_status ck_entropy_reason
 
 STAGE_FREE_OBJS := $(foreach s,$(STAGE_SRCS),$(STAGE_OUT)/free/$(subst /,_,$(subst $(STAGE_NATIVE)/,,$(s:.c=.o))))
diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb
index 8281f0cc..a81ece95 100644
--- a/native/kernel/svc/.crumb
+++ b/native/kernel/svc/.crumb
@@ -18,26 +18,26 @@
       "children": [
         {
           "digest": "17d9c9eba5fe222af0e8700ac3baa3461eb217a372f16a5e79e00a19cc5df6f5",
-          "last_commit": "fbbfc9c",
+          "last_commit": "31ed9f8",
           "name": "compat",
           "purpose": "Directory native/kernel/svc/compat. Purpose not yet described by a human."
         },
         {
-          "digest": "2815a08ee2c689d59a24bc81ec578a1068cd2bbc34737bb16418e0ebd8ecb3f9",
-          "last_commit": "fbbfc9c",
+          "digest": "c64e9742262522ca9b9a0b76ec28beb02a1ab7a3b9284bd85f5710391d143dcf",
+          "last_commit": "2f393a4",
           "name": "tests",
           "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:9e2977ce5ea7f74952e26dfb57f3703ab65c5ccbe933e2f5135ab1a5496e0af7",
-      "compiled_at": "2026-10-05T02:01:59Z",
+      "children_root": "sha256:556579a3c48b50e544dc026c1a4300a68b8fc92f4b7b4ebad24a74341178f62f",
+      "compiled_at": "2026-10-06T01:02:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:f24db6711bf88a0d7c48375f6f979fd589306a9266c697c5f25d4e8a2dbdb90d",
+      "digest": "sha256:2c634b363be2e02a04c0fdb3cf56c88bebf0a86ee172f3416989df3764ea7a0d",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 35,
-      "generated_at_commit": "71d5b326eea6a330f3cc1c4377fc4bc2d134d5aa",
-      "source_tree": "sha256:947429839de94404d11be4fef56449e2d79c1c4a1d0fe51f95c0bb9b1c18b73b"
+      "generated_at_commit": "20587476bf0d4b7577cc3b62857a9166300681bf",
+      "source_tree": "sha256:a49f575fb80438c30583914ccbe3149a5fb9c12e625392ffcf76fe42844723fb"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/svc/tests/.crumb b/native/kernel/svc/tests/.crumb
index d8085580..7d50576c 100644
--- a/native/kernel/svc/tests/.crumb
+++ b/native/kernel/svc/tests/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-04T13:47:18Z",
+      "compiled_at": "2026-10-06T01:02:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:2815a08ee2c689d59a24bc81ec578a1068cd2bbc34737bb16418e0ebd8ecb3f9",
+      "digest": "sha256:c64e9742262522ca9b9a0b76ec28beb02a1ab7a3b9284bd85f5710391d143dcf",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 3,
-      "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512",
-      "source_tree": "sha256:da553dcfc95bfaceb95162c1f54f51947b22132b51e6859375a44d87182df3e4"
+      "generated_at_commit": "20587476bf0d4b7577cc3b62857a9166300681bf",
+      "source_tree": "sha256:e0eb26d5ea897406da2b1fd37c676ec2b2a206468d14c70317073c00e1cbd716"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/svc/tests/ck_host.c b/native/kernel/svc/tests/ck_host.c
index 9c8e4975..d31aea9d 100644
--- a/native/kernel/svc/tests/ck_host.c
+++ b/native/kernel/svc/tests/ck_host.c
@@ -71,6 +71,8 @@ uint64_t ck_time_us(void)
 }
 void ck_udelay(uint32_t us) { (void)us; }
 const char *ck_commit(void) { return "host-test-commit"; }
+unsigned ck_exception_level(void) { return 1; }
+uint64_t ck_conventional_memory_kb(void) { return 42; }
 uint32_t ck_boot_count_hint(void) { return 0; }
 
 /* Host: the capability library reads the real /dev/urandom. */
diff --git a/native/kernel/svc/tests/stage_test.c b/native/kernel/svc/tests/stage_test.c
index 419ce6ae..008a6a22 100644
--- a/native/kernel/svc/tests/stage_test.c
+++ b/native/kernel/svc/tests/stage_test.c
@@ -21,6 +21,8 @@
 #include "net_bind.h"
 #include "net_udp.h"
 #include "xhci_fence.h"
+#include "usb_hid.h"
+#include <stdarg.h>
 
 static int checks, failures;
 #define CHECK(c)                                                                 \
@@ -845,6 +847,126 @@ static void test_artifact_store(void)
     unlink(aimg);
 }
 
+/* ---------------- operator input pure logic (dev/usb_hid.c) ---------------- */
+
+static char g_echo[256];
+static size_t g_echo_n;
+static void t_echo(char c) { if (g_echo_n < sizeof g_echo - 1) g_echo[g_echo_n++] = c; }
+static char g_sh[512];
+static void t_out(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    size_t n = strlen(g_sh);
+    vsnprintf(g_sh + n, sizeof g_sh - n, fmt, ap);
+    va_end(ap);
+}
+
+static void test_usb_hid(void)
+{
+    /* keymap */
+    CHECK(ck_hid_usage(0x04, 0).kind == CK_KEY_CHAR && ck_hid_usage(0x04, 0).c == 'a');
+    CHECK(ck_hid_usage(0x1d, 1).c == 'Z');
+    CHECK(ck_hid_usage(0x1e, 0).c == '1' && ck_hid_usage(0x27, 0).c == '0');
+    CHECK(ck_hid_usage(0x1e, 1).kind == CK_KEY_NONE); /* shifted digit: not in the keymap */
+    CHECK(ck_hid_usage(0x28, 0).kind == CK_KEY_ENTER && ck_hid_usage(0x2a, 0).kind == CK_KEY_BACKSPACE);
+    CHECK(ck_hid_usage(0x29, 0).kind == CK_KEY_ESCAPE && ck_hid_usage(0x2c, 0).c == ' ');
+    CHECK(ck_hid_usage(0x3a, 0).kind == CK_KEY_NONE); /* F1 */
+
+    /* decode: new usages only, rollover ignored, wrong length ignored */
+    ck_hid_decoder d = {{0}};
+    ck_key_event ev[CK_HID_MAX_KEYS];
+    uint8_t r1[8] = {0, 0, 0x04, 0, 0, 0, 0, 0};
+    CHECK(ck_hid_decode(&d, r1, 8, ev) == 1 && ev[0].c == 'a');
+    CHECK(ck_hid_decode(&d, r1, 8, ev) == 0); /* still held: no repeat */
+    uint8_t r2[8] = {0x02, 0, 0x04, 0x05, 0, 0, 0, 0};
+    CHECK(ck_hid_decode(&d, r2, 8, ev) == 1 && ev[0].c == 'B');
+    uint8_t roll[8] = {0, 0, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+    CHECK(ck_hid_decode(&d, roll, 8, ev) == 0);
+    CHECK(ck_hid_decode(&d, r2, 8, ev) == 0); /* rollover kept the previous state */
+    uint8_t up[8] = {0};
+    CHECK(ck_hid_decode(&d, up, 8, ev) == 0);
+    CHECK(ck_hid_decode(&d, r1, 8, ev) == 1 && ev[0].c == 'a'); /* pressed again after release */
+    CHECK(ck_hid_decode(&d, r1, 7, ev) == 0);
+
+    /* configuration descriptor (same fixtures as the Rust descriptor.rs tests) */
+    static const uint8_t kbd[34] = {9, 2, 34, 0, 1, 1, 8, 0xa0, 50, 9, 4, 0, 0, 1, 3, 1, 1, 0,
+                                    9, 0x21, 0x11, 0x01, 0, 1, 0x22, 63, 0, 7, 5, 0x81, 3, 8, 0, 7};
+    ck_boot_kbd bk;
+    CHECK(ck_usb_find_boot_kbd(kbd, sizeof kbd, &bk) == 0 && bk.configuration == 1 && bk.interface == 0 &&
+          bk.endpoint == 0x81 && bk.max_packet == 8 && bk.interval == 7);
+    static const uint8_t comp[50] = {9, 2, 50, 0, 2, 2, 0, 0xa0, 50, 9, 4, 0, 0, 1, 3, 1, 2, 0, 7, 5, 0x81, 3, 4, 0, 10,
+                                     9, 4, 1, 0, 2, 3, 1, 1, 0, 7, 5, 0x02, 3, 8, 0, 10, 7, 5, 0x83, 3, 8, 0, 4, 0, 0};
+    CHECK(ck_usb_find_boot_kbd(comp, sizeof comp, &bk) == 0 && bk.interface == 1 && bk.endpoint == 0x83 && bk.interval == 4);
+    uint8_t bad[34];
+    memcpy(bad, kbd, sizeof bad);
+    bad[27] = 40; /* endpoint length runs past wTotalLength */
+    CHECK(ck_usb_find_boot_kbd(bad, sizeof bad, &bk) == -1);
+    memcpy(bad, kbd, sizeof bad);
+    bad[16] = 2; /* protocol mouse: no keyboard */
+    CHECK(ck_usb_find_boot_kbd(bad, sizeof bad, &bk) == -1);
+    CHECK(ck_usb_find_boot_kbd(kbd, 8, &bk) == -1);
+    memcpy(bad, kbd, sizeof bad);
+    bad[9] = 1; /* zero-progress descriptor length */
+    CHECK(ck_usb_find_boot_kbd(bad, sizeof bad, &bk) == -1);
+
+    /* line editor: echo, backspace, Enter, fail closed on overflow */
+    ck_line l;
+    ck_line_reset(&l);
+    g_echo_n = 0;
+    ck_key_event a = {CK_KEY_CHAR, 'a'}, b = {CK_KEY_CHAR, 'b'}, bs = {CK_KEY_BACKSPACE, 0}, en = {CK_KEY_ENTER, 0};
+    CHECK(ck_line_feed(&l, a, t_echo) == CK_LINE_MORE && ck_line_feed(&l, b, t_echo) == CK_LINE_MORE);
+    CHECK(ck_line_feed(&l, bs, t_echo) == CK_LINE_MORE && l.len == 1);
+    CHECK(ck_line_feed(&l, en, t_echo) == CK_LINE_DONE && strcmp(l.buf, "a") == 0);
+    CHECK(g_echo_n == 3 && g_echo[0] == 'a' && g_echo[1] == 'b' && g_echo[2] == '\b');
+    ck_line_reset(&l);
+    ck_key_event x = {CK_KEY_CHAR, 'x'};
+    for (unsigned i = 0; i < CK_LINE_CAP; i++) CHECK(ck_line_feed(&l, x, 0) == CK_LINE_MORE);
+    CHECK(l.len == CK_LINE_CAP && !l.overflow);
+    CHECK(ck_line_feed(&l, x, 0) == CK_LINE_MORE && l.overflow && l.len == CK_LINE_CAP);
+    CHECK(ck_line_feed(&l, bs, 0) == CK_LINE_MORE && l.len == CK_LINE_CAP); /* no backing out of an overflow */
+    CHECK(ck_line_feed(&l, en, 0) == CK_LINE_OVERFLOW && l.len == 0 && l.buf[0] == 0 && l.typed == CK_LINE_CAP + 1);
+    ck_line_reset(&l);
+    for (unsigned i = 0; i < CK_LINE_CAP; i++) (void)ck_line_feed(&l, x, 0);
+    CHECK(ck_line_feed(&l, en, 0) == CK_LINE_DONE && l.len == CK_LINE_CAP); /* exactly at the bound is accepted */
+
+    /* shell (Rust shell.rs texts) */
+    ck_shell_ctx ctx = {42, 1, 7, "c0ffee"};
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("help", &ctx, t_out) == 0 && strcmp(g_sh, "commands: help mem el report uptime exit\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("el", &ctx, t_out) == 0 && strcmp(g_sh, "EL1\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run(" mem ", &ctx, t_out) == 0 && strcmp(g_sh, "conventional_memory_kb: 42\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("uptime", &ctx, t_out) == 0 && strcmp(g_sh, "uptime_ms: 7\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("report", &ctx, t_out) == 0 && strstr(g_sh, "aienos_commit: c0ffee") != NULL);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("wat", &ctx, t_out) == 0 && strcmp(g_sh, "unknown command: wat\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("x a b", &ctx, t_out) == 0 && strcmp(g_sh, "invalid command line\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("x 12345678901234567", &ctx, t_out) == 0 && strcmp(g_sh, "invalid command line\n") == 0);
+    g_sh[0] = 0;
+    CHECK(ck_shell_run("exit", &ctx, t_out) == 1 && g_sh[0] == 0);
+    CHECK(ck_shell_parse("", 0) == CK_SH_EMPTY && ck_shell_parse("unknown abc", 11) == CK_SH_UNKNOWN);
+
+    /* recovery decision and identity digest */
+    ck_key_event r = {CK_KEY_CHAR, 'r'}, R = {CK_KEY_CHAR, 'R'};
+    CHECK(ck_recovery_decide(0, r) == CK_RECOVERY_NORMAL_TIMEOUT);
+    CHECK(ck_recovery_decide(1, r) == CK_RECOVERY_CONSOLE && ck_recovery_decide(1, R) == CK_RECOVERY_CONSOLE);
+    CHECK(ck_recovery_decide(1, a) == CK_RECOVERY_NORMAL_KEY && ck_recovery_decide(1, en) == CK_RECOVERY_NORMAL_KEY);
+    CHECK(strcmp(ck_recovery_name(CK_RECOVERY_CONSOLE), "recovery reason=key-r") == 0);
+    uint8_t id[32], want[32];
+    static const char msg[] = "AIENOS-CK-RECOVERY-IDENTITY-V1\0abc";
+    sha256_hash((const uint8_t *)msg, sizeof msg - 1, want);
+    ck_recovery_identity("abc", id);
+    CHECK(memcmp(id, want, 32) == 0);
+    ck_recovery_identity("abd", want);
+    CHECK(memcmp(id, want, 32) != 0);
+}
+
 int main(void)
 {
     setvbuf(stdout, NULL, _IOLBF, 0);
@@ -858,6 +980,7 @@ int main(void)
     test_nvme_shutdown();
     test_net_udp();
     test_xhci_fence();
+    test_usb_hid();
     printf("CK_STAGE_HOST: %s checks=%d failures=%d\n", failures ? "FAIL" : "PASS", checks, failures);
     return failures ? 1 : 0;
 }
diff --git a/scripts/.crumb b/scripts/.crumb
index 53e13d0b..c423ddb6 100644
--- a/scripts/.crumb
+++ b/scripts/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-05T19:26:03Z",
+      "compiled_at": "2026-10-06T01:02:05Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:987eb5d8a450f5aaf1f821e428d30c06538cc5135d943892339157f9359e6938",
+      "digest": "sha256:e8e8c21a3f1b0e2a2df96918fd438edf57c0f38095d04c9abc529225c4da9363",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 65,
-      "generated_at_commit": "32256ba94a0bbabbe8f7ba201e7126b57fe4e4ea",
-      "source_tree": "sha256:61a25c98d59872bd3962dbae7bf7874793edc56d56063e3b316986654ef52f39"
+      "generated_at_commit": "20587476bf0d4b7577cc3b62857a9166300681bf",
+      "source_tree": "sha256:66055c3a599af41cb73b5dd2d177ea04241662ce3e3ceaad59e3012cc218faea"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/scripts/ck_gates.sh b/scripts/ck_gates.sh
index 333af731..a550d4f3 100755
--- a/scripts/ck_gates.sh
+++ b/scripts/ck_gates.sh
@@ -7,7 +7,8 @@
 # scripts/qemu_ck_net_test.sh, scripts/qemu_ck_artifact_test.sh,
 # scripts/qemu_ck_smp_test.sh, scripts/qemu_ck_store_crash_test.sh,
 # scripts/qemu_ck_disk_layout_test.sh, scripts/qemu_ck_continuity_test.sh,
-# scripts/qemu_ck_recovery_test.sh, scripts/qemu_ck_allen_test.sh, scripts/qemu_ck_fpu_test.sh,
+# scripts/qemu_ck_recovery_test.sh, scripts/qemu_ck_allen_test.sh,
+# scripts/qemu_ck_keyboard_test.sh, scripts/qemu_ck_fpu_test.sh,
 # scripts/qemu_ck_infer_test.sh, scripts/qemu_ck_screen_test.sh), and prints
 # one line per gate:
 #     AIENOS_CK_<gate>: PASS|FAIL|NOT_RUN [(reason)]
@@ -21,7 +22,7 @@
 #
 # QEMU is an emulator: a PASS here qualifies nothing physical (the receipt
 # says "physical": "NOT_RUN"). The child scripts serialise themselves: the
-# FPU, INFER and SCREEN children take the QEMU gate lock (~/workspace/.qemu-gate-lock,
+# KEYBOARD, FPU, INFER and SCREEN children take the QEMU gate lock (~/workspace/.qemu-gate-lock,
 # exclusive create) and report NOT_RUN while another gate run holds it or
 # while the machine quiet flag (~/workspace/.spark-quiet) exists, which they
 # only read (no agent raises the quiet flag without Drake's approval); the
@@ -54,6 +55,7 @@ set -uo pipefail
 #         cont  -> verdict line from scripts/qemu_ck_continuity_test.sh
 #         recov -> verdict line from scripts/qemu_ck_recovery_test.sh
 #         allen -> verdict line from scripts/qemu_ck_allen_test.sh (ALLEN genesis/restore, OS-0018 PROPOSED)
+#         kbd   -> verdict line from scripts/qemu_ck_keyboard_test.sh (xHCI keyboard, recovery access; keys from QEMU sendkey)
 #         fpu   -> verdict line from scripts/qemu_ck_fpu_test.sh (NOT_RUN without the Rust target)
 #         infer -> verdict line from scripts/qemu_ck_infer_test.sh (NOT_RUN without the model file or the Rust target)
 #         screen -> verdict line from scripts/qemu_ck_screen_test.sh (GOP framebuffer console vs a QMP screendump)
@@ -73,7 +75,7 @@ M4_CONTINUITY|cont|-
 M4_RECOVERY|recov|-
 M4_ALLEN|allen|-
 ARGUS1_REVOKE|store|-
-KEYBOARD|missing|no xHCI/USB HID keyboard driver in the C kernel
+KEYBOARD|kbd|-
 NET|net|-
 SMP|smp|-
 DISK_LAYOUT|disk|-
@@ -81,7 +83,7 @@ FPU|fpu|-
 INFER|infer|-
 SCREEN|screen|-
 '
-CHILDREN=(boot store net artifact smp crash disk cont recov allen fpu infer screen)
+CHILDREN=(boot store net artifact smp crash disk cont recov allen kbd fpu infer screen)
 # ===========================================================================
 
 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -129,6 +131,7 @@ set_default_children() {
         [cont]="${repo_root}/scripts/qemu_ck_continuity_test.sh"
         [recov]="${repo_root}/scripts/qemu_ck_recovery_test.sh"
         [allen]="${repo_root}/scripts/qemu_ck_allen_test.sh"
+        [kbd]="${repo_root}/scripts/qemu_ck_keyboard_test.sh"
         [fpu]="${repo_root}/scripts/qemu_ck_fpu_test.sh"
         [infer]="${repo_root}/scripts/qemu_ck_infer_test.sh"
         [screen]="${repo_root}/scripts/qemu_ck_screen_test.sh"
@@ -365,7 +368,7 @@ self_test() {
     }
     scenario() { # NAME BOOT_SCRIPT STORE_SCRIPT [NET_SCRIPT] [ARTIFACT_SCRIPT] [SMP_SCRIPT] [CRASH_SCRIPT] [DISK_SCRIPT] (absent: missing)
         scen="$1"
-        declare -gA child_script=([boot]="$2" [store]="$3" [net]="${4:-${tmp}/kids/net_not_present.sh}" [artifact]="${5:-${tmp}/kids/no_artifact_child.sh}" [smp]="${6:-${tmp}/kids/no_smp_child.sh}" [crash]="${7:-${tmp}/kids/no_crash_child.sh}" [disk]="${8:-${tmp}/kids/no_disk_child.sh}" [cont]="${tmp}/kids/no_cont_child.sh" [recov]="${tmp}/kids/no_recov_child.sh" [allen]="${tmp}/kids/no_allen_child.sh" [fpu]="${tmp}/kids/no_fpu_child.sh" [infer]="${tmp}/kids/no_infer_child.sh" [screen]="${tmp}/kids/no_screen_child.sh")
+        declare -gA child_script=([boot]="$2" [store]="$3" [net]="${4:-${tmp}/kids/net_not_present.sh}" [artifact]="${5:-${tmp}/kids/no_artifact_child.sh}" [smp]="${6:-${tmp}/kids/no_smp_child.sh}" [crash]="${7:-${tmp}/kids/no_crash_child.sh}" [disk]="${8:-${tmp}/kids/no_disk_child.sh}" [cont]="${tmp}/kids/no_cont_child.sh" [recov]="${tmp}/kids/no_recov_child.sh" [allen]="${tmp}/kids/no_allen_child.sh" [kbd]="${kbd_kid:-${tmp}/kids/no_kbd_child.sh}" [fpu]="${tmp}/kids/no_fpu_child.sh" [infer]="${tmp}/kids/no_infer_child.sh" [screen]="${tmp}/kids/no_screen_child.sh")
         run_children 2>/dev/null
         evaluate_table >"${tmp}/${scen}.out"
     }
@@ -388,8 +391,10 @@ self_test() {
         && ok "A: M4_NVME PASS line carries the confined-mode note" || bad "A: M4_NVME PASS line lacks the note"
     grep -qxF "AIENOS_CK_NET: PASS (${NET_PASS_NOTE})" "${tmp}/A.out" \
         && ok "A: NET PASS line carries the QEMU slirp / SMMU fence note" || bad "A: NET PASS line lacks the note"
-    grep -qx 'AIENOS_CK_KEYBOARD: NOT_RUN (MISSING_IMPLEMENTATION: no xHCI/USB HID keyboard driver in the C kernel)' "${tmp}/A.out" \
-        && ok "A: missing gate prints NOT_RUN (MISSING_IMPLEMENTATION: reason)" || bad "A: KEYBOARD line wrong"
+    grep -qxF 'AIENOS_CK_M0_ROLLBACK: NOT_RUN (MISSING_IMPLEMENTATION: C loader signatures, A/B, BootNext and rollback are parked (native/boot/README.md))' "${tmp}/A.out" \
+        && ok "A: missing gate prints NOT_RUN (MISSING_IMPLEMENTATION: reason)" || bad "A: M0_ROLLBACK line wrong"
+    grep -q '^AIENOS_CK_KEYBOARD: NOT_RUN' "${tmp}/A.out" \
+        && ok "A: KEYBOARD claimed PASS by the store child stays NOT_RUN without its own child" || bad "A: KEYBOARD line wrong"
     [[ "$(grep -c '^AIENOS_CK_[A-Z0-9_]*: ' "${tmp}/A.out")" == 20 ]] && ok "A: exactly 20 verdict lines" || bad "A: verdict line count"
 
     # B: boot FAIL; store script missing -> its three gates NOT_RUN, never PASS.
@@ -481,6 +486,18 @@ self_test() {
     scenario V "$(fake bootV 0 'AIENOS_CK_M1: PASS')" "$(fake storeV 0 'AIENOS_CK_M4_NVME: PASS')" "" "" "" "" \
         "$(fake diskV 1 'AIENOS_CK_DISK_LAYOUT: PASS')"
     expect DISK_LAYOUT FAIL
+    # W, X, Y: KEYBOARD comes only from its own child (scripts/qemu_ck_keyboard_test.sh):
+    # PASS with exit 0 is PASS, a FAIL verdict is FAIL, exit 3 (lock or quiet flag) is NOT_RUN.
+    kbd_kid="$(fake kbdW 0 'ROW 30 PASS  smmu: overflow line refused' 'AIENOS_CK_KEYBOARD_DMA: PASS' 'AIENOS_CK_KEYBOARD: PASS (rows 25-32)')"
+    scenario W "$(fake bootW 0 'AIENOS_CK_M1: PASS')" "$(fake storeW 0 'AIENOS_CK_KEYBOARD: FAIL')"
+    expect KEYBOARD PASS
+    kbd_kid="$(fake kbdX 1 'ROW 29 FAIL  smmu: shell line missing' 'AIENOS_CK_KEYBOARD: FAIL')"
+    scenario X "$(fake bootX 0 'AIENOS_CK_M1: PASS')" "$(fake storeX 0 'AIENOS_CK_KEYBOARD: PASS')"
+    expect KEYBOARD FAIL
+    kbd_kid="$(fake kbdY 3 'NOT_RUN  QEMU gate lock held' 'AIENOS_CK_KEYBOARD: NOT_RUN (gate lock held)')"
+    scenario Y "$(fake bootY 0 'AIENOS_CK_M1: PASS')" "$(fake storeY 0 'AIENOS_CK_M4_NVME: PASS')"
+    expect KEYBOARD NOT_RUN
+    unset kbd_kid
 
     # Receipt: named by its content hash, valid JSON, physical NOT_RUN, never overwritten.
     scenario R "$(fake bootR 0 'AIENOS_CK_M1: PASS')" "$(fake storeR 0 'AIENOS_CK_M4_NVME: PASS')"
@@ -506,7 +523,7 @@ self_test() {
         jq -e '.physical == "NOT_RUN" and (.gates | length) == 20 and .verdict == "NOT_ALL_GATES_PASS"
                and ([.gates[] | select(.id == "M1")][0].verdict == "PASS")
                and ([.gates[] | select(.id == "ARGUS1_REVOKE")][0].verdict == "FAIL")
-               and (.children | length) == 13 and .commit_subject == "quote \" backslash \\ tab\tend"' "${receipt_path}" >/dev/null \
+               and (.children | length) == 14 and .commit_subject == "quote \" backslash \\ tab\tend"' "${receipt_path}" >/dev/null \
             && ok "receipt is valid JSON (jq) with expected fields" || bad "receipt JSON invalid or fields wrong"
     else
         echo "NOT_RUN  jq not installed; JSON validity not machine-checked"; jq_skipped=1
@@ -525,7 +542,7 @@ self_test() {
         [[ -n "${g}" ]] || continue
         rows=$((rows + 1))
         case "${s}" in
-            boot|store|net|artifact|smp|crash|disk|cont|recov|allen|fpu|infer|screen) [[ "${w}" == - ]] || tbad=1 ;;
+            boot|store|net|artifact|smp|crash|disk|cont|recov|allen|kbd|fpu|infer|screen) [[ "${w}" == - ]] || tbad=1 ;;
             missing) [[ -n "${w}" && "${w}" != - ]] || tbad=1 ;;
             *) tbad=1 ;;
         esac
diff --git a/scripts/qemu_ck_keyboard_test.sh b/scripts/qemu_ck_keyboard_test.sh
index b4f0ed0e..b61edb15 100755
--- a/scripts/qemu_ck_keyboard_test.sh
+++ b/scripts/qemu_ck_keyboard_test.sh
@@ -1,44 +1,68 @@
 #!/usr/bin/env bash
-# KEYBOARD gate for the AIENOS C kernel, DMA-safety half only: rows 25-28, 31
-# and 32 of native/kernel/GATES.md "SEED-0A keyboard" (Rust oracle:
-# scripts/qemu_keyboard_test.sh with SMMU=1 and SMMU=0). Rows 29-30 (keyboard
-# attached, typed line echoed, console shell) stay NOT_RUN
-# (MISSING_IMPLEMENTATION: the C kernel has no USB HID driver and no console
-# shell), so the KEYBOARD gate itself stays NOT_RUN whatever this prints.
+# KEYBOARD gate for the AIENOS C kernel: rows 25-32 of native/kernel/GATES.md
+# "SEED-0A keyboard" (Rust oracle: scripts/qemu_keyboard_test.sh with SMMU=1
+# and SMMU=0) plus the C-only rows 30a-30c (recovery access, line overflow).
 # QEMU is not hardware: a PASS here qualifies nothing physical.
 #
 # Boots the full C image (make full) in QEMU AArch64 with UEFI (AAVMF), an
 # NVMe disk (normal full boot), a qemu-xhci controller with a usb-kbd on it
 # (the Rust gate's devices) and no NIC. The devices stage
 # (native/kernel/dev/devices.c) runs the post-exit bus-master sweep first and
-# the xHCI DMA fence (native/kernel/dev/xhci_fence.c) last.
+# the xHCI DMA fence (native/kernel/dev/xhci_fence.c) last; inside the
+# confined grant the operator phase (native/kernel/dev/usb_kbd.c) drives the
+# keyboard. Keys are typed from OUTSIDE the guest through the QEMU monitor
+# ("sendkey", as the Rust gate does); the kernel never fakes the device.
 #
-#  boot kbd-smmu    iommu=smmuv3 (Rust SMMU=1):
+#  boot kbd-smmu      iommu=smmuv3 (Rust SMMU=1). No key in the recovery
+#                     window (normal boot by timeout), then the lines "abc",
+#                     "help", "el", "mem", 65 x "x" (overflow) and "exit":
 #   row 25  "keyboard: xhci SSSS:BB:DD.F mmio 0x.." (found on the ECAM walk)
 #   row 26  "dma_sweep: seg 0000 bus .." before the first device DMA grant,
 #           no "dma_sweep: bme STUCK"
 #   row 27  "xhci_pci: command=0x.... bus_master=off" before the xHCI DMA gate
+#   row 29  "keyboard: ready", "keyboard_echo: abc", "keyboard_line: abc",
+#           "keyboard: done (enter)", all between the confined grant and the
+#           revoke
+#   row 30  "commands: help mem el report uptime exit", "EL1",
+#           "conventional_memory_kb: N" (N > 0), "keyboard: done (exit)"
+#   row 30a (C only) recovery access offered after "keyboard: ready" and
+#           decided "choice=normal reason=timeout" before the shell starts
+#   row 30c (C only) the 65-key line is refused ("keyboard_line: overflow
+#           (line refused: 65 keys typed, limit 64)"), never echoed back as a
+#           line and never run as a command
 #   row 31  grant confined ("smmu_dma_window: xhci only, translation active",
 #           "dma_gate: xhci granted (Confined), bus master on"), controller
 #           halted, "dma_gate: xhci bus master revoked", COMMAND read back
 #           "xhci_pci: after phase command=0x.... bus_master=off", "smmu: xhci
 #           stream 0x.. returned to abort (rc=0)", in that order, all before
-#           the "devices: xhci=fenced (rc=0)" line (so a later reset-time
-#           quiesce revoke cannot stand in for it)
+#           the "devices: xhci=fenced (rc=0)" line
 #   row 32  no "report_kind: (panic|fault)", "report_kind: final", QEMU exit 0
-#  boot kbd-nosmmu  no SMMU (Rust SMMU=0), same image:
+#  boot kbd-nosmmu    no SMMU (Rust SMMU=0), same image, no keys:
 #   rows 25, 26, 27, 32 as above
 #   row 28  "dma_gate: xhci denied (NoSmmu), bus master stays off", "keyboard:
 #           unavailable (SMMU DMA isolation not active)", COMMAND read back
 #           after the deny with bus_master=off, no "dma_gate: xhci granted",
 #           no "keyboard: ready"
-# Both boots must also pass every M1 check (scripts/lib_ck_m1_checks.sh) and
-# carry no TEST-ONLY mutation banner and no "UNSAFE DMA BYPASS".
+#   row 30a recovery access reported unavailable, normal boot
+#           ("choice=normal reason=no-keyboard")
+#  boot kbd-recovery  iommu=smmuv3, same image; "r" typed in the recovery window:
+#   row 30b (C only) "recovery_access: choice=recovery reason=key-r"; then, in
+#           order: xHCI bus master revoked, xHCI stream back to abort,
+#           "devices: recovery halt nvme=released virtio_net=released
+#           xhci=released", the stub's identity line (the SHA-256 this script
+#           recomputes from the commit), "recovery_console: halted"; no shell,
+#           no Store stage, no final report, no panic or fault, and QEMU still
+#           running 3 s after the halt line (halted, not reset; the script
+#           then stops QEMU)
+# kbd-smmu and kbd-nosmmu must also pass every M1 check
+# (scripts/lib_ck_m1_checks.sh); all boots carry no TEST-ONLY mutation
+# banner, no "UNSAFE DMA BYPASS" and no "keyboard: hid NOT_IMPLEMENTED".
 #
-# --mutation (self-test of the checks above; TEST-ONLY images): builds
-# "make full CK_TEST_XHCI_MUTATION=<m>" for each mutation and boots it once;
-# the named row must FAIL (and the boot must still reach "report_kind: final"
-# with row 25 PASS, so the failure is the mutation's, not a dead boot):
+# --mutation (self-test of the DMA checks; TEST-ONLY images): builds
+# "make full CK_TEST_XHCI_MUTATION=<m>" for each mutation and boots it once
+# without keys; the named row must FAIL (and the boot must still reach
+# "report_kind: final" with row 25 PASS, so the failure is the mutation's,
+# not a dead boot):
 #   bm-left-on     xHCI bus mastering switched back on after the sweep (smmu)  -> row 27
 #   no-revoke      release skips the bus-master clear (smmu)                    -> row 31
 #   grant-no-smmu  DMA granted without an SMMU (nosmmu)                         -> row 28
@@ -47,13 +71,17 @@
 # CK_HARDWARE_STAGING=1 (and with CK_QEMU_UNSAFE_DMA=1), and that the default
 # image carries no mutation banner.
 #
-# Env: AIENOS_QEMU_SMMU=1 or 0 runs only that boot (default: both).
-# Takes the machine quiet flag itself like the other qemu_ck_* scripts
-# (AIENOS_QUIET_FLAG / AIENOS_QUIET_TAG).
+# Env: AIENOS_QEMU_SMMU=1 runs only kbd-smmu and kbd-recovery, =0 only
+# kbd-nosmmu (a partial run: the gate verdict is then NOT_RUN).
+# Like the FPU/INFER/SCREEN children: NOT_RUN (exit 3) while the machine quiet
+# flag (AIENOS_QUIET_FLAG, default ~/workspace/.spark-quiet) exists, which this
+# script only reads and never writes, or while the QEMU gate lock
+# (AIENOS_GATE_LOCK, default ~/workspace/.qemu-gate-lock, exclusive create) is
+# held by another gate run.
 # Final lines (normal run): one "KEYBOARD_ROW <n>: PASS|FAIL|NOT_RUN (...)"
-# per row 25-32, "AIENOS_CK_KEYBOARD_DMA: PASS|FAIL (rows 25-28,31,32)" and
-# "AIENOS_CK_KEYBOARD: NOT_RUN (MISSING_IMPLEMENTATION: ...)". Exit 0 when
-# the DMA rows PASS, 1 FAIL, 2 missing tools, 3 NOT_RUN (quiet flag held).
+# per row, "AIENOS_CK_KEYBOARD_DMA: PASS|FAIL (rows 25-28,31,32)" and
+# "AIENOS_CK_KEYBOARD: PASS|FAIL|NOT_RUN (...)" (read by scripts/ck_gates.sh).
+# Exit 0 when the gate PASSes, 1 FAIL, 2 missing tools, 3 NOT_RUN.
 # --mutation: "AIENOS_CK_KEYBOARD_MUTATION: PASS|FAIL"; exit 0 / 1.
 # Needs qemu-system-aarch64, AAVMF (Ubuntu: qemu-system-arm qemu-efi-aarch64)
 # and a C compiler.
@@ -68,13 +96,13 @@ case "${1:-}" in
     --mutation) mutation_run=1 ;;
     *) echo "usage: $0 [--mutation]"; exit 2 ;;
 esac
-final_tag="AIENOS_CK_KEYBOARD_DMA"
+final_tag="AIENOS_CK_KEYBOARD"
 [[ "${mutation_run}" == 0 ]] || final_tag="AIENOS_CK_KEYBOARD_MUTATION"
 
 code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}"
 vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}"
-command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not installed"; echo "${final_tag}: NOT_RUN"; exit 2; }
-[[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "AAVMF firmware not found"; echo "${final_tag}: NOT_RUN"; exit 2; }
+command -v qemu-system-aarch64 >/dev/null || { echo "qemu-system-aarch64 not installed"; echo "${final_tag}: NOT_RUN (qemu-system-aarch64 missing)"; exit 2; }
+[[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "AAVMF firmware not found"; echo "${final_tag}: NOT_RUN (AAVMF missing)"; exit 2; }
 
 cross=""
 if [ "$(uname -m)" != "aarch64" ]; then cross="aarch64-linux-gnu-"; fi
@@ -88,24 +116,36 @@ if [[ "${mutation_run}" == 1 ]]; then
     for m in "${mutations[@]}"; do mk full CK_TEST_XHCI_MUTATION="${m}" >/dev/null; done
 fi
 
+# Machine-wide quiet flag: read only, never written here (Drake's rule: no
+# agent raises it without approval). If someone holds it: NOT_RUN.
 quiet_flag="${AIENOS_QUIET_FLAG:-${HOME}/workspace/.spark-quiet}"
-quiet_tag="${AIENOS_QUIET_TAG:-qemu_ck_keyboard_test $$}"
-if ! ( set -C; echo "${quiet_tag}" > "${quiet_flag}" ) 2>/dev/null; then
+if [[ -e "${quiet_flag}" ]]; then
     echo "NOT_RUN  quiet flag ${quiet_flag} is held: $(head -c 200 "${quiet_flag}" 2>/dev/null || true)"
-    echo "${final_tag}: NOT_RUN"
+    echo "${final_tag}: NOT_RUN (quiet flag held)"
     exit 3
 fi
-own_flag=1
-release_flag() {
-    if [[ "${own_flag}" == 1 ]]; then
-        own_flag=0
-        if [[ -f "${quiet_flag}" ]] && grep -qxF -- "${quiet_tag}" "${quiet_flag}"; then rm -f "${quiet_flag}"; fi
+# One QEMU gate at a time: exclusive create (set -C) of the gate lock.
+gate_lock="${AIENOS_GATE_LOCK:-${HOME}/workspace/.qemu-gate-lock}"
+gate_tag="${AIENOS_GATE_TAG:-qemu_ck_keyboard_test $$}"
+if ! ( set -C; echo "${gate_tag}" > "${gate_lock}" ) 2>/dev/null; then
+    echo "NOT_RUN  QEMU gate lock ${gate_lock} is held: $(head -c 200 "${gate_lock}" 2>/dev/null || true)"
+    echo "${final_tag}: NOT_RUN (QEMU gate lock held)"
+    exit 3
+fi
+own_lock=1
+release_lock() {
+    if [[ "${own_lock}" == 1 ]]; then
+        own_lock=0
+        if [[ -f "${gate_lock}" ]] && grep -qxF -- "${gate_tag}" "${gate_lock}"; then rm -f "${gate_lock}"; fi
     fi
 }
 top="$(mktemp -d)"
+qemu_pid=""
 cleanup() {
+    [[ -z "${qemu_pid}" ]] || kill "${qemu_pid}" 2>/dev/null || true
+    exec 3>&- 2>/dev/null || true
     rm -rf "${top}"
-    release_flag
+    release_lock
 }
 trap cleanup EXIT
 
@@ -115,19 +155,42 @@ img_bytes=67108864
 image="${top}/nvme.img"
 truncate -s "${img_bytes}" "${image}"
 m1_fail=0
+boot_timeout="${AIENOS_QEMU_TIMEOUT:-180}"
+overflow_keys=65
+
+serial_has() { tr -d '\r' 2>/dev/null <"${work}/serial.log" | grep -qE -- "$1"; }
+qemu_running() { [[ -n "${qemu_pid}" ]] && kill -0 "${qemu_pid}" 2>/dev/null; }
+# wait_for seconds ERE...: 0 once the serial log matches one, 1 on timeout or QEMU exit.
+wait_for() {
+    local deadline=$(( $(date +%s) + $1 )) p; shift
+    while (( $(date +%s) < deadline )) && qemu_running; do
+        for p in "$@"; do serial_has "${p}" && return 0; done
+        sleep 0.2
+    done
+    for p in "$@"; do serial_has "${p}" && return 0; done
+    return 1
+}
+# Keys go in through the QEMU monitor (outside the guest), 0.12 s apart.
+send_keys() { local k; for k in "$@"; do echo "sendkey ${k}" >&3; sleep 0.12; done; }
+send_line() { send_keys "$@" ret; sleep 0.5; }
 
-# boot <name> <efi> smmu|nosmmu: one QEMU boot; serial text in ${work}/serial.txt.
+# boot <name> <efi> smmu|nosmmu <action>: one QEMU boot; serial text in
+# ${work}/serial.txt, QEMU status in qemu_status, for recovery boots
+# halted_running=yes|no. action: none | shell | recovery.
 boot() {
     work="${top}/$1"
+    local action="$4"
     mkdir -p "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS"
     touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
     cp "$2" "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
     cp "${vars_fd}" "${work}/vars.fd"
+    rm -f "${work}/mon.in" "${work}/mon.out"
+    mkfifo "${work}/mon.in" "${work}/mon.out"
+    : >"${work}/serial.log"
     local machine="virt,virtualization=on,gic-version=3"
     [[ "$3" != smmu ]] || machine+=",iommu=smmuv3"
-    set +e
     # Issue #61: single-threaded TCG (see qemu_boot_test.sh).
-    timeout "${AIENOS_QEMU_TIMEOUT:-180}" qemu-system-aarch64 \
+    timeout "${boot_timeout}" qemu-system-aarch64 \
         -M "${machine}" -accel tcg,thread=single -cpu max -smp 4 -m 2048 \
         -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
         -drive if=pflash,format=raw,file="${work}/vars.fd" \
@@ -137,18 +200,55 @@ boot() {
         -device nvme,drive=nvme0,serial=aienos-kbd-test \
         -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0 \
         -device ramfb -display none -nic none \
-        -serial file:"${work}/serial.log" -no-reboot
+        -chardev pipe,id=mon,path="${work}/mon" -mon chardev=mon,mode=readline \
+        -serial file:"${work}/serial.log" -no-reboot 2>"${work}/qemu.err" &
+    qemu_pid=$!
+    cat "${work}/mon.out" >/dev/null &   # drain monitor output so QEMU never blocks
+    exec 3>"${work}/mon.in"
+    halted_running=no
+    case "${action}" in
+        shell)
+            # No key in the recovery window: the boot must continue by timeout.
+            if wait_for "${boot_timeout}" '^keyboard: shell ready' '^keyboard: unavailable' '^report_kind: (panic|fault|final)'; then
+                if serial_has '^keyboard: shell ready'; then
+                    send_line a b c
+                    send_line h e l p
+                    send_line e l
+                    send_line m e m
+                    local -a xs=()
+                    for ((i = 0; i < overflow_keys; i++)); do xs+=(x); done
+                    send_line "${xs[@]}"
+                    send_line e x i t
+                fi
+            fi ;;
+        recovery)
+            if wait_for "${boot_timeout}" '^recovery_access: waiting' '^recovery_access: unavailable' '^report_kind: (panic|fault|final)'; then
+                if serial_has '^recovery_access: waiting'; then
+                    send_keys r
+                    if wait_for 60 '^recovery_console: halted' '^report_kind: (panic|fault|final)' && serial_has '^recovery_console: halted'; then
+                        sleep 3
+                        qemu_running && halted_running=yes
+                    fi
+                fi
+            fi
+            kill "${qemu_pid}" 2>/dev/null || true ;;
+    esac
+    set +e
+    wait "${qemu_pid}"
     qemu_status=$?
     set -e
+    qemu_pid=""
+    exec 3>&- 2>/dev/null || true
     tr -d '\r' <"${work}/serial.log" >"${work}/serial.txt"
     [[ -z "${AIENOS_LOG_DIR:-}" ]] || cp "${work}/serial.txt" "${AIENOS_LOG_DIR}/qemu_ck_keyboard_$1.log"
-    echo "== boot $1 ($3): qemu exit ${qemu_status}"
+    echo "== boot $1 ($3, keys: ${action}): qemu exit ${qemu_status}$([[ "${action}" != recovery ]] || echo ", halted_running=${halted_running}")"
 }
 
 # Row bookkeeping: rowfail[n]=1 once any check of row n failed in this
 # evaluation; rowmodes[n] lists the boots that checked it.
+all_rows=(25 26 27 28 29 30 30a 30b 30c 31 32)
 declare -A rowfail rowmodes
-reset_rows() { for r in 25 26 27 28 31 32; do rowfail[$r]=0; rowmodes[$r]=""; done; }
+reset_rows() { local r; for r in "${all_rows[@]}"; do rowfail[$r]=0; rowmodes[$r]=""; done; }
 reset_rows
 mode=""
 note_mode() { [[ " ${rowmodes[$1]} " == *" ${mode} "* ]] || rowmodes[$1]="${rowmodes[$1]:+${rowmodes[$1]} }${mode}"; }
@@ -168,8 +268,8 @@ before() { # row, description, earlier ERE, later ERE: both present, earlier fir
     else rfail "$1" "$2 (lines ${a:-none} ${b:-none})"; fi
 }
 
-# evaluate smmu|nosmmu: every DMA-safety row check on ${work}/serial.txt.
-evaluate() {
+# evaluate_dma smmu|nosmmu|recovery: rows 25-28 and 31 on ${work}/serial.txt.
+evaluate_dma() {
     mode="$1"
     rcheck 25 "xHCI found on the ECAM walk (Rust: keyboard: xhci )" \
         '^keyboard: xhci 0000:[0-9a-f]{2}:[0-9a-f]{2}\.[0-7] mmio 0x[0-9a-f]+ '
@@ -205,62 +305,147 @@ evaluate() {
         before 31 "order: stream abort < end of the xHCI phase (not a reset-time revoke)" \
             '^smmu: xhci stream .* returned to abort' '^devices: xhci=fenced \(rc=0\)$'
     fi
+}
+
+# evaluate_final smmu|nosmmu: row 32 for a boot that must end with the final report.
+evaluate_final() {
+    mode="$1"
     rabsent 32 "no panic or fault" '^report_kind: (panic|fault)'
     rcheck 32 "final report reached" 'report_kind: final'
     if [[ "${qemu_status}" == 0 ]]; then rpass 32 "QEMU exit 0 after PSCI reset"; else rfail 32 "QEMU exit ${qemu_status} (expected 0)"; fi
 }
 
+# evaluate_input smmu|nosmmu: rows 29, 30, 30a, 30c.
+evaluate_input() {
+    mode="$1"
+    if [[ "${mode}" == nosmmu ]]; then
+        rcheck 30a "recovery access reported unavailable, normal boot" \
+            '^recovery_access: unavailable \(no operator keyboard: xhci=denied\); choice=normal reason=no-keyboard$'
+        rabsent 30a "no recovery wait without a keyboard" '^recovery_access: waiting'
+        return
+    fi
+    rcheck 29 "keyboard attached by the C driver (Rust: keyboard: ready)" '^keyboard: ready \(port [0-9]+, slot [0-9]+, endpoint 0x8[0-9a-f]\)$'
+    before 29 "keyboard attached inside the confined grant" '^dma_gate: xhci granted \(Confined\)' '^keyboard: ready'
+    rcheck 29 "typed text echoed (Rust: keyboard_echo: abc)" '^keyboard_echo: abc$'
+    rcheck 29 "line ended by Enter and reported (Rust: keyboard_line: abc)" '^keyboard_line: abc$'
+    rcheck 29 "keyboard phase line finished on Enter (Rust: keyboard: done (enter))" '^keyboard: done \(enter\)$'
+    before 29 "typed line before the revoke" '^keyboard_line: abc$' '^dma_gate: xhci bus master revoked$'
+    rcheck 30 "help command output" '^commands: help mem el report uptime exit$'
+    rcheck 30 "EL command output" '^EL1$'
+    rcheck 30 "memory command output" '^conventional_memory_kb: [1-9][0-9]*$'
+    rcheck 30 "keyboard phase finished on exit" '^keyboard: done \(exit\)$'
+    before 30 "exit before the revoke" '^keyboard: done \(exit\)$' '^dma_gate: xhci bus master revoked$'
+    rcheck 30a "recovery window offered" '^recovery_access: waiting [0-9]+ ms for an operator key'
+    rcheck 30a "no key: normal boot by timeout" '^recovery_access: choice=normal reason=timeout$'
+    before 30a "keyboard ready < recovery window" '^keyboard: ready' '^recovery_access: waiting'
+    before 30a "recovery decision < shell" '^recovery_access: choice=' '^keyboard: shell ready'
+    rabsent 30a "no recovery console on a normal boot" '^recovery_console:'
+    rcheck 30c "overlong line refused (fail closed)" \
+        "^keyboard_line: overflow \\(line refused: ${overflow_keys} keys typed, limit 64\\)\$"
+    rabsent 30c "overlong line never reported as a line" '^keyboard_line: x'
+    rabsent 30c "overlong line never run as a command" '^unknown command: x'
+}
+
+# evaluate_recovery: rows 30b, 31 and the recovery boot's no-panic check.
+evaluate_recovery() {
+    mode=recovery
+    local want
+    want="$(printf 'AIENOS-CK-RECOVERY-IDENTITY-V1\0%s' "${commit}" | sha256sum | cut -d' ' -f1)"
+    rcheck 29 "keyboard attached by the C driver" '^keyboard: ready \(port [0-9]+, slot [0-9]+, endpoint 0x8[0-9a-f]\)$'
+    rcheck 30b "operator key r selects the recovery console" '^recovery_access: choice=recovery reason=key-r$'
+    before 30b "order: choice < xHCI revoke" '^recovery_access: choice=recovery' '^dma_gate: xhci bus master revoked$'
+    before 30b "order: xHCI stream abort < recovery halt line" '^smmu: xhci stream .* returned to abort \(rc=0\)$' '^devices: recovery halt '
+    rcheck 30b "every device DMA released before the halt" '^devices: recovery halt nvme=released virtio_net=released xhci=released$'
+    rcheck 30b "stub prints the identity digest (recomputed here from the commit)" \
+        "^recovery_console: identity build_sha256=${want} commit=${commit} "
+    before 30b "order: recovery halt line < identity" '^devices: recovery halt ' '^recovery_console: identity '
+    before 30b "order: identity < halted" '^recovery_console: identity ' '^recovery_console: halted'
+    rabsent 30b "no shell on the recovery path" '^keyboard: shell ready'
+    rabsent 30b "no Store stage on the recovery path" '^stage store'
+    rabsent 30b "no final report on the recovery path" 'report_kind: final'
+    rabsent 30b "no panic or fault" '^report_kind: (panic|fault)'
+    if [[ "${halted_running}" == yes ]]; then rpass 30b "QEMU still running 3 s after the halt line (halted, not reset)"
+    else rfail 30b "QEMU was not running after the halt line (or the halt line never came)"; fi
+}
+
+image_checks() {
+    check_absent "no TEST-ONLY mutation banner in the default image" "TEST-ONLY xHCI MUTATION"
+    check_absent "no unsafe DMA bypass in this image" "UNSAFE DMA BYPASS"
+    check_absent "no leftover NOT_IMPLEMENTED HID marker" "^keyboard: hid NOT_IMPLEMENTED"
+    check "image is this commit" "aienos_commit: ${commit}"
+}
+
 if [[ "${mutation_run}" == 0 ]]; then
-    modes=(smmu nosmmu)
+    modes=(smmu nosmmu recovery)
     case "${AIENOS_QEMU_SMMU:-}" in
-        1) modes=(smmu) ;;
+        1) modes=(smmu recovery) ;;
         0) modes=(nosmmu) ;;
         "") ;;
-        *) echo "AIENOS_QEMU_SMMU must be 1, 0 or unset"; release_flag; echo "${final_tag}: NOT_RUN"; exit 2 ;;
+        *) echo "AIENOS_QEMU_SMMU must be 1, 0 or unset"; release_lock; echo "${final_tag}: NOT_RUN (bad AIENOS_QEMU_SMMU)"; exit 2 ;;
     esac
     other_fail=0
     for md in "${modes[@]}"; do
-        boot "kbd-${md}" "${default_efi}" "${md}"
+        case "${md}" in
+            smmu) boot kbd-smmu "${default_efi}" smmu shell ;;
+            nosmmu) boot kbd-nosmmu "${default_efi}" nosmmu none ;;
+            recovery) boot kbd-recovery "${default_efi}" smmu recovery ;;
+        esac
         failed=0
-        ck_m1_checks
-        [[ "${failed}" == 0 ]] || m1_fail=1
+        if [[ "${md}" != recovery ]]; then
+            ck_m1_checks
+            [[ "${failed}" == 0 ]] || m1_fail=1
+        fi
         failed=0
-        check_absent "no TEST-ONLY mutation banner in the default image" "TEST-ONLY xHCI MUTATION"
-        check_absent "no unsafe DMA bypass in this image" "UNSAFE DMA BYPASS"
-        check "honest marker: no USB HID driver yet (rows 29-30 NOT_RUN)" \
-            "^keyboard: hid NOT_IMPLEMENTED\|^keyboard: unavailable (SMMU DMA isolation not active)$"
+        image_checks
         [[ "${failed}" == 0 ]] || other_fail=1
         failed=0
-        evaluate "${md}"
+        evaluate_dma "${md}"
+        if [[ "${md}" == recovery ]]; then
+            evaluate_recovery
+        else
+            evaluate_input "${md}"
+            evaluate_final "${md}"
+        fi
+        echo "RECOVERY_CHOICE kbd-${md}: $(grep -m1 -E '^recovery_access: (choice=|unavailable)' "${work}/serial.txt" || echo 'none recorded')"
     done
-    release_flag
-    if [[ "${m1_fail}${other_fail}" != 00 || -n "${AIENOS_QEMU_VERBOSE:-}" ]] || (( rowfail[25] + rowfail[26] + rowfail[27] + rowfail[28] + rowfail[31] + rowfail[32] )); then
+    release_lock
+    any_fail=0
+    for r in "${all_rows[@]}"; do any_fail=$(( any_fail | rowfail[$r] )); done
+    if [[ "${m1_fail}${other_fail}" != 00 || -n "${AIENOS_QEMU_VERBOSE:-}" || "${any_fail}" != 0 ]]; then
         for s in "${top}"/*/serial.txt; do
             echo "---- serial console $(basename "$(dirname "${s}")") (device lines) ----"
-            grep -E '^(keyboard|xhci|xhci_pci|dma_sweep|dma_gate|smmu|devices:|stage |report_kind:)' "${s}" | head -60 || true
+            grep -E '^(keyboard|xhci|xhci_pci|dma_sweep|dma_gate|smmu|devices:|stage |report_kind:|recovery_|commands|EL[0-9]|conventional)' "${s}" | head -80 || true
         done
     fi
     dma_fail=$(( m1_fail | other_fail ))
+    gate_fail=$(( m1_fail | other_fail ))
+    partial=0
+    [[ -z "${AIENOS_QEMU_SMMU:-}" ]] || partial=1
     echo "== per-row results (QEMU only; hardware NOT_RUN)"
-    for r in 25 26 27 28 31 32; do
+    for r in "${all_rows[@]}"; do
         if [[ -z "${rowmodes[$r]}" ]]; then
             echo "KEYBOARD_ROW ${r}: NOT_RUN (not checked in this run's modes)"
-            [[ -n "${AIENOS_QEMU_SMMU:-}" ]] || dma_fail=1
+            partial=1
         elif [[ "${rowfail[$r]}" == 0 && "${m1_fail}" == 0 ]]; then
             echo "KEYBOARD_ROW ${r}: PASS (${rowmodes[$r]})"
         else
             echo "KEYBOARD_ROW ${r}: FAIL (${rowmodes[$r]}$([[ "${m1_fail}" == 0 ]] || echo '; an M1 check failed'))"
-            dma_fail=1
+            gate_fail=1
+            case "${r}" in 25|26|27|28|31|32) dma_fail=1 ;; esac
         fi
     done
-    echo "KEYBOARD_ROW 29: NOT_RUN (MISSING_IMPLEMENTATION: no USB HID driver in the C kernel)"
-    echo "KEYBOARD_ROW 30: NOT_RUN (MISSING_IMPLEMENTATION: no console shell in the C kernel)"
-    [[ "${m1_fail}" == 0 ]] || echo "M1 checks failed on at least one boot: the DMA rows cannot pass"
-    [[ "${other_fail}" == 0 ]] || echo "image checks failed (mutation banner, unsafe bypass or HID marker)"
-    if [[ "${dma_fail}" == 0 ]]; then echo "${final_tag}: PASS (rows 25-28,31,32; modes ${modes[*]})"; else echo "${final_tag}: FAIL (rows 25-28,31,32; modes ${modes[*]})"; fi
-    echo "AIENOS_CK_KEYBOARD: NOT_RUN (MISSING_IMPLEMENTATION: no USB HID driver or console shell in the C kernel; rows 29-30)"
-    [[ "${dma_fail}" == 0 ]] && exit 0
-    exit 1
+    [[ "${m1_fail}" == 0 ]] || echo "M1 checks failed on at least one boot: no row can pass"
+    [[ "${other_fail}" == 0 ]] || echo "image checks failed (mutation banner, unsafe bypass, HID marker or commit)"
+    if [[ "${dma_fail}" == 0 ]]; then echo "AIENOS_CK_KEYBOARD_DMA: PASS (rows 25-28,31,32; modes ${modes[*]})"; else echo "AIENOS_CK_KEYBOARD_DMA: FAIL (rows 25-28,31,32; modes ${modes[*]})"; fi
+    if [[ "${gate_fail}" != 0 ]]; then
+        echo "${final_tag}: FAIL (rows 25-32,30a-30c; modes ${modes[*]}; QEMU only)"
+        exit 1
+    elif [[ "${partial}" != 0 ]]; then
+        echo "${final_tag}: NOT_RUN (partial run, modes ${modes[*]}; every boot is needed for the gate)"
+        exit 3
+    fi
+    echo "${final_tag}: PASS (rows 25-32,30a-30c; boots kbd-smmu kbd-nosmmu kbd-recovery; QEMU only, hardware NOT_RUN)"
+    exit 0
 fi
 
 # ---- --mutation: every mutation must make its row FAIL ----
@@ -283,9 +468,10 @@ declare -A mut_mode=([bm-left-on]=smmu [no-revoke]=smmu [grant-no-smmu]=nosmmu [
 declare -A mut_row=([bm-left-on]=27 [no-revoke]=31 [grant-no-smmu]=28 [no-sweep]=26)
 for m in "${mutations[@]}"; do
     efi="${out}/full-test-xhci-${m}/BOOTAA64.EFI"
-    boot "mut-${m}" "${efi}" "${mut_mode[$m]}"
+    boot "mut-${m}" "${efi}" "${mut_mode[$m]}" none
     reset_rows
-    evaluate "${mut_mode[$m]}"
+    evaluate_dma "${mut_mode[$m]}"
+    evaluate_final "${mut_mode[$m]}"
     r="${mut_row[$m]}"
     if ! grep -qF "WARNING: TEST-ONLY xHCI MUTATION BUILD (CK_TEST_XHCI_MUTATION=${m}," "${work}/serial.txt"; then
         mut_bad "${m}: image did not announce the mutation"
@@ -297,7 +483,7 @@ for m in "${mutations[@]}"; do
         mut_bad "${m} (${mut_mode[$m]}): row ${r} still PASSES: the check does not catch this mutation"
     fi
 done
-release_flag
+release_lock
 if [[ "${mut_fail}" != 0 || -n "${AIENOS_QEMU_VERBOSE:-}" ]]; then
     for s in "${top}"/*/serial.txt; do
         echo "---- serial console $(basename "$(dirname "${s}")") (device lines) ----"