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

closed derived 7e0dc596e7c92771 #505

Imported from GitHub aien-dev/aienux#505 (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 25784d187969d5339d47c1fc11379c125c37a947 · Head eafc9c71e6cb3a00e6b5bc5954a8aa3762150204

Fetch it

A git bundle of the pull request's head, 8278 bytes.

curl -fsSL https://interplane.io/drakestapleton/aienux/patches/7e0dc596e7c92771.bundle -o 7e0dc596e7c92771.bundle
git fetch 7e0dc596e7c92771.bundle refs/pull/505/head

Raw bundle · 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
505
eafc9c71e6cb3a00e6b5bc5954a8aa3762150204
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":505,"url":"https://github.com/aien-dev/aienux/pull/505","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:38Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index eaa06564..d382908c 100644
--- a/.crumb
+++ b/.crumb
@@ -33,8 +33,8 @@
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
         {
-          "digest": "93e6e9eab515a36245e770ac5789a51b33daaa56ebddb6d6c7070fc65f047cd3",
-          "last_commit": "47973bb4",
+          "digest": "fc5393380b21025d37b375678a31dd10496e8baa4590615d2d76f10c4bb8ff98",
+          "last_commit": "1ff4dc91",
           "name": "native",
           "purpose": "Directory native. Purpose not yet described by a human."
         },
@@ -51,15 +51,15 @@
           "purpose": "First-party host artifact preparation tools"
         }
       ],
-      "children_root": "sha256:1032cc94531222dcaeafffcae91ddde712858e8a68df4845cfd719c62333798b",
-      "compiled_at": "2026-11-06T00:50:27Z",
+      "children_root": "sha256:e2e1fa85c723a4e46d188bf9bbf626756c5e4d6f63fcfa2c88f7c9248b566855",
+      "compiled_at": "2026-11-06T01:09:35Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:c4c9b96af51c878bbb675600b396ddd610fe2ca282f86f6fcb4c4ed4a2991ed6",
+      "digest": "sha256:367e3df0df6dc3fe5f79af44dde9c1803e8201577d65a58fb94512b2117391ff",
       "evidence_files": 274,
       "evidence_root": "sha256:af014a4ed8f6fe759fc5809807fb47578d3410811b522d9f65d749382b029802",
       "files": 3777,
-      "generated_at_commit": "47973bb401c35ff45002e8296a216a1558f663e0",
-      "source_tree": "sha256:1c3133c0831aeb85637ddb725ab4a6aba7bca9b3c7b594a69fd36bdd5e813d97"
+      "generated_at_commit": "1ff4dc91658b624f8827bf0a03b4955189f64198",
+      "source_tree": "sha256:73a1f2472bb381c20a2735e0b91e9b228465f2c1175c74e06061e2d53e903d2a"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/.crumb b/native/.crumb
index 994e24c8..283d6b9c 100644
--- a/native/.crumb
+++ b/native/.crumb
@@ -79,8 +79,8 @@
           "purpose": "Directory native/disk. Purpose not yet described by a human."
         },
         {
-          "digest": "4dc3dd1b9414534e1880c835a10a98b74c9440b4c59929b491b8b985f502206e",
-          "last_commit": "47973bb4",
+          "digest": "42df25c718a53cea8a5654525f05ffb104c3ae64e5ada7d640e73130bf4b7549",
+          "last_commit": "1ff4dc91",
           "name": "kernel",
           "purpose": "Directory native/kernel. Purpose not yet described by a human."
         },
@@ -115,15 +115,15 @@
           "purpose": "Directory native/store. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:672b890a47c3ea517cd06d74b4feefce2f83dcfecb83a9d25d4b9a9d63e839a8",
-      "compiled_at": "2026-11-06T00:50:27Z",
+      "children_root": "sha256:1c96072f834275ce7fbddab92eda7d7cc3a9fcdb2daf1aa0711ea70a578b59c9",
+      "compiled_at": "2026-11-06T01:09:35Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:93e6e9eab515a36245e770ac5789a51b33daaa56ebddb6d6c7070fc65f047cd3",
+      "digest": "sha256:fc5393380b21025d37b375678a31dd10496e8baa4590615d2d76f10c4bb8ff98",
       "evidence_files": 24,
       "evidence_root": "sha256:ecc7ccf2e924c221a5bac1d91e23b13d8f3c8d78c2a893a882ed7ca5e88d855d",
       "files": 777,
-      "generated_at_commit": "47973bb401c35ff45002e8296a216a1558f663e0",
-      "source_tree": "sha256:2734116d52606f13968e529e2c832db22f98b81468b54ad8eba4bf37427797d1"
+      "generated_at_commit": "1ff4dc91658b624f8827bf0a03b4955189f64198",
+      "source_tree": "sha256:e309c3a79891aea15354e066b45a910b56cdcfc499efa1e53d27b441bc4751f3"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/.crumb b/native/kernel/.crumb
index 1ee1e2cf..30e57f58 100644
--- a/native/kernel/.crumb
+++ b/native/kernel/.crumb
@@ -81,14 +81,14 @@
           "purpose": "Directory native/kernel/mm. Purpose not yet described by a human."
         },
         {
-          "digest": "87e4d6c053c07b5933ce205d638c8611a390747d11452629f4767191f2a4d8ea",
-          "last_commit": "38d322ee",
+          "digest": "6c3bb274d3f6563192f5f4ba88552da48ac1a2db10000d02a54d02624e5db9d7",
+          "last_commit": "1ff4dc91",
           "name": "svc",
           "purpose": "Directory native/kernel/svc. Purpose not yet described by a human."
         },
         {
           "digest": "f973f76cc4e15d69d53f58665ce12638eb309d2f7bbf32351cbf44d93354e242",
-          "last_commit": "47973bb4",
+          "last_commit": "25784d18",
           "name": "tests",
           "purpose": "Directory native/kernel/tests. Purpose not yet described by a human."
         },
@@ -99,15 +99,15 @@
           "purpose": "Hosted (Linux-built) checkers for the native kernel, run by `make -C native/kernel test`; nothin"
         }
       ],
-      "children_root": "sha256:2e64f2252781aeb26b438840dc0cf6e91f9c4fb1485cc2d6f40afcae25aa2842",
-      "compiled_at": "2026-11-06T00:50:27Z",
+      "children_root": "sha256:d8387c8635d5ac61d1d265d003a69b4e4dde18590b8d5b1da302c6cb65d4fb65",
+      "compiled_at": "2026-11-06T01:09:35Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:4dc3dd1b9414534e1880c835a10a98b74c9440b4c59929b491b8b985f502206e",
+      "digest": "sha256:42df25c718a53cea8a5654525f05ffb104c3ae64e5ada7d640e73130bf4b7549",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 521,
-      "generated_at_commit": "47973bb401c35ff45002e8296a216a1558f663e0",
-      "source_tree": "sha256:ef8ccbed3b99fd9dcc2c4d3a4248e133bd8362c449e1d2a74b8aeaac22daf0ec"
+      "generated_at_commit": "1ff4dc91658b624f8827bf0a03b4955189f64198",
+      "source_tree": "sha256:ee9b77e4e12f37dacb7283ccd5041636962e3b13f5ec713d249dab0235a43791"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb
index 5ed18bb9..38fd123a 100644
--- a/native/kernel/svc/.crumb
+++ b/native/kernel/svc/.crumb
@@ -23,21 +23,21 @@
           "purpose": "Directory native/kernel/svc/compat. Purpose not yet described by a human."
         },
         {
-          "digest": "24b4cfaf8283cb721bcb21878931931bc2f5107ff014b03ab4625e23b7e38db5",
-          "last_commit": "6b91f3f0",
+          "digest": "01e9385a8463bc3505aba9c4be4cf0d646a5e51012affc92aadb894319d36ea8",
+          "last_commit": "1ff4dc91",
           "name": "tests",
           "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:65b2c83d2f74367f5ba79b226b03541891438f5f04141abc89b51c923a5fb066",
-      "compiled_at": "2026-11-06T00:33:49Z",
+      "children_root": "sha256:9afba3204928eda543c0fe48d2f3c6c74988dd9f404d730ec7c831fe8b9343e9",
+      "compiled_at": "2026-11-06T01:09:35Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:87e4d6c053c07b5933ce205d638c8611a390747d11452629f4767191f2a4d8ea",
+      "digest": "sha256:6c3bb274d3f6563192f5f4ba88552da48ac1a2db10000d02a54d02624e5db9d7",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 55,
-      "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80",
-      "source_tree": "sha256:44cfede109b1b6a8a57b65ff4af47e9e88e7eb124de759dcdad0e32800941730"
+      "generated_at_commit": "1ff4dc91658b624f8827bf0a03b4955189f64198",
+      "source_tree": "sha256:94aed90a3c08d2eb0da849df78adfdb510bf279fa6349c78a8b4ae763171b981"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/svc/tests/.crumb b/native/kernel/svc/tests/.crumb
index 024a60dc..04106188 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-11-06T00:33:49Z",
+      "compiled_at": "2026-11-06T01:09:35Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:24b4cfaf8283cb721bcb21878931931bc2f5107ff014b03ab4625e23b7e38db5",
+      "digest": "sha256:01e9385a8463bc3505aba9c4be4cf0d646a5e51012affc92aadb894319d36ea8",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 4,
-      "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80",
-      "source_tree": "sha256:0c6b70e78fb8e9f9bfdd4f522d291e7ea913f316327a6b3c62b7c1645f298362"
+      "generated_at_commit": "1ff4dc91658b624f8827bf0a03b4955189f64198",
+      "source_tree": "sha256:4656a54d743a4f7506d4860549297b35b78d83aadff0ebf7c55c7420a615a4e9"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/native/kernel/svc/tests/ck_host.c b/native/kernel/svc/tests/ck_host.c
index fb26508c..d9b2da3a 100644
--- a/native/kernel/svc/tests/ck_host.c
+++ b/native/kernel/svc/tests/ck_host.c
@@ -226,7 +226,13 @@ int ck_acpi_platform_devices(const char *const *ids, unsigned nids, struct ck_pl
     if (out && max) *out = host_plat;
     return 1;
 }
-void ck_mb(void) { __sync_synchronize(); }
+void (*ck_host_mb_hook)(void);
+void (*ck_host_udelay_hook)(void);
+void ck_mb(void)
+{
+    __sync_synchronize();
+    if (ck_host_mb_hook) ck_host_mb_hook();
+}
 const void *ck_acpi_find(const char sig[4])
 {
     if (memcmp(sig, "MCFG", 4) == 0) return ck_host_mcfg;
@@ -238,7 +244,11 @@ uint64_t ck_time_us(void)
     clock_gettime(CLOCK_MONOTONIC, &ts);
     return (uint64_t)ts.tv_sec * 1000000u + (uint64_t)ts.tv_nsec / 1000u;
 }
-void ck_udelay(uint32_t us) { (void)us; }
+void ck_udelay(uint32_t us)
+{
+    (void)us;
+    if (ck_host_udelay_hook) ck_host_udelay_hook();
+}
 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; }
diff --git a/native/kernel/svc/tests/ck_host.h b/native/kernel/svc/tests/ck_host.h
index d443edd3..25f81526 100644
--- a/native/kernel/svc/tests/ck_host.h
+++ b/native/kernel/svc/tests/ck_host.h
@@ -30,6 +30,10 @@ extern unsigned ck_host_unconfine_allow;       /* with unconfine_fail: this many
 extern unsigned ck_host_confine_calls, ck_host_unconfine_calls;
 extern uint32_t ck_host_confine_segment, ck_host_confine_rid;
 extern uint64_t ck_host_confine_phys, ck_host_confine_len;
+/* Device models step here, on the caller's thread, so a register poll sees the model's answer without timing:
+ * the mb hook runs after every ck_mb (drivers fence each register write with it), the udelay hook on every poll wait. */
+extern void (*ck_host_mb_hook)(void);
+extern void (*ck_host_udelay_hook)(void);
 void ck_host_mmio_reset(void);            /* forget every recorded mapping and the counter */
 /* One ACPI platform device the next ck_acpi_platform_devices scan can return.
  * Cleared: the scan reports no DSDT, as on an unconfigured host. */
diff --git a/native/kernel/svc/tests/stage_test.c b/native/kernel/svc/tests/stage_test.c
index 8fef9922..597b42da 100644
--- a/native/kernel/svc/tests/stage_test.c
+++ b/native/kernel/svc/tests/stage_test.c
@@ -15,14 +15,13 @@
  */
 
 /* stage_test.c -- host tests for the Lane 18 boot stages (devices,
- * security, Store). Hosted test code: libc, pthreads, disk_file. Host
+ * security, Store). Hosted test code: libc, disk_file. Host
  * results qualify nothing physical; they check the logic only. */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>
-#include <pthread.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include "ck.h"
@@ -2730,9 +2729,10 @@ static void test_cortex_journal(void)
 }
 
 /* A tiny xHCI: HCRST completes and Run/Stop clears HCH, so the keyboard phase
- * can reach "no device" instead of a register or reset timeout. Host only. */
-static uint8_t *volatile xhci_watch_bar[2];
-static volatile int xhci_watch_on;
+ * can reach "no device" instead of a register or reset timeout. Host only.
+ * It steps once per driver poll wait (ck_host_udelay_hook), on the driver's
+ * own thread, so no result depends on scheduling (#490). */
+static uint8_t *xhci_model_bar[2];
 static uint32_t xhci_ld32(volatile uint8_t *p)
 {
     return (uint32_t)p[0] | ((uint32_t)p[1] << 8) | ((uint32_t)p[2] << 16) | ((uint32_t)p[3] << 24);
@@ -2744,28 +2744,25 @@ static void xhci_st32(volatile uint8_t *p, uint32_t v)
     p[2] = (uint8_t)(v >> 16);
     p[3] = (uint8_t)(v >> 24);
 }
-static void *xhci_watch(void *arg)
-{
-    (void)arg;
-    while (xhci_watch_on) {
-        for (int i = 0; i < 2; i++) {
-            volatile uint8_t *bar = xhci_watch_bar[i];
-            if (!bar) continue;
-            uint32_t op = xhci_ld32(bar) & 0xffu;
-            if (op + 8u > 0x4000u) continue;
-            uint32_t cmd = xhci_ld32(bar + op), sts = xhci_ld32(bar + op + 4);
-            if (cmd & 2u) { /* HCRST: complete, leave the controller halted */
-                xhci_st32(bar + op, cmd & ~2u);
-                xhci_st32(bar + op + 4, (sts & ~0x800u) | 1u);
-            } else if (cmd & 1u) { /* RS: running */
-                if (sts & 1u) xhci_st32(bar + op + 4, sts & ~1u);
-            } else if (!(sts & 1u)) {
-                xhci_st32(bar + op + 4, sts | 1u);
-            }
+static unsigned xhci_model_steps;
+static void xhci_step(void)
+{
+    xhci_model_steps++;
+    for (int i = 0; i < 2; i++) {
+        volatile uint8_t *bar = xhci_model_bar[i];
+        if (!bar) continue;
+        uint32_t op = xhci_ld32(bar) & 0xffu;
+        if (op + 8u > 0x4000u) continue;
+        uint32_t cmd = xhci_ld32(bar + op), sts = xhci_ld32(bar + op + 4);
+        if (cmd & 2u) { /* HCRST: complete, leave the controller halted */
+            xhci_st32(bar + op, cmd & ~2u);
+            xhci_st32(bar + op + 4, (sts & ~0x800u) | 1u);
+        } else if (cmd & 1u) { /* RS: running */
+            if (sts & 1u) xhci_st32(bar + op + 4, sts & ~1u);
+        } else if (!(sts & 1u)) {
+            xhci_st32(bar + op + 4, sts | 1u);
         }
-        usleep(20);
     }
-    return 0;
 }
 
 /* Failed DMA release. Host shim only: nothing here is a real xHCI or SMMU.
@@ -2824,13 +2821,10 @@ static void test_xhci_release_refused(void)
     ck_host_confine_named_rc = 0;
     ck_host_unconfine_fail = 1;
     ck_host_unconfine_allow = 1; /* PCI abort succeeds; the platform abort is the one refused */
-    pthread_t watch;
-    int watching = 0;
-    xhci_watch_bar[0] = bar;
-    xhci_watch_bar[1] = pbar;
-    xhci_watch_on = 1;
-    watching = pthread_create(&watch, 0, xhci_watch, 0) == 0;
-    CHECK(watching);
+    xhci_model_bar[0] = bar;
+    xhci_model_bar[1] = pbar;
+    xhci_model_steps = 0;
+    ck_host_udelay_hook = xhci_step;
     grants = ck_host_confine_calls;
     ck_host_capture_start();
     rc = ck_xhci_fence(&s);
@@ -2841,6 +2835,7 @@ static void test_xhci_release_refused(void)
     CHECK(strcmp(ck_xhci_state(), "release-failed") == 0);
     CHECK(ck_xhci_live() == 1);
     CHECK(ck_host_confine_calls == grants + 2); /* PCI requester, then the ACPI name */
+    CHECK(xhci_model_steps > 0);                /* the driver's polls drove the model */
     CHECK(has(x, "abort FAILED, stays confined"));
     CHECK(has(x, "trying 1 ACPI platform controller"));
     grants = ck_host_confine_calls;
@@ -2853,11 +2848,6 @@ static void test_xhci_release_refused(void)
     /* A platform controller that is denied never holds a stream. The PCI
      * fence already succeeded, so that error stays CK_XHCI_OK / "fenced". */
     printf("  [xHCI platform fallback denied, host, not hardware]\n");
-    if (watching) {
-        xhci_watch_on = 0;
-        pthread_join(watch, 0);
-        watching = 0;
-    }
     memset(bar, 0, sizeof bar);
     put32(bar + 0x00, 0x01000020u);
     put32(bar + 0x10, 0x1u);
@@ -2868,9 +2858,6 @@ static void test_xhci_release_refused(void)
     memset(pbar, 0, sizeof pbar);
     put32(pbar + 0x00, 0x10u);
     put32(pbar + 0x14, 1u);
-    xhci_watch_on = 1;
-    watching = pthread_create(&watch, 0, xhci_watch, 0) == 0;
-    CHECK(watching);
     ck_host_confine_named_rc = CK_SMMU_ABSENT;
     ck_host_capture_start();
     rc = ck_xhci_fence(&s);
@@ -2878,11 +2865,8 @@ static void test_xhci_release_refused(void)
     x = ck_host_capture_text();
     CHECK(rc == CK_XHCI_OK && strcmp(ck_xhci_state(), "fenced") == 0 && ck_xhci_live() == 0);
     CHECK(has(x, "denied (NoSmmu)"));
-    if (watching) {
-        xhci_watch_on = 0;
-        pthread_join(watch, 0);
-    }
-    xhci_watch_bar[0] = xhci_watch_bar[1] = 0;
+    ck_host_udelay_hook = 0;
+    xhci_model_bar[0] = xhci_model_bar[1] = 0;
     ck_host_plat_clear();
     CHECK(ck_xhci_host_forget() == 0);
     ck_host_try_map_ok = 0;
@@ -2950,6 +2934,135 @@ static void test_net_release_refused(void)
     ck_host_confine_rc = CK_SMMU_ABSENT;
 }
 
+/* #490 (1): a capability window outside its BAR (net_bind.c, the map_window failure after the grant). With the
+ * abort refused the bind must report CK_NET_E_SMMU and stay live; with the abort accepted CK_NET_E_ARG and released. */
+static void test_net_window_map_fail(void)
+{
+    printf("  [virtio-net window map failure, host, not hardware]\n");
+    static uint8_t cfg[4096];
+    static uint8_t bar[0x4000] __attribute__((aligned(4096)));
+    static pci_func vf;
+    memset(cfg, 0, sizeof cfg);
+    memset(bar, 0, sizeof bar);
+    memset(&vf, 0, sizeof vf);
+    vf.vendor = 0x1af4;
+    vf.device = 0x1041;
+    vf.cfg = cfg;
+    vf.bar[4].addr = (uint64_t)(uintptr_t)bar;
+    vf.bar[4].size = sizeof bar;
+    virtio_pci_caps caps;
+    memset(&caps, 0, sizeof caps);
+    caps.common_cfg = (virtio_pci_region){1, 4, 0, 0x1000};
+    caps.isr_cfg = (virtio_pci_region){1, 4, 0x1000, 0x1000};
+    caps.device_cfg = (virtio_pci_region){1, 4, 0x2000, 0x1000};
+    caps.notify_cfg = (virtio_pci_region){1, 4, 0x3800, 0x1000}; /* ends 0x800 past the BAR */
+    caps.has_notify_off_multiplier = 1;
+    caps.notify_off_multiplier = 4;
+    ck_host_confine_rc = 0;
+    ck_host_unconfine_fail = 1;
+    unsigned grants = ck_host_confine_calls;
+    ck_host_capture_start();
+    int rc = ck_net_bind_selftest(&vf, &caps);
+    ck_host_capture_stop();
+    const char *x = ck_host_capture_text();
+    CHECK(rc == CK_NET_E_SMMU);
+    CHECK(ck_net_live() == 1);
+    CHECK(ck_host_confine_calls == grants + 1);
+    CHECK(has(x, "virtio_net: not bound (capability window 1 outside its BAR)\n"));
+    CHECK(has(x, "abort FAILED, stays confined") && !has(x, "returned to abort"));
+    CHECK(!has(x, "bus master on"));                                 /* the device never got bus mastering */
+    CHECK((pci_r16(cfg, 4) & 0x4u) == 0);
+    ck_host_unconfine_fail = 0;
+    ck_net_release();
+    CHECK(ck_net_live() == 0);
+    ck_host_capture_start();
+    rc = ck_net_bind_selftest(&vf, &caps);
+    ck_host_capture_stop();
+    CHECK(rc == CK_NET_E_ARG && ck_net_live() == 0);
+    CHECK(has(ck_host_capture_text(), "outside its BAR") && has(ck_host_capture_text(), "returned to abort"));
+    ck_host_confine_rc = CK_SMMU_ABSENT;
+}
+
+/* A virtio common-config window in plain memory, with the one register the selftest needs per queue: queue_enable
+ * follows queue_select, and a device reset (status 0) clears it. It steps after every driver register write
+ * (ck_host_mb_hook), on the driver's thread. device_feature reads the same word for both selects. */
+static volatile uint8_t *vnet_model_cc;
+static uint16_t vnet_model_sel, vnet_model_en[2];
+static void vnet_step(void)
+{
+    volatile uint8_t *cc = vnet_model_cc;
+    if (!cc) return;
+    uint16_t sel = (uint16_t)(cc[0x16] | (cc[0x17] << 8)) & 1u;
+    if (sel != vnet_model_sel) {
+        vnet_model_en[vnet_model_sel] = (uint16_t)(cc[0x1c] | (cc[0x1d] << 8));
+        cc[0x1c] = (uint8_t)vnet_model_en[sel];
+        cc[0x1d] = (uint8_t)(vnet_model_en[sel] >> 8);
+        vnet_model_sel = sel;
+    }
+    if (cc[0x14] == 0) vnet_model_en[0] = vnet_model_en[1] = 0, cc[0x1c] = cc[0x1d] = 0;
+}
+
+/* #490 (2): the final release of a selftest that got past init. VERSION_1 and ACCESS_PLATFORM are offered, MAC is
+ * not, so init succeeds and the selftest ends at "no MAC" before the final release. With that abort refused the
+ * result must be CK_NET_E_SMMU, not the selftest's own CK_NET_E_INIT, and the stream stays confined. */
+static void test_net_final_release_refused(void)
+{
+    printf("  [virtio-net final release refused, host, not hardware]\n");
+    static uint8_t cfg[4096];
+    static uint8_t bar[0x4000] __attribute__((aligned(4096)));
+    static pci_func vf;
+    memset(cfg, 0, sizeof cfg);
+    memset(bar, 0, sizeof bar);
+    memset(&vf, 0, sizeof vf);
+    bar[4] = 0x3;                                                    /* device_feature: bits 0,1 / 32,33 */
+    bar[0x12] = 2;                                                   /* num_queues */
+    bar[0x18] = 0x10;                                                /* queue_size 16 */
+    vnet_model_cc = bar;
+    vnet_model_sel = 0;
+    vnet_model_en[0] = vnet_model_en[1] = 0;
+    ck_host_mb_hook = vnet_step;
+    vf.vendor = 0x1af4;
+    vf.device = 0x1041;
+    vf.cfg = cfg;
+    vf.bar[4].addr = (uint64_t)(uintptr_t)bar;
+    vf.bar[4].size = sizeof bar;
+    virtio_pci_caps caps;
+    memset(&caps, 0, sizeof caps);
+    caps.common_cfg = (virtio_pci_region){1, 4, 0, 0x1000};
+    caps.isr_cfg = (virtio_pci_region){1, 4, 0x1000, 0x1000};
+    caps.device_cfg = (virtio_pci_region){1, 4, 0x2000, 0x1000};
+    caps.notify_cfg = (virtio_pci_region){1, 4, 0x3000, 0x1000};
+    caps.has_notify_off_multiplier = 1;
+    caps.notify_off_multiplier = 4;
+    ck_host_confine_rc = 0;
+    ck_host_unconfine_fail = 1;
+    ck_host_capture_start();
+    int rc = ck_net_bind_selftest(&vf, &caps);
+    ck_host_capture_stop();
+    const char *x = ck_host_capture_text();
+    printf("  virtio-net final release rc=%d live=%d\n", rc, ck_net_live());
+    CHECK(has(x, "access_platform=yes"));                            /* init passed: the final release is reached */
+    CHECK(has(x, "net: selftest FAIL (rc=-"));
+    CHECK(rc == CK_NET_E_SMMU);
+    CHECK(ck_net_live() == 1);
+    CHECK(has(x, "abort FAILED, stays confined") && !has(x, "returned to abort"));
+    CHECK((pci_r16(cfg, 4) & 0x4u) == 0);                            /* bus master revoked */
+    ck_host_unconfine_fail = 0;
+    ck_host_capture_start();
+    rc = ck_net_bind_selftest(&vf, &caps);                           /* still live: refused before any grant */
+    ck_net_release();
+    ck_host_capture_stop();
+    CHECK(rc == CK_NET_E_ARG && ck_net_live() == 0);
+    ck_host_capture_start();
+    rc = ck_net_bind_selftest(&vf, &caps);                           /* abort accepted: the selftest's own result */
+    ck_host_capture_stop();
+    CHECK(rc == CK_NET_E_INIT && ck_net_live() == 0);
+    CHECK(has(ck_host_capture_text(), "returned to abort"));
+    ck_host_mb_hook = 0;
+    vnet_model_cc = 0;
+    ck_host_confine_rc = CK_SMMU_ABSENT;
+}
+
 int main(void)
 {
     setvbuf(stdout, NULL, _IOLBF, 0);
@@ -2984,6 +3097,8 @@ int main(void)
     test_xhci_fence();
     test_xhci_release_refused();
     test_net_release_refused();
+    test_net_window_map_fail();
+    test_net_final_release_refused();
     test_usb_hid();
     printf("CK_STAGE_HOST: %s checks=%d failures=%d\n", failures ? "FAIL" : "PASS", checks, failures);
     return failures ? 1 : 0;