Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/patches/108f59a4b0b0d8b5 # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aienux#503 (code only) closed derived `108f59a4b0b0d8b5` #503 Imported from GitHub aien-dev/aienux#503 (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 `a2eb271e5f461cc0721d986293450d6d4bc73f2a` · Head `12d429311da6bab8c95914e73c6c001b8932ed58` ### Fetch it A git bundle of the pull request's head, 12035 bytes. ``` curl -fsSL https://interplane.io/drakestapleton/aienux/patches/108f59a4b0b0d8b5.bundle -o 108f59a4b0b0d8b5.bundle git fetch 108f59a4b0b0d8b5.bundle refs/pull/503/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 503 12d429311da6bab8c95914e73c6c001b8932ed58 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aienux","number":503,"url":"https://github.com/aien-dev/aienux/pull/503","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:37Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 3f10a258..02d8e533 100644 --- a/.crumb +++ b/.crumb @@ -33,8 +33,8 @@ "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "7411860f1419b884000b687337c8927370c86773a06b94b8da532841e6cebf92", - "last_commit": "00f16089", + "digest": "e4a6c8a97c0df7d9bda79a63342f74c0b06b18ebee1d0de31d4bf1099470bbe2", + "last_commit": "6b91f3f0", "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:8fcfe5c949083e32033a0bb3871d1584d89442588bb728219b675d6f7a3477ef", - "compiled_at": "2026-11-06T00:26:02Z", + "children_root": "sha256:617c10b4433852ffcb2c18c1105369d747910a51eee27f0aafd9afc5f1d9222b", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:310b1e3136012d059db89bc4810a7243fd798670f2f21e1e322c67eb080a5998", + "digest": "sha256:6e62fd06c16bd1d2449db58ca39b3d11aca9342348bd81a115fa00d384d9e7a0", "evidence_files": 274, "evidence_root": "sha256:af014a4ed8f6fe759fc5809807fb47578d3410811b522d9f65d749382b029802", - "files": 3776, - "generated_at_commit": "00f160892accb9365d9486273089145e56d6e49d", - "source_tree": "sha256:923eceb3aba83772ddd60c774bce46206ee78e2ad3e828be8f1e7ca40d4c8a96" + "files": 3777, + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:e1fb5804ef0bb6e1a9de98c69db475893b367bae7a314bc131837ef043a99667" }, "owner_lane": "", "provenance": { diff --git a/native/.crumb b/native/.crumb index 98f8b826..598faafa 100644 --- a/native/.crumb +++ b/native/.crumb @@ -79,8 +79,8 @@ "purpose": "Directory native/disk. Purpose not yet described by a human." }, { - "digest": "4082453d802a43dcde2069e418210fed2c69922389418aa7a11f160c1fa5450d", - "last_commit": "00f16089", + "digest": "cd715446fbb6b337b4a64cb07273017cbd1a67eea0d1435d1ad25c96ff7cce16", + "last_commit": "6b91f3f0", "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:7ed5d13ae3eb1bc4fba34199a694246161f966429dcef7317f789d71c4171150", - "compiled_at": "2026-11-06T00:26:02Z", + "children_root": "sha256:01bdb8eb493ab4ad63a208ede8e69a0f611395240543791b90d5f881719e6645", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:7411860f1419b884000b687337c8927370c86773a06b94b8da532841e6cebf92", + "digest": "sha256:e4a6c8a97c0df7d9bda79a63342f74c0b06b18ebee1d0de31d4bf1099470bbe2", "evidence_files": 24, "evidence_root": "sha256:ecc7ccf2e924c221a5bac1d91e23b13d8f3c8d78c2a893a882ed7ca5e88d855d", - "files": 776, - "generated_at_commit": "00f160892accb9365d9486273089145e56d6e49d", - "source_tree": "sha256:545c07e59b9811cfa20df829eb0798cb8b5ee88a1c2612069911dc90dbbf6a63" + "files": 777, + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:eb6369205a9a161cec1c2f9d863cccc70b2d0c31609f0de40a5e11dbd09616a5" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/.crumb b/native/kernel/.crumb index 888b547f..a5916447 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": "1c13cb136f224c171fbdf70ab18f5aec1621027ee5e05a4a9f52a05206657585", - "last_commit": "544e12b3", + "digest": "82f5b707835d6baec04a4d7e87debf00054d9e16fd090292e0f121e56bf05b30", + "last_commit": "6b91f3f0", "name": "core", "purpose": "Directory native/kernel/core. Purpose not yet described by a human." }, { - "digest": "1300a405c3d4fd7ee4a82cb8125af7a446364659aaab360ef9307484b5feaa29", - "last_commit": "00f16089", + "digest": "0b8f0332d884b0f6e39eecb4a487ca0be5435609af49dceb0d33cb0354947ae9", + "last_commit": "6b91f3f0", "name": "dev", "purpose": "Directory native/kernel/dev. Purpose not yet described by a human." }, { - "digest": "54cee35b405dc1c90f62d4d227ed172142abfd4917e720708ba0b83b94b9376e", - "last_commit": "f45d00ad", + "digest": "5157b513cd269418b046ab3661ca4e68c25bbe8bd709a8cc8f9be213173e9cef", + "last_commit": "5b1ba463", "name": "include", "purpose": "Directory native/kernel/include. Purpose not yet described by a human." }, @@ -81,14 +81,14 @@ "purpose": "Directory native/kernel/mm. Purpose not yet described by a human." }, { - "digest": "078a29364ef61e201e0884d0aa9d3f96b3ba01e7af0ea5adbba2936deafddb43", - "last_commit": "8411824a", + "digest": "87e4d6c053c07b5933ce205d638c8611a390747d11452629f4767191f2a4d8ea", + "last_commit": "6b91f3f0", "name": "svc", "purpose": "Directory native/kernel/svc. Purpose not yet described by a human." }, { - "digest": "bb7793de50fe4f1c95ecbeff2e45b09d6bb292f470d3f4fd1e7fbf6d99f49ad2", - "last_commit": "544e12b3", + "digest": "7f717340268adbe7ed0e7831a1905f23229bcce12b7690a406fcf29c9efe9f7a", + "last_commit": "6b91f3f0", "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:7244bf915ad01e1f25c6bbeb03c1e8a6458fbae818034e3f11f40ea4ac0a452f", - "compiled_at": "2026-11-06T00:26:02Z", + "children_root": "sha256:6951316af457a69ea725d160b4f221c43879b68b1ab4630df394798b2d0c60d2", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:4082453d802a43dcde2069e418210fed2c69922389418aa7a11f160c1fa5450d", + "digest": "sha256:cd715446fbb6b337b4a64cb07273017cbd1a67eea0d1435d1ad25c96ff7cce16", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 520, - "generated_at_commit": "00f160892accb9365d9486273089145e56d6e49d", - "source_tree": "sha256:274eca89c52a7749d4d7867f970a9b4eb36e70fb33df17e186b0d7dc0c8742a6" + "files": 521, + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:52f8fca126fc3db1f6bd44a0251941373cec1967bbb794cd02a7979a7286b735" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/Makefile b/native/kernel/Makefile index 06489953..00adc3a0 100644 --- a/native/kernel/Makefile +++ b/native/kernel/Makefile @@ -1512,6 +1512,7 @@ TESTS := test_fmt test_frames test_pt test_acpi test_acpi_dev test_heap test_smm test_continuity_subject test_continuity_subject_provision test_lifecycle test_console_rx test_klog test_klog_slot test_pi5 test_pi5_marker test_pi5_rng test_cpufeat test_dma_window test_pi5_pcie test_pi5_net test_pi5_gem test_unlock_req test_context test_agent_cmd test_artifact_card test_pipe test_allen_gate \ test_netboot_text test_gb10_gsp_boot TESTS += test_gpu_sim test_gsp_mmio +TESTS += test_smmu_svc HCFLAGS := -std=gnu11 -O1 -g -Wall -Wextra -Werror -I$(KDIR)/core -I$(KDIR)/mm -I$(KDIR)/tests -I$(BOOT) SANFLAGS := -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer @@ -2992,6 +2993,17 @@ dma-window-mutants: done; test $$fail -eq 0 .PHONY: test-dma-window dma-window-mutants +# SMMU DMA service refusals (core/smmu_svc.c, #480): the test includes the service source to lay out its static +# instance table, and stubs the platform hooks itself. Host only. +SMMU_SVC_SRCS := $(KDIR)/core/fmt.c $(KDIR)/core/acpi.c $(KDIR)/core/smmu.c $(KDIR)/mm/frames.c $(KDIR)/mm/pt.c $(KDIR)/mm/heap.c +SMMU_SVC_DEPS := $(KDIR)/tests/test_smmu_svc.c $(KDIR)/core/smmu_svc.c $(SMMU_SVC_SRCS) $(KDIR)/tests/ck_test.h $(HDRS) +$(OUT)/host/test_smmu_svc: $(SMMU_SVC_DEPS) + @mkdir -p $(dir $@) + $(HOSTCC) $(HCFLAGS) -I$(KDIR)/include -o $@ $< $(SMMU_SVC_SRCS) +$(OUT)/host-san/test_smmu_svc: $(SMMU_SVC_DEPS) + @mkdir -p $(dir $@) + $(HOSTCC) $(HCFLAGS) $(SANFLAGS) -I$(KDIR)/include -o $@ $< $(SMMU_SVC_SRCS) + # AIENOS-GB10 cut D, host side: GPU page tables, allocator and channel over a simulated GB10 # (gpu/gpu_sim.c). Host test only, not linked into any image (dependency map: kernel-side D code waits for #163/B). GPU_SIM_SRCS := $(KDIR)/gpu/gmmu.c $(KDIR)/gpu/gpu_mem.c $(KDIR)/gpu/gpu_chan.c $(KDIR)/gpu/gpu_sim.c diff --git a/native/kernel/core/.crumb b/native/kernel/core/.crumb index 439cb984..8bc2eb57 100644 --- a/native/kernel/core/.crumb +++ b/native/kernel/core/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-04T20:56:36Z", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:1c13cb136f224c171fbdf70ab18f5aec1621027ee5e05a4a9f52a05206657585", + "digest": "sha256:82f5b707835d6baec04a4d7e87debf00054d9e16fd090292e0f121e56bf05b30", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 78, - "generated_at_commit": "9680b207508e0e10eb479df3eca4b214681f119a", - "source_tree": "sha256:4d03f98d28bf0a0637ca923050bc0c8bb8d1827e78306cd4743120c976043a51" + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:fb977c5f80f6fa476c9db2ee69c38b261cb91c481e4bee18c9f2a21dc7c0ee96" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/core/smmu_svc.c b/native/kernel/core/smmu_svc.c index 0b0a1f38..7891adfd 100644 --- a/native/kernel/core/smmu_svc.c +++ b/native/kernel/core/smmu_svc.c @@ -347,8 +347,10 @@ int ck_dma_unconfine(uint32_t stream_id) { int slot = 0, amb; struct inst *in = holder(stream_id, &slot, &amb); + if (amb) + return CK_SMMU_AMBIGUOUS; /* fail closed: neither holder is aborted */ if (!in) - return CK_SMMU_EARG; /* not confined, or confined on two SMMUs */ + return CK_SMMU_EARG; /* not confined */ if (ck_smmu_abort_ste(&in->regs, &in->t, stream_id, CK_SMMU_DEFAULT_SPINS)) return CK_SMMU_FAILED; in->used[slot] = 0; diff --git a/native/kernel/dev/.crumb b/native/kernel/dev/.crumb index 42b84d95..b3183ba4 100644 --- a/native/kernel/dev/.crumb +++ b/native/kernel/dev/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-06T00:26:02Z", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:1300a405c3d4fd7ee4a82cb8125af7a446364659aaab360ef9307484b5feaa29", + "digest": "sha256:0b8f0332d884b0f6e39eecb4a487ca0be5435609af49dceb0d33cb0354947ae9", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 55, - "generated_at_commit": "00f160892accb9365d9486273089145e56d6e49d", - "source_tree": "sha256:542149bdafa0198a4c1f9c2bd0bbd290bf55e9a72a0aaa07d21840400c5b9fdc" + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:0ff44e7301db91432640c4630fad04c5a490021ad2e320684005e21c151d2c6e" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/dev/devices.c b/native/kernel/dev/devices.c index 5f94c823..00ac9358 100644 --- a/native/kernel/dev/devices.c +++ b/native/kernel/dev/devices.c @@ -102,8 +102,9 @@ void ck_dev_nvme_release(void) * confined here too: ownership is kept and a later release retries. */ int urc = ck_dma_unconfine(g_nvme.stream_id); if (urc == 0) g_nvme.confined = 0; - ck_printf("smmu: nvme stream 0x%x %s (rc=%d)\n", g_nvme.stream_id, - urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc); + ck_printf("smmu: nvme stream 0x%x %s (rc=%d%s%s)\n", g_nvme.stream_id, + urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc, urc ? ": " : "", + urc ? ck_dma_unconfine_why(urc) : ""); } /* Ownership is given back only once DMA is fully off (bus master and stream). */ if (!g_nvme.bm_on && !g_nvme.confined && !g_nvme.stuck) g_nvme.claimed = 0; diff --git a/native/kernel/dev/net_bind.c b/native/kernel/dev/net_bind.c index 6887e2e4..8137687a 100644 --- a/native/kernel/dev/net_bind.c +++ b/native/kernel/dev/net_bind.c @@ -124,8 +124,9 @@ void ck_net_release(void) * confined (ck_net_live stays 1) and a later release retries. */ int urc = ck_dma_unconfine(n->stream_id); if (urc == 0) n->confined = 0; - ck_printf("smmu: virtio_net stream 0x%x %s (rc=%d)\n", n->stream_id, - urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc); + ck_printf("smmu: virtio_net stream 0x%x %s (rc=%d%s%s)\n", n->stream_id, + urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc, urc ? ": " : "", + urc ? ck_dma_unconfine_why(urc) : ""); } } diff --git a/native/kernel/dev/rtl8127_bind.c b/native/kernel/dev/rtl8127_bind.c index 405f9caa..f00a9014 100644 --- a/native/kernel/dev/rtl8127_bind.c +++ b/native/kernel/dev/rtl8127_bind.c @@ -62,8 +62,9 @@ void ck_rtl8127_release(void) if (g_rtl.confined) { int urc = ck_dma_unconfine(g_rtl.stream_id); if (urc == 0) g_rtl.confined = 0; - ck_printf("smmu: rtl8127 stream 0x%x %s (rc=%d)\n", g_rtl.stream_id, urc == 0 ? "returned to abort" : "abort FAILED", - urc); + ck_printf("smmu: rtl8127 stream 0x%x %s (rc=%d%s%s)\n", g_rtl.stream_id, + urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc, urc ? ": " : "", + urc ? ck_dma_unconfine_why(urc) : ""); } } diff --git a/native/kernel/dev/xhci_fence.c b/native/kernel/dev/xhci_fence.c index 67778129..23fcefa4 100644 --- a/native/kernel/dev/xhci_fence.c +++ b/native/kernel/dev/xhci_fence.c @@ -176,8 +176,9 @@ void ck_xhci_release(void) * confined (ck_xhci_live stays 1) and a later release retries. */ int urc = ck_dma_unconfine(x->stream_id); if (urc == 0) x->confined = 0; - ck_printf("smmu: xhci stream 0x%x %s (rc=%d)\n", x->stream_id, - urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc); + ck_printf("smmu: xhci stream 0x%x %s (rc=%d%s%s)\n", x->stream_id, + urc == 0 ? "returned to abort" : "abort FAILED, stays confined", urc, urc ? ": " : "", + urc ? ck_dma_unconfine_why(urc) : ""); } } diff --git a/native/kernel/include/.crumb b/native/kernel/include/.crumb index 1fa573b0..369eafd1 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-24T04:15:32Z", + "compiled_at": "2026-11-05T02:01:33Z", "compiler": "crumb-compile/1", - "digest": "sha256:54cee35b405dc1c90f62d4d227ed172142abfd4917e720708ba0b83b94b9376e", + "digest": "sha256:5157b513cd269418b046ab3661ca4e68c25bbe8bd709a8cc8f9be213173e9cef", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 1, - "generated_at_commit": "621c9e6fe430ee689836bee3ee2689d7d32e0f7d", - "source_tree": "sha256:617c9046d32df918fef874dfcd16daec79dca077cab24a33b445caef36fcf927" + "generated_at_commit": "3be8290b317427791b12ae1416f055e5e696712d", + "source_tree": "sha256:0ef80d263d26293022bd587b4ceced58197eba1555d689dac07aaa1116b1660c" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/include/ck.h b/native/kernel/include/ck.h index fca4fd6b..52dae22f 100644 --- a/native/kernel/include/ck.h +++ b/native/kernel/include/ck.h @@ -130,6 +130,7 @@ void ck_irq_cpu_enable(int on); #define CK_SMMU_NOSTREAM (-3) #define CK_SMMU_EARG (-4) #define CK_SMMU_OTHER (-5) /* the stream belongs to an SMMUv3 node the IORT parser did not keep (beyond CK_IORT_MAX_SMMUS) */ +#define CK_SMMU_AMBIGUOUS (-6) /* ck_dma_unconfine: the stream id is confined on two SMMUs; nothing is aborted (#480) */ #define CK_DMA_MAX_STREAMS 8 struct ck_dma_confinement { uint64_t smmu_base; @@ -179,10 +180,19 @@ struct ck_acpi_scan_info { int ck_acpi_platform_devices(const char *const *ids, unsigned nids, struct ck_platform_dev *out, unsigned max, struct ck_acpi_scan_info *info); /* Return a confined stream to abort (after the device's bus mastering is - * off). 0 ok, CK_SMMU_EARG if not confined (or, stream ids being per SMMU, - * confined on two SMMUs at once: ambiguous), CK_SMMU_FAILED on a command - * timeout. */ + * off). 0 ok, CK_SMMU_EARG if not confined, CK_SMMU_AMBIGUOUS if (stream ids + * being per SMMU) it is confined on two SMMUs at once (fail closed: both stay + * confined), CK_SMMU_FAILED on a command timeout. */ int ck_dma_unconfine(uint32_t stream_id); +/* Console text for a non-zero ck_dma_unconfine result, so a caller's message + * tells "nothing to release" apart from an inconsistent SMMU state (#480). */ +static inline const char *ck_dma_unconfine_why(int rc) +{ + return rc == CK_SMMU_EARG ? "not confined in the SMMU service" + : rc == CK_SMMU_AMBIGUOUS ? "AMBIGUOUS: stream id confined on two SMMUs" + : rc == CK_SMMU_FAILED ? "abort command failed" + : "unexpected result"; +} /* Drain the event queue of every SMMU brought up. Returns how many records * named `stream_id` (others are dropped); *first gets the first of them. * -1 if no SMMU is up. */ diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb index c2f03b38..5ed18bb9 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": "26a6628184cfa2f5ebcb95c1130285be9ab2141dc05d554a58ae6d1469ce7724", - "last_commit": "9165e025", + "digest": "24b4cfaf8283cb721bcb21878931931bc2f5107ff014b03ab4625e23b7e38db5", + "last_commit": "6b91f3f0", "name": "tests", "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human." } ], - "children_root": "sha256:15b6a33951f4fc7ccc7a53ee66f651fe784e56aa8648cdd65f5ebef9dbd28abe", - "compiled_at": "2026-11-05T01:52:58Z", + "children_root": "sha256:65b2c83d2f74367f5ba79b226b03541891438f5f04141abc89b51c923a5fb066", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:078a29364ef61e201e0884d0aa9d3f96b3ba01e7af0ea5adbba2936deafddb43", + "digest": "sha256:87e4d6c053c07b5933ce205d638c8611a390747d11452629f4767191f2a4d8ea", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 55, - "generated_at_commit": "3be8290b317427791b12ae1416f055e5e696712d", - "source_tree": "sha256:cb1b91941b86f2ab7cbf3500141618acd1e240717d86c760c0dab1855fb2542e" + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:44cfede109b1b6a8a57b65ff4af47e9e88e7eb124de759dcdad0e32800941730" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/tests/.crumb b/native/kernel/svc/tests/.crumb index 2ac50676..024a60dc 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-05T01:52:58Z", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:26a6628184cfa2f5ebcb95c1130285be9ab2141dc05d554a58ae6d1469ce7724", + "digest": "sha256:24b4cfaf8283cb721bcb21878931931bc2f5107ff014b03ab4625e23b7e38db5", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 4, - "generated_at_commit": "3be8290b317427791b12ae1416f055e5e696712d", - "source_tree": "sha256:bfbf338ddc467ed632aa0c4ebdd426722fe449ceefb5299775be1ea03f5ccaff" + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:0c6b70e78fb8e9f9bfdd4f522d291e7ea913f316327a6b3c62b7c1645f298362" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/tests/stage_test.c b/native/kernel/svc/tests/stage_test.c index 5e1c03b5..8fef9922 100644 --- a/native/kernel/svc/tests/stage_test.c +++ b/native/kernel/svc/tests/stage_test.c @@ -886,6 +886,7 @@ static void test_nvme_bind_discovery(void) ck_host_capture_stop(); x = ck_host_capture_text(); CHECK(has(x, "dma_gate: nvme bus master revoked\n") && has(x, "abort FAILED, stays confined (rc=")); + CHECK(has(x, "abort FAILED, stays confined (rc=-2: abort command failed)\n")); /* #480: the reason is named */ CHECK(!has(x, "returned to abort")); CHECK(has(x, "nvme: bind refused, already owned by seg 0003 01:00.0 (bound=0 bm_on=0 confined=1)")); /* #489: a reset quiesce while the abort is still refused retries the release; the stream stays confined, diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb index 7c9cd1ca..b88fb356 100644 --- a/native/kernel/tests/.crumb +++ b/native/kernel/tests/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-11-04T20:56:36Z", + "compiled_at": "2026-11-06T00:33:49Z", "compiler": "crumb-compile/1", - "digest": "sha256:bb7793de50fe4f1c95ecbeff2e45b09d6bb292f470d3f4fd1e7fbf6d99f49ad2", + "digest": "sha256:7f717340268adbe7ed0e7831a1905f23229bcce12b7690a406fcf29c9efe9f7a", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 220, - "generated_at_commit": "9680b207508e0e10eb479df3eca4b214681f119a", - "source_tree": "sha256:74e610ee29c522d162b3055d24808b3abe6353cb05980ae549ca17c3027dd895" + "files": 221, + "generated_at_commit": "6b91f3f0e54cd3323f6f1459460b4bf0c09e1c80", + "source_tree": "sha256:06613542d81428a195766f5b9c7a6975ea9721e91d41b2dd081ea0ab1377aa1c" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/tests/test_smmu_svc.c b/native/kernel/tests/test_smmu_svc.c new file mode 100644 index 00000000..38275da6 --- /dev/null +++ b/native/kernel/tests/test_smmu_svc.c @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: Apache-2.0 + * Copyright 2026 Drake Stapleton (AIEN / aien-dev) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* test_smmu_svc.c -- host test of ck_dma_unconfine's refusals (#480). + * The service's instance table is static, so the source is included here and + * the table is laid out directly; no SMMU register is touched, because both + * refusals return before any command is issued. A stream held by one SMMU + * (the abort path) needs real registers and is covered by the stage tests + * through their mock. Host only, not hardware. */ +#include "ck_test.h" +#include "../core/smmu_svc.c" + +/* Platform hooks the service links against. The refusals under test reach none + * of them; each one counts, so a refusal that touches the platform fails. */ +static int platform_calls; +void ck_printf(const char *fmt, ...) { (void)fmt; } +void *ck_dma_alloc(size_t bytes, size_t align, uint64_t *phys) { (void)bytes; (void)align; (void)phys; platform_calls++; return 0; } +volatile void *ck_mmio_map(uint64_t phys, size_t len) { (void)phys; (void)len; platform_calls++; return 0; } +void ck_mb(void) { platform_calls++; } +const void *ck_acpi_find(const char sig[4]) { (void)sig; platform_calls++; return 0; } + +static void hold(unsigned k, int slot, uint32_t sid) +{ + g.inst[k].state = 1; + g.inst[k].used[slot] = 1; + g.inst[k].sid[slot] = sid; +} + +static void test_not_confined(void) +{ + memset(&g, 0, sizeof g); + CHECK(ck_dma_unconfine(0x40) == CK_SMMU_EARG); /* no SMMU up at all */ + hold(0, 0, 0x41); + CHECK(ck_dma_unconfine(0x40) == CK_SMMU_EARG); /* up, but another stream */ + CHECK(g.inst[0].used[0] == 1 && g.inst[0].sid[0] == 0x41); + g.inst[1].state = CK_SMMU_FAILED; /* a failed instance holds nothing */ + g.inst[1].used[0] = 1; + g.inst[1].sid[0] = 0x40; + CHECK(ck_dma_unconfine(0x40) == CK_SMMU_EARG); +} + +static void test_ambiguous(void) +{ + memset(&g, 0, sizeof g); + hold(0, 2, 0x40); + hold(1, 0, 0x40); + int rc = ck_dma_unconfine(0x40); + CHECK(rc == CK_SMMU_AMBIGUOUS); + CHECK(rc != CK_SMMU_EARG && rc != 0); + /* fail closed: both holders keep the stream confined */ + CHECK(g.inst[0].used[2] == 1 && g.inst[0].sid[2] == 0x40); + CHECK(g.inst[1].used[0] == 1 && g.inst[1].sid[0] == 0x40); + CHECK(ck_dma_unconfine(0x40) == CK_SMMU_AMBIGUOUS); /* stays refused on retry */ +} + +int main(void) +{ + test_not_confined(); + test_ambiguous(); + CHECK(platform_calls == 0); /* refusals issue no command and map nothing */ + return ck_t_verdict("test_smmu_svc"); +} ```