From 9696c7d98e324105b6b161626dc82450f1b8ab2b Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 8 Oct 2026 14:15:06 -0500 Subject: [PATCH 1/4] Kernel: unmap MMIO window pages on revoke, exclusive ownership (aienos#286, cut B3b) Co-Authored-By: Claude Opus 5.5 --- native/kernel/dev/mmio_window.c | 81 +++++++++++++++--- native/kernel/dev/mmio_window.h | 43 +++++++++- native/kernel/include/ck.h | 15 ++++ native/kernel/mm/mmu.c | 59 +++++++++++++ native/kernel/stage.mk | 2 +- native/kernel/svc/tests/ck_host.c | 66 ++++++++++++++- native/kernel/svc/tests/ck_host.h | 2 + native/kernel/svc/tests/stage_test.c | 121 ++++++++++++++++++++++++++- native/kernel/tests/test_pt.c | 11 +++ 9 files changed, 382 insertions(+), 18 deletions(-) diff --git a/native/kernel/dev/mmio_window.c b/native/kernel/dev/mmio_window.c index ff19294e..9656dd3c 100644 --- a/native/kernel/dev/mmio_window.c +++ b/native/kernel/dev/mmio_window.c @@ -61,6 +61,65 @@ int ck_mmio_window_create(struct ck_mmio_registry *r, struct ck_cap_table *t, co return CK_MMIO_OK; } +int ck_mmio_window_open(struct ck_mmio_registry *r, struct ck_cap_table *t, const pci_found *f, unsigned bar, + uint64_t size, unsigned rights, struct ck_handle *out) +{ + if (!r || !t || !f || !out || size == 0) + return CK_MMIO_E_ARG; + if ((rights & ~CK_MMIO_RIGHTS) || !(rights & CK_R_READ)) + return CK_MMIO_E_RIGHTS; + uint64_t addr; + int rc = ck_mmio_bar_addr(f, bar, &addr); + if (rc) + return rc; + if (addr + size < addr) + return CK_MMIO_E_RANGE; + if (r->next >= CK_MMIO_WINDOWS) + return CK_MMIO_E_FULL; + /* Exclusive: a page some other driver already mapped is refused, so the + * unmap on revoke can never pull a mapping out from under it. */ + const volatile void *m = ck_mmio_map_exclusive(addr, (size_t)size); + if (!m) + return CK_MMIO_E_MAP; + uint32_t idx = r->next; + rc = ck_mmio_window_create(r, t, f, bar, size, m, rights, out); + if (rc) { + (void)ck_mmio_unmap_exclusive(addr, (size_t)size); + return rc; + } + r->w[idx].owned = r->w[idx].mapped = 1; + return CK_MMIO_OK; +} + +int ck_mmio_revoke(struct ck_mmio_registry *r, uint32_t table_id, struct ck_handle h, + struct ck_cap_table *const *tables, unsigned ntables) +{ + if (!r || !tables) + return CK_MMIO_E_ARG; + uint32_t resource = 0; + int named = 0; + for (unsigned i = 0; i < ntables; i++) + if (tables[i]->id == table_id) + named = ck_cap_lookup(tables[i], h, 0, &resource) == CK_CAP_OK; + int rc = ck_cap_revoke(table_id, h, tables, ntables); + if (rc || !named) + return rc; /* refused or already revoked: nothing is unmapped here */ + uint32_t idx = resource - CK_MMIO_RESOURCE_BASE; + if (resource < CK_MMIO_RESOURCE_BASE || idx >= CK_MMIO_WINDOWS || !r->w[idx].used || + r->w[idx].resource != resource || !r->w[idx].owned || !r->w[idx].mapped) + return CK_CAP_OK; + for (unsigned i = 0; i < ntables; i++) + for (unsigned s = 0; s < tables[i]->n; s++) + if (tables[i]->slots[s].live && !tables[i]->slots[s].tombstone && tables[i]->slots[s].resource == resource) + return CK_CAP_OK; /* a parent or sibling still holds the window */ + struct ck_mmio_window *w = &r->w[idx]; + w->base = 0; /* the accessor has no pointer left to use, whatever the unmap does */ + if (ck_mmio_unmap_exclusive(w->bus_addr, (size_t)w->size)) + return CK_MMIO_E_UNMAP; + w->mapped = 0; + return CK_CAP_OK; +} + int ck_mmio_read(const struct ck_mmio_registry *r, const struct ck_cap_table *t, struct ck_handle h, uint64_t offset, unsigned width, uint64_t *value) { @@ -75,6 +134,8 @@ int ck_mmio_read(const struct ck_mmio_registry *r, const struct ck_cap_table *t, r->w[idx].resource != resource) return CK_MMIO_E_RESOURCE; const struct ck_mmio_window *w = &r->w[idx]; + if (!w->base) + return CK_CAP_INVALID; /* owned pages were given back */ if (width != 1 && width != 2 && width != 4 && width != 8) return CK_MMIO_E_ALIGN; if (offset & (width - 1u)) @@ -112,26 +173,26 @@ int ck_mmio_stage_report(void) } uint64_t addr = 0; (void)ck_mmio_bar_addr(nv, 0, &addr); - /* 0x1000 covers the NVMe register file head (CAP, VS); the real BAR size is unknown here. */ - const volatile void *m = ck_mmio_try_map(addr, 0x1000); - if (!m) { - ck_printf("mmio_win: %04x:%02x:%02x.%u BAR0 map refused (report-only)\n", nv->segment, nv->bus, nv->dev, nv->fn); - return CK_MMIO_E_BAR; - } struct ck_mmio_registry reg; struct ck_cap_table tab; struct ck_cap_table *const tabs[1] = { &tab }; struct ck_handle h; ck_mmio_registry_init(®); ck_cap_init(&tab, 1, CK_CAP_SLOTS); - int crc = ck_mmio_window_create(®, &tab, nv, 0, 0x1000, m, CK_MMIO_RIGHTS, &h); + /* 0x1000 covers the NVMe register file head (CAP, VS); the real BAR size is unknown here. The window maps + * the page exclusively: if the page is already mapped it is refused and nothing is touched. */ + int crc = ck_mmio_window_open(®, &tab, nv, 0, 0x1000, CK_MMIO_RIGHTS, &h); + if (crc == CK_MMIO_E_MAP) { + ck_printf("mmio_win: %04x:%02x:%02x.%u BAR0 map refused (report-only)\n", nv->segment, nv->bus, nv->dev, nv->fn); + return CK_MMIO_E_BAR; + } uint64_t vs = 0, again = 0; int rrc = crc ? crc : ck_mmio_read(®, &tab, h, 0x08, 4, &vs); /* NVMe VS register */ int wrc = crc ? crc : ck_mmio_read(®, &tab, h, 0x1000, 4, &again); /* one past the window */ - int vrc = crc ? crc : ck_cap_revoke(tab.id, h, tabs, 1); + int vrc = crc ? crc : ck_mmio_revoke(®, tab.id, h, tabs, 1); int arc = crc ? crc : ck_mmio_read(®, &tab, h, 0x08, 4, &again); ck_printf("mmio_win: %04x:%02x:%02x.%u bar0 addr=0x%llx size=0x1000 create=%d read(VS)=%d value=0x%llx " - "past-end=%d revoke=%d after-revoke=%d (read-only, report-only)\n", - nv->segment, nv->bus, nv->dev, nv->fn, (unsigned long long)addr, crc, rrc, (unsigned long long)vs, wrc, vrc, arc); + "past-end=%d revoke=%d after-revoke=%d unmapped=%d (read-only, report-only)\n", + nv->segment, nv->bus, nv->dev, nv->fn, (unsigned long long)addr, crc, rrc, (unsigned long long)vs, wrc, vrc, arc, crc ? -1 : !ck_mmio_is_mapped(addr, 0x1000)); return CK_MMIO_OK; } diff --git a/native/kernel/dev/mmio_window.h b/native/kernel/dev/mmio_window.h index ad4b57a6..f72211f2 100644 --- a/native/kernel/dev/mmio_window.h +++ b/native/kernel/dev/mmio_window.h @@ -18,11 +18,22 @@ * Resource numbers: the registry never frees or reuses a window, so a number * is never given to a second resource (aienos#285 / ADR 0019 trigger not hit). * + * Pages (cut B3b): a window made with ck_mmio_window_open OWNS its pages. It + * maps them with ck_mmio_map_exclusive, which refuses (fail closed) when any + * page is already mapped, so a mapping some other driver holds (nvme_bind maps + * the same NVMe BAR0) can never be unmapped by a window. ck_mmio_revoke, once + * no live capability for the window is left, unmaps the pages and invalidates + * the TLB, so a raw access to the old pointer faults at the MMU; the accessor + * refusal stays as a second layer. Refuse-not-refcount was chosen on purpose: + * a shared page would make revoke depend on a stranger. Windows made with + * ck_mmio_window_create (borrowed mapping) still revoke the capability only. + * * Limits (named): BAR size is not discoverable here, so the caller supplies - * it from firmware or a fixture; page tables are NOT unmapped on revoke (the - * kernel mapping from ck_mmio_try_map stays Device RW; read-only and revoke - * are enforced in the accessor, not by the MMU); no interrupts, no DMA, no - * polling helper, no config-space or COMMAND changes. */ + * it from firmware or a fixture; the mapping is Device RW even though the + * accessor is read-only (no read-only Device mapping is made); revoke must go + * through ck_mmio_revoke (a bare ck_cap_revoke still refuses the accessor but + * leaves the pages mapped); no interrupts, no DMA, no polling helper, no + * config-space or COMMAND changes. */ #ifndef AIENOS_CK_MMIO_WINDOW_H #define AIENOS_CK_MMIO_WINDOW_H #include @@ -43,12 +54,16 @@ enum { CK_MMIO_E_ALIGN = -505, /* width not 1/2/4/8, or offset not width-aligned */ CK_MMIO_E_FULL = -506, /* registry full (windows are never reused) */ CK_MMIO_E_RESOURCE = -507, /* handle is live but names no MMIO window */ + CK_MMIO_E_MAP = -508, /* exclusive map refused: a page is already mapped, overlaps RAM, or cannot be mapped */ + CK_MMIO_E_UNMAP = -509, /* capability revoked but the page unmap failed */ }; struct ck_mmio_window { uint8_t used; uint32_t resource; uint64_t bus_addr, size; + uint8_t owned; /* 1: window mapped these pages itself and unmaps them on revoke */ + uint8_t mapped; /* owned pages still mapped */ const volatile uint8_t *base; /* caller's mapping of [bus_addr, +size) */ }; struct ck_mmio_registry { @@ -68,6 +83,26 @@ int ck_mmio_bar_addr(const pci_found *f, unsigned bar, uint64_t *addr); int ck_mmio_window_create(struct ck_mmio_registry *r, struct ck_cap_table *t, const pci_found *f, unsigned bar, uint64_t size, const volatile void *base, unsigned rights, struct ck_handle *out); +/* Like ck_mmio_window_create, but the window OWNS its pages: it maps the BAR + * itself with ck_mmio_map_exclusive (CK_MMIO_E_MAP, nothing created, if any + * page is already mapped by someone else) and ck_mmio_revoke takes the pages + * away again. */ +int ck_mmio_window_open(struct ck_mmio_registry *r, struct ck_cap_table *t, const pci_found *f, unsigned bar, + uint64_t size, unsigned rights, struct ck_handle *out); + +/* The revoke path for window capabilities: ck_cap_revoke(table_id, h, tables, + * ntables), and when that leaves no live capability for the window's resource + * in `tables` the owned pages are unmapped (MMU level; a raw access then + * faults) and the TLB is invalidated. Revoking a derived child while its + * parent is still live leaves the pages mapped. Returns the ck_cap code; + * CK_MMIO_E_UNMAP if the capability is gone but the unmap failed (the pages + * stay mapped and the accessor still refuses). `tables` must list every table + * that can hold a capability for the window. Borrowed windows (created with + * ck_mmio_window_create) revoke the capability only. Calling it again on a + * revoked handle is harmless (CK_CAP_INVALID, nothing touched). */ +int ck_mmio_revoke(struct ck_mmio_registry *r, uint32_t table_id, struct ck_handle h, + struct ck_cap_table *const *tables, unsigned ntables); + /* Checked read of `width` (1, 2, 4 or 8) bytes at `offset`. Capability * failures return the ck_cap code (CK_CAP_INVALID: revoked, stale or unknown * handle; CK_CAP_MISSING_RIGHTS). *value is written only on CK_MMIO_OK. */ diff --git a/native/kernel/include/ck.h b/native/kernel/include/ck.h index f1e3c048..51aebd19 100644 --- a/native/kernel/include/ck.h +++ b/native/kernel/include/ck.h @@ -48,6 +48,21 @@ volatile void *ck_mmio_map(uint64_t phys, size_t len); * cannot be mapped (for addresses read from firmware tables; added for the * platform xHCI path, NEXT-PHASE-3 cut 2). */ volatile void *ck_mmio_try_map(uint64_t phys, size_t len); +/* Exclusive variant of ck_mmio_try_map for a caller that must later take the + * pages away again (aienos#286, cut B3b). Maps [phys, phys+len) Device-nGnRE + * only if EVERY page in the range is currently unmapped; NULL (and nothing + * mapped) when any page is already mapped by someone else, overlaps RAM, or + * cannot be mapped. ck_mmio_try_map reuses pages that are already mapped, so + * it must never be paired with an unmap. */ +volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len); +/* Unmaps pages mapped by ck_mmio_map_exclusive and invalidates the TLB. 0 on + * success; -1 (nothing changed) if any page of the range is not a Device + * identity mapping of itself or the unmap cannot be done on live tables. + * After it returns 0 a raw access to the range faults. */ +int ck_mmio_unmap_exclusive(uint64_t phys, size_t len); +/* 1 if any page of [phys, phys+len) is currently mapped in the kernel's + * tables (a table lookup, never an access, so it cannot fault), else 0. */ +int ck_mmio_is_mapped(uint64_t phys, size_t len); /* Full system barrier (dsb sy). */ void ck_mb(void); diff --git a/native/kernel/mm/mmu.c b/native/kernel/mm/mmu.c index 2388c6d4..c9ed9185 100644 --- a/native/kernel/mm/mmu.c +++ b/native/kernel/mm/mmu.c @@ -420,3 +420,62 @@ volatile void *ck_mmio_try_map(uint64_t phys, size_t len) { return len ? ck_mm_mmio_try_map(phys, len) : 0; } + +/* Exclusive map for a caller that unmaps again (mmio_window.c). All or + * nothing: if any page is already mapped, by anyone, nothing is mapped. Pages + * are mapped one at a time at level 3 so the unmap never needs to split a + * block (a split is refused on live tables). */ +volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len) +{ + uint64_t lo = phys & ~(CK_PAGE - 1); + uint64_t hi = (phys + len + CK_PAGE - 1) & ~(CK_PAGE - 1); + if (!len || hi <= lo || overlaps_ram(lo, hi)) + return 0; + for (uint64_t p = lo; p < hi; p += CK_PAGE) + if (ck_pt_lookup(&pt, p, 0, 0, 0) == 0) + return 0; + for (uint64_t p = lo; p < hi; p += CK_PAGE) + if (ck_pt_map(&pt, p, p, CK_PAGE, CK_PT_DEVICE)) { + (void)ck_pt_unmap(&pt, lo, p - lo); /* undo: these pages were ours a moment ago */ + if (pt.live) + tlb_sync(); + return 0; + } + if (pt.live) + tlb_sync(); + return (volatile void *)(uintptr_t)phys; +} + +/* Break before make: the entries are made invalid first, then the TLB is + * invalidated and synchronised (tlb_sync) before this returns, so no stale + * translation outlives the call and a later map of the same pages starts from + * invalid entries. */ +int ck_mmio_unmap_exclusive(uint64_t phys, size_t len) +{ + uint64_t lo = phys & ~(CK_PAGE - 1); + uint64_t hi = (phys + len + CK_PAGE - 1) & ~(CK_PAGE - 1); + if (!len || hi <= lo || overlaps_ram(lo, hi)) + return -1; + for (uint64_t p = lo; p < hi; p += CK_PAGE) { + uint64_t a, at; + int lv; + /* Only a Device identity page of its own: never RAM, a block, or a page with other attributes. */ + if (ck_pt_lookup(&pt, p, &a, &at, &lv) != 0 || a != p || lv != 3 || at != CK_PT_DEVICE) + return -1; + } + if (ck_pt_unmap(&pt, lo, hi - lo)) + return -1; + if (pt.live) + tlb_sync(); + return 0; +} + +int ck_mmio_is_mapped(uint64_t phys, size_t len) +{ + uint64_t lo = phys & ~(CK_PAGE - 1); + uint64_t hi = (phys + len + CK_PAGE - 1) & ~(CK_PAGE - 1); + for (uint64_t p = lo; len && p < hi; p += CK_PAGE) + if (ck_pt_lookup(&pt, p, 0, 0, 0) == 0) + return 1; + return 0; +} diff --git a/native/kernel/stage.mk b/native/kernel/stage.mk index bf30825a..4ace1a2f 100644 --- a/native/kernel/stage.mk +++ b/native/kernel/stage.mk @@ -62,7 +62,7 @@ STAGE_FREE_FLAGS := -std=gnu11 -O2 -Wall -Wextra -Werror -ffreestanding -nostdli 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_exception_level ck_conventional_memory_kb \ - ck_acpi_platform_devices ck_dma_confine_named ck_mmio_try_map \ + ck_acpi_platform_devices ck_dma_confine_named ck_mmio_try_map ck_mmio_map_exclusive ck_mmio_unmap_exclusive ck_mmio_is_mapped \ ck_cap_init ck_cap_insert ck_cap_lookup ck_cap_revoke \ ck_entropy_fill ck_entropy_status ck_entropy_reason \ ck_console_rx_ready ck_console_rx_poll ck_console_uart_name ck_console_uart_base diff --git a/native/kernel/svc/tests/ck_host.c b/native/kernel/svc/tests/ck_host.c index e499a03a..ec360e36 100644 --- a/native/kernel/svc/tests/ck_host.c +++ b/native/kernel/svc/tests/ck_host.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "ck.h" #include "ck_compat.h" @@ -86,13 +87,74 @@ volatile void *ck_mmio_map(uint64_t phys, size_t len) } /* Host: no platform MMIO by default (the ACPI platform xHCI list is always * empty). A test may turn on identity mapping (ck_host_try_map_ok) and make - * one exact address fail (ck_host_try_map_fail). */ + * one exact address fail (ck_host_try_map_fail). + * + * The fake also keeps a tiny page map so exclusive ownership and unmap can be + * tested: try_map (shared, like the kernel's) and map_exclusive record the + * page range as mapped; map_exclusive refuses when any page is recorded; + * unmap_exclusive turns the range into PROT_NONE so a raw access really + * faults, and a later map_exclusive restores PROT_READ|PROT_WRITE. */ +#define HOST_PAGE 4096ull +#define HOST_MAPS 16 +static struct { uint64_t lo, hi; int unmapped; } hmap[HOST_MAPS]; +static unsigned hmap_n; +int ck_host_unmap_calls; + +static void host_range(uint64_t phys, size_t len, uint64_t *lo, uint64_t *hi) +{ + *lo = phys & ~(HOST_PAGE - 1); + *hi = (phys + len + HOST_PAGE - 1) & ~(HOST_PAGE - 1); +} +static int host_find(uint64_t lo, uint64_t hi, int unmapped) +{ + for (unsigned i = 0; i < hmap_n; i++) + if (hmap[i].unmapped == unmapped && lo < hmap[i].hi && hmap[i].lo < hi) return (int)i; + return -1; +} +static void host_drop(int i) { hmap[i] = hmap[--hmap_n]; } +static void host_add(uint64_t lo, uint64_t hi) +{ + if (hmap_n < HOST_MAPS) hmap[hmap_n++] = (typeof(hmap[0])){ lo, hi, 0 }; +} +void ck_host_mmio_reset(void) { hmap_n = 0; ck_host_unmap_calls = 0; } + volatile void *ck_mmio_try_map(uint64_t phys, size_t len) { - (void)len; if (!ck_host_try_map_ok || (ck_host_try_map_fail && phys == ck_host_try_map_fail)) return NULL; + uint64_t lo, hi; + host_range(phys, len, &lo, &hi); + if (host_find(lo, hi, 0) < 0) host_add(lo, hi); + return (volatile void *)(uintptr_t)phys; +} +volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len) +{ + if (!len || !ck_host_try_map_ok || (ck_host_try_map_fail && phys == ck_host_try_map_fail)) return NULL; + uint64_t lo, hi; + host_range(phys, len, &lo, &hi); + if (hmap_n >= HOST_MAPS || host_find(lo, hi, 0) >= 0) return NULL; + for (int i; (i = host_find(lo, hi, 1)) >= 0;) { /* pages given back earlier: usable again */ + mprotect((void *)(uintptr_t)hmap[i].lo, hmap[i].hi - hmap[i].lo, PROT_READ | PROT_WRITE); + host_drop(i); + } + host_add(lo, hi); return (volatile void *)(uintptr_t)phys; } +int ck_mmio_is_mapped(uint64_t phys, size_t len) +{ + uint64_t lo, hi; + host_range(phys, len, &lo, &hi); + return len && host_find(lo, hi, 0) >= 0; +} +int ck_mmio_unmap_exclusive(uint64_t phys, size_t len) +{ + uint64_t lo, hi; + host_range(phys, len, &lo, &hi); + int i = len ? host_find(lo, hi, 0) : -1; + if (i < 0 || hmap[i].lo != lo || hmap[i].hi != hi) return -1; + ck_host_unmap_calls++; + hmap[i].unmapped = 1; + return mprotect((void *)(uintptr_t)lo, hi - lo, PROT_NONE) == 0 ? 0 : -1; +} /* Host: no DSDT reachable (no FADT in ck_acpi_find). */ int ck_acpi_platform_devices(const char *const *ids, unsigned nids, struct ck_platform_dev *out, unsigned max, struct ck_acpi_scan_info *info) diff --git a/native/kernel/svc/tests/ck_host.h b/native/kernel/svc/tests/ck_host.h index e50f6fb4..1233b31c 100644 --- a/native/kernel/svc/tests/ck_host.h +++ b/native/kernel/svc/tests/ck_host.h @@ -6,6 +6,8 @@ extern const void *ck_host_mcfg; /* table returned for ck_acpi_find("MCFG") */ extern int ck_host_quiet; /* 1: drop ck_printf output */ extern int ck_host_try_map_ok; /* 1: ck_mmio_try_map is identity (default 0: always NULL) */ extern uint64_t ck_host_try_map_fail; /* with try_map_ok: this exact phys still fails (0: none) */ +extern int ck_host_unmap_calls; /* successful ck_mmio_unmap_exclusive calls */ +void ck_host_mmio_reset(void); /* forget every recorded mapping and the counter */ void ck_host_capture_start(void); /* record ck_printf/ck_puts text (even when quiet) */ const char *ck_host_capture_text(void); /* NUL-terminated text captured since start */ void ck_host_capture_stop(void); diff --git a/native/kernel/svc/tests/stage_test.c b/native/kernel/svc/tests/stage_test.c index 39dfe18d..11f07637 100644 --- a/native/kernel/svc/tests/stage_test.c +++ b/native/kernel/svc/tests/stage_test.c @@ -1577,6 +1577,124 @@ static void test_mmio_window(void) munmap(ecam, FAKE_BYTES); } + +/* ---------------- Unmap on revoke, exclusive page ownership (cut B3b) ---------------- */ + +static void child_read_window(uint8_t *p) { (void)*(volatile uint8_t *)p; } + +/* A synthetic function whose 64-bit BAR0 is the address of `win` (identity + * mapping on the host), command register memory-decode on. */ +static void syn_func(pci_found *f, uint8_t *win) +{ + memset(f, 0, sizeof *f); + f->vendor = 0x1b36; + f->device = 0x0010; + f->class_code = 0x010802; + f->command = 0x2; + f->bar_raw[0] = (uint32_t)(uintptr_t)win | 4u; + f->bar_raw[1] = (uint32_t)((uint64_t)(uintptr_t)win >> 32); +} + +static void test_mmio_unmap(void) +{ + uint8_t *win = mmap(NULL, 2 * WIN_BYTES, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + CHECK(win != MAP_FAILED); + if (win == MAP_FAILED) return; + for (size_t i = 0; i < 2 * WIN_BYTES; i++) win[i] = win_pat(i); + uint8_t *next = win + WIN_BYTES; /* neighbouring page, not part of the window */ + pci_found f; + syn_func(&f, win); + uint64_t addr = (uint64_t)(uintptr_t)win; + + struct ck_mmio_registry reg; + struct ck_cap_table tab, tab2; + struct ck_cap_table *const tabs[2] = {&tab, &tab2}; + struct ck_handle h, c, c2, again; + uint64_t v = 0; + ck_host_mmio_reset(); + ck_host_try_map_ok = 1; + ck_host_try_map_fail = 0; + ck_mmio_registry_init(®); + ck_cap_init(&tab, 1, CK_CAP_SLOTS); + ck_cap_init(&tab2, 2, CK_CAP_SLOTS); + + /* Exclusive ownership: pages someone else already mapped (nvme_bind maps + * the same BAR0) are refused, nothing is created, and the other mapping + * is untouched. */ + CHECK(ck_mmio_try_map(addr, WIN_BYTES) != NULL); + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_MAP); + CHECK(reg.next == 0 && ck_host_unmap_calls == 0 && ck_mmio_is_mapped(addr, WIN_BYTES)); + CHECK(child_died_on_write(child_read_window, win) == 0); + ck_host_mmio_reset(); /* the other owner is gone */ + + /* Open, read, derive. */ + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_OK); + CHECK(reg.next == 1 && reg.w[0].owned == 1 && reg.w[0].mapped == 1 && reg.w[0].bus_addr == addr); + CHECK(ck_mmio_is_mapped(addr, WIN_BYTES)); + CHECK(ck_mmio_read(®, &tab, h, 8, 4, &v) == CK_MMIO_OK && v == win_expect(8, 4)); + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &again) == CK_MMIO_E_MAP); /* second owner refused */ + CHECK(ck_mmio_try_map(addr + WIN_BYTES, WIN_BYTES) != NULL); /* an unrelated neighbour page */ + CHECK(ck_cap_derive_into(&tab, h, &tab2, CK_R_READ | CK_R_REVOKE, &c) == CK_CAP_OK); + CHECK(ck_cap_derive(&tab, h, CK_R_READ, &c2) == CK_CAP_OK); + CHECK(ck_mmio_read(®, &tab2, c, 16, 4, &v) == CK_MMIO_OK && v == win_expect(16, 4)); + /* NEGATIVE CONTROL: with no revoke, the raw read in a child succeeds, so a + * fault below can only come from the revoke. */ + CHECK(child_died_on_write(child_read_window, win) == 0); + + /* Revoking one derived child leaves the parent, its other children and the + * pages alone. */ + CHECK(ck_mmio_revoke(®, tab2.id, c, tabs, 2) == CK_CAP_OK); + CHECK(ck_mmio_read(®, &tab2, c, 16, 4, &v) == CK_CAP_INVALID); + CHECK(ck_mmio_read(®, &tab, h, 8, 4, &v) == CK_MMIO_OK); + CHECK(ck_mmio_is_mapped(addr, WIN_BYTES) && ck_host_unmap_calls == 0 && reg.w[0].mapped == 1); + CHECK(child_died_on_write(child_read_window, win) == 0); + + /* Revoking the parent removes every remaining capability and unmaps. */ + CHECK(ck_mmio_revoke(®, tab.id, h, tabs, 2) == CK_CAP_OK); + CHECK(ck_mmio_read(®, &tab, h, 8, 4, &v) == CK_CAP_INVALID); + CHECK(ck_mmio_read(®, &tab, c2, 8, 4, &v) == CK_CAP_INVALID); + CHECK(!ck_mmio_is_mapped(addr, WIN_BYTES) && ck_host_unmap_calls == 1 && reg.w[0].mapped == 0); + CHECK(child_died_on_write(child_read_window, win) == 1); /* raw access faults at the MMU */ + CHECK(child_died_on_write(child_read_window, win + WIN_BYTES - 8) == 1); + CHECK(child_died_on_write(child_read_window, next) == 0); /* neighbour page untouched */ + CHECK(ck_mmio_is_mapped(addr + WIN_BYTES, WIN_BYTES)); + + /* Double revoke is harmless: refused, no second unmap. */ + CHECK(ck_mmio_revoke(®, tab.id, h, tabs, 2) == CK_CAP_INVALID); + CHECK(ck_host_unmap_calls == 1); + + /* The pages are free again for a new owner (what nvme_bind does after the + * report); numbers still never repeat. */ + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &again) == CK_MMIO_OK); + CHECK(reg.next == 2 && reg.w[1].resource != reg.w[0].resource); + CHECK(ck_mmio_read(®, &tab, h, 0, 4, &v) == CK_CAP_INVALID); + CHECK(ck_mmio_read(®, &tab, again, 0, 4, &v) == CK_MMIO_OK && v == win_expect(0, 4)); + CHECK(child_died_on_write(child_read_window, win) == 0); + CHECK(ck_mmio_revoke(®, tab.id, again, tabs, 2) == CK_CAP_OK && ck_host_unmap_calls == 2); + + /* A borrowed window (ck_mmio_window_create) revokes the capability only. */ + ck_host_mmio_reset(); + CHECK(mprotect(win, WIN_BYTES, PROT_READ | PROT_WRITE) == 0); + CHECK(ck_mmio_window_create(®, &tab, &f, 0, WIN_BYTES, win, CK_MMIO_RIGHTS, &h) == CK_MMIO_OK); + CHECK(reg.w[reg.next - 1].owned == 0); + CHECK(ck_mmio_revoke(®, tab.id, h, tabs, 2) == CK_CAP_OK && ck_host_unmap_calls == 0); + CHECK(ck_mmio_read(®, &tab, h, 0, 4, &v) == CK_CAP_INVALID); + CHECK(child_died_on_write(child_read_window, win) == 0); + + /* Argument and failure edges. */ + CHECK(ck_mmio_window_open(NULL, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_ARG); + CHECK(ck_mmio_window_open(®, &tab, &f, 0, 0, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_ARG); + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_R_READ | CK_R_WRITE, &h) == CK_MMIO_E_RIGHTS); + CHECK(ck_mmio_window_open(®, &tab, &f, 2, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_BAR); + CHECK(ck_mmio_revoke(NULL, tab.id, h, tabs, 2) == CK_MMIO_E_ARG); + ck_host_try_map_ok = 0; + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_MAP); + ck_host_try_map_ok = 1; + munmap(win, 2 * WIN_BYTES); + ck_host_mmio_reset(); + ck_host_try_map_ok = 0; +} + /* The stage report binds a window to a discovered NVMe BAR0, reads VS * through the capability, and shows the read refused after revoke. */ static void test_mmio_stage_report(void) @@ -1608,7 +1726,7 @@ static void test_mmio_stage_report(void) ck_host_capture_stop(); const char *x = ck_host_capture_text(); CHECK(has(x, "mmio_win: 0000:00:02.0 bar0 addr=0x")); - CHECK(has(x, "size=0x1000 create=0 read(VS)=0 value=0x10400 past-end=-504 revoke=0 after-revoke=-2 (read-only, report-only)\n")); + CHECK(has(x, "size=0x1000 create=0 read(VS)=0 value=0x10400 past-end=-504 revoke=0 after-revoke=-2 unmapped=1 (read-only, report-only)\n")); /* Map refused: reported, nothing bound. */ ck_host_try_map_ok = 0; ck_host_capture_start(); @@ -1655,6 +1773,7 @@ int main(void) test_discover_report(); test_discover_in_stage(); test_mmio_window(); + test_mmio_unmap(); test_mmio_stage_report(); test_store(); test_artifact_store(); diff --git a/native/kernel/tests/test_pt.c b/native/kernel/tests/test_pt.c index ee7ebc10..96107340 100644 --- a/native/kernel/tests/test_pt.c +++ b/native/kernel/tests/test_pt.c @@ -141,6 +141,17 @@ int main(void) CHECK(ck_pt_map(&pt, 2 * G + 0x400000, 2 * G + 0x400000, K4, CK_PT_DEVICE) == CK_PT_ELIVE); CHECK(ck_pt_unmap(&pt, 2 * G + 0x400000, K4) == CK_PT_ELIVE); expect(pt.root, 2 * G + 0x400000, 2 * G + 0x400000, CK_PT_NORMAL_RW, 2); /* block split by the stack guard */ + /* Live unmap of one level-3 page (MMIO window revoke): the page becomes a + * hole, neighbours are untouched, and the hole can be mapped again (the + * live rule only fills invalid entries). A block would need a split. */ + CHECK(ck_pt_unmap(&pt, 0x08004000, K4) == 0); + expect_hole(pt.root, 0x08004000); + expect_hole(pt.root, 0x08004ff8); + expect(pt.root, 0x08003000, 0x08003000, CK_PT_DEVICE, 3); + expect(pt.root, 0x08005000, 0x08005000, CK_PT_DEVICE, 3); + CHECK(ck_pt_unmap(&pt, 0x08004000, K4) == 0); /* unmapping a hole is harmless */ + CHECK(ck_pt_map(&pt, 0x08004000, 0x08004000, K4, CK_PT_DEVICE) == 0); + expect(pt.root, 0x08004000, 0x08004000, CK_PT_DEVICE, 3); pt.live = 0; /* ck_pt_lookup agrees with the independent walk. */ From 944158e887b2ee703709b46bdc6fa3950f9fcbe2 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 8 Oct 2026 14:15:09 -0500 Subject: [PATCH 2/4] Crumbs: recompile after B3b Co-Authored-By: Claude Opus 5.5 --- .crumb | 14 +++++++------- native/.crumb | 14 +++++++------- native/kernel/.crumb | 30 +++++++++++++++--------------- native/kernel/dev/.crumb | 8 ++++---- native/kernel/include/.crumb | 8 ++++---- native/kernel/mm/.crumb | 8 ++++---- native/kernel/svc/.crumb | 14 +++++++------- native/kernel/svc/tests/.crumb | 8 ++++---- native/kernel/tests/.crumb | 8 ++++---- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.crumb b/.crumb index 18120cdd..8a1d5223 100644 --- a/.crumb +++ b/.crumb @@ -33,8 +33,8 @@ "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "84d2e721df0eeb0c4b1acaf25fb3cd47b5eb0e13e1c9289bab5efb2b1ad4cb9c", - "last_commit": "d9a09b4", + "digest": "b9a1bf2c3c28708197a62759140771981e1d34ba10cb38c591ccdff1fdb2d51e", + "last_commit": "9696c7d", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, @@ -45,15 +45,15 @@ "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:b9186f6414bad51b543a394fa6faf5599e569e1a9720296cd13937cc4d5135a7", - "compiled_at": "2026-10-08T18:19:51Z", + "children_root": "sha256:66c2033455f6d4059747d102f8fb3c30033a3256feb34cae6c2203030b4df714", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:ffbf85921fd0ea36d7e12d5a61a4d045bbfd4b93da2f2774b25b3dcf778a82f5", + "digest": "sha256:1fcca8b2472b3370a8f82866711392574bd7b56860494b47e97e2129b2a12608", "evidence_files": 153, "evidence_root": "sha256:29aa8775feb12d9e0e64b41fc1fc48b97e32dc16bf9176562cbe9fe1ea934f00", "files": 3026, - "generated_at_commit": "d9a09b4a2ba23b64d9b2ab213ff322beb8e1ea5b", - "source_tree": "sha256:dc283646cd7184057047f7bee34dda33f953a68de9ce62999c1889029254e009" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:27d7c98b5b83dc62f4eaa138be89bb0cf961d9cad1b6a133dcd8c246b3b53071" }, "owner_lane": "", "provenance": { diff --git a/native/.crumb b/native/.crumb index c04bf9ab..5a95fb3b 100644 --- a/native/.crumb +++ b/native/.crumb @@ -79,8 +79,8 @@ "purpose": "Directory native/disk. Purpose not yet described by a human." }, { - "digest": "7b5020b1d5601578af653dfdc6a37995c7f0929bb417641c7e062d9a76761bf5", - "last_commit": "d9a09b4", + "digest": "5329c800b73600e87a216d5c1439c10ca7cc6afebe71def6b324a463093d106b", + "last_commit": "9696c7d", "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:8dc331ec7d5baf5c83b8382fd332cf58ddffc92609e200d7ede2d4742ae8c9e7", - "compiled_at": "2026-10-08T18:19:51Z", + "children_root": "sha256:9e99ae3c96e8200d4966cd00e5258778aed19a8703fa62e9bee9f7997d182eb1", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:84d2e721df0eeb0c4b1acaf25fb3cd47b5eb0e13e1c9289bab5efb2b1ad4cb9c", + "digest": "sha256:b9a1bf2c3c28708197a62759140771981e1d34ba10cb38c591ccdff1fdb2d51e", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 453, - "generated_at_commit": "d9a09b4a2ba23b64d9b2ab213ff322beb8e1ea5b", - "source_tree": "sha256:c54cb8f5995615f49916244cbaa35089256218d243a9cf11c940bf1d4b44796c" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:e6c5b0b1bcdfa92ddba1985fbf42020ec6d0434f883aa3b3b7917ba7db6e8ca1" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/.crumb b/native/kernel/.crumb index 18a65af7..7fde730d 100644 --- a/native/kernel/.crumb +++ b/native/kernel/.crumb @@ -63,32 +63,32 @@ "purpose": "Directory native/kernel/core. Purpose not yet described by a human." }, { - "digest": "6c054ed3205f37694f7bd38c79842dccc48f622a39ac50b26917064ed506092f", - "last_commit": "c270ad5", + "digest": "e2191228f95358821035617f00f113aad369327041f737f270b92c6e1ad736fb", + "last_commit": "9696c7d", "name": "dev", "purpose": "Directory native/kernel/dev. Purpose not yet described by a human." }, { - "digest": "4a14f71ed7d1e067b7ead5dacb0c2fda6217626ba5bdf377b3d33701cee109f9", - "last_commit": "8641977", + "digest": "e650493f5b00f0c22a9415f6b6bac3682d0ae95da8d22f4f96768ce420f180c4", + "last_commit": "9696c7d", "name": "include", "purpose": "Directory native/kernel/include. Purpose not yet described by a human." }, { - "digest": "05fee5afbbfcbca9eab294bfc3778bc380b2eaa1c95a595b6946971a180f0665", - "last_commit": "6da9d58", + "digest": "22912c31743025e6c18a4a4f644ad3158d2e3b3c10e01d5b28ff841fe0f7e707", + "last_commit": "9696c7d", "name": "mm", "purpose": "Directory native/kernel/mm. Purpose not yet described by a human." }, { - "digest": "1ff0f553f38615dae0ee14458129ccd58ba3b0c9ac82d939c64ad9e9e4bc1aae", - "last_commit": "c270ad5", + "digest": "8349ed49b642fd5489c8f859f9a67aae899b1b5e7fbae07069fade40dc8fba87", + "last_commit": "9696c7d", "name": "svc", "purpose": "Directory native/kernel/svc. Purpose not yet described by a human." }, { - "digest": "a2824603eee1429e7fe251a0051d43ec3d3822ba7f3796d2d554c359f0588ed0", - "last_commit": "3b26ea9", + "digest": "914e88d9cb6247068ad34e800b17579e9f4d3717c4a9e94cd66ee44ecf0b9bc0", + "last_commit": "9696c7d", "name": "tests", "purpose": "Directory native/kernel/tests. Purpose not yet described by a human." }, @@ -99,15 +99,15 @@ "purpose": "Directory native/kernel/tools. Purpose not yet described by a human." } ], - "children_root": "sha256:a5315e263789a217f08300f54a18a2b61db9869353601d27e195515b84040f2b", - "compiled_at": "2026-10-08T18:19:51Z", + "children_root": "sha256:05416b6052a4fdb866937aeeae0a1878828db6112c2f5eeb92afcb01156ea7c6", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:7b5020b1d5601578af653dfdc6a37995c7f0929bb417641c7e062d9a76761bf5", + "digest": "sha256:5329c800b73600e87a216d5c1439c10ca7cc6afebe71def6b324a463093d106b", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 289, - "generated_at_commit": "d9a09b4a2ba23b64d9b2ab213ff322beb8e1ea5b", - "source_tree": "sha256:d864eccd3e1ace0f7d216d41cab1a7fb435965fd9b31c82f2780b369583591bc" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:34bed9cfb076fbfa072ded84e6496a3ea73e4d59898b8cd2124994aa840f2bf5" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/dev/.crumb b/native/kernel/dev/.crumb index b40d6a28..f6fe6ecf 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-08T17:47:58Z", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:6c054ed3205f37694f7bd38c79842dccc48f622a39ac50b26917064ed506092f", + "digest": "sha256:e2191228f95358821035617f00f113aad369327041f737f270b92c6e1ad736fb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 27, - "generated_at_commit": "c270ad5b9efba86bc97ddf170eff477d086d804c", - "source_tree": "sha256:14f19d1a5200638171d1b8158742c04de82dda42a62590ed350e88241cf852ee" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:ed12f5a67c25ce6ff90877044f30aca8ed0727d21b170d520d4d0e745d568de4" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/include/.crumb b/native/kernel/include/.crumb index ccdb3bed..683787a6 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-08T04:37:23Z", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:4a14f71ed7d1e067b7ead5dacb0c2fda6217626ba5bdf377b3d33701cee109f9", + "digest": "sha256:e650493f5b00f0c22a9415f6b6bac3682d0ae95da8d22f4f96768ce420f180c4", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 1, - "generated_at_commit": "e387b502b58d9d15fd2751ec5ef4c60f93862244", - "source_tree": "sha256:2134231c6d9c434d108ea24f8bc7d2663fc5e688c62c91c6c07755c93ebbf1b6" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:a0dfb41ff4da70076ceda943e9b0d4c3cc18be53263471443f2dbbf1df44db27" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/mm/.crumb b/native/kernel/mm/.crumb index a52f4bcf..bca1f1ee 100644 --- a/native/kernel/mm/.crumb +++ b/native/kernel/mm/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-06T02:21:10Z", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:05fee5afbbfcbca9eab294bfc3778bc380b2eaa1c95a595b6946971a180f0665", + "digest": "sha256:22912c31743025e6c18a4a4f644ad3158d2e3b3c10e01d5b28ff841fe0f7e707", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 7, - "generated_at_commit": "4bbc7e66f4e28b91c523acf8f4b296dfe2141e71", - "source_tree": "sha256:e02f28ddffec29c55a3c740c286b81751c77d73398db03c14077aaecd4c276d5" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:6830af0470b51e0a583f67b37b40e23381ddd4239a46536a556638fa42a62c30" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb index 380b37fa..3e61e3d0 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": "c5c66bebf979e5722deb500f0b3b31d912aff8395869f5afe91cd7e5c48e3c00", - "last_commit": "c270ad5", + "digest": "2059bcd5cb9c44b129f59aa2e02b3136527af0d4fb5681513f8e4711ff061856", + "last_commit": "9696c7d", "name": "tests", "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human." } ], - "children_root": "sha256:d5d0b083e51a293b3a0567f43ee275b119aa34f40f978f8e428712864cae91f8", - "compiled_at": "2026-10-08T17:47:58Z", + "children_root": "sha256:91b86874a76163722da21f2aefb7ad1d4287baf3809a16fded1a1927fb4e4caa", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:1ff0f553f38615dae0ee14458129ccd58ba3b0c9ac82d939c64ad9e9e4bc1aae", + "digest": "sha256:8349ed49b642fd5489c8f859f9a67aae899b1b5e7fbae07069fade40dc8fba87", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 35, - "generated_at_commit": "c270ad5b9efba86bc97ddf170eff477d086d804c", - "source_tree": "sha256:6bdd1249992f9496bf6c1f07cf5460cd1ed02891afbef16a722a7066b7800d8d" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:7cb932e4de84619bd9fd38d4f06e6caa95325b63d5cb5bb0047112455902cda1" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/tests/.crumb b/native/kernel/svc/tests/.crumb index 8c9a776f..1f0a6f52 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-08T17:47:58Z", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:c5c66bebf979e5722deb500f0b3b31d912aff8395869f5afe91cd7e5c48e3c00", + "digest": "sha256:2059bcd5cb9c44b129f59aa2e02b3136527af0d4fb5681513f8e4711ff061856", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 3, - "generated_at_commit": "c270ad5b9efba86bc97ddf170eff477d086d804c", - "source_tree": "sha256:b7be231aaa5a282aa132312009a2af92960ae90bc6e7ff368fdc127a144d9070" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:3dd493c0c389003b5c373ee99e0601275dee20d28b404a80e3eff8bb1b6e4d40" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/tests/.crumb b/native/kernel/tests/.crumb index 0ac6d975..7c27bf49 100644 --- a/native/kernel/tests/.crumb +++ b/native/kernel/tests/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-08T14:02:25Z", + "compiled_at": "2026-10-08T19:15:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:a2824603eee1429e7fe251a0051d43ec3d3822ba7f3796d2d554c359f0588ed0", + "digest": "sha256:914e88d9cb6247068ad34e800b17579e9f4d3717c4a9e94cd66ee44ecf0b9bc0", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 148, - "generated_at_commit": "3b26ea92c67fbee8db58539e03b55ccb9b35bc53", - "source_tree": "sha256:13393b1e9ad6c4f04a28a172170c609f6432ac642723ad01c0d4a7ecd92d3e6a" + "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", + "source_tree": "sha256:26ea29075b182391a5b2d8e126807b405cd78db10c9f9d5446cf041813a373e7" }, "owner_lane": "", "provenance": { From 6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 8 Oct 2026 14:22:53 -0500 Subject: [PATCH 3/4] Kernel: refuse shared maps over live exclusive MMIO ranges; document bare-revoke rule (aienos#286, cut B3b) Co-Authored-By: Claude Opus 5.5 --- native/kernel/dev/mmio_window.c | 5 ++-- native/kernel/dev/mmio_window.h | 13 +++++++++-- native/kernel/mm/mmu.c | 34 +++++++++++++++++++++++++-- native/kernel/svc/tests/ck_host.c | 35 +++++++++++++++++++--------- native/kernel/svc/tests/stage_test.c | 33 ++++++++++++++++++++++++-- 5 files changed, 101 insertions(+), 19 deletions(-) diff --git a/native/kernel/dev/mmio_window.c b/native/kernel/dev/mmio_window.c index 9656dd3c..bc34e534 100644 --- a/native/kernel/dev/mmio_window.c +++ b/native/kernel/dev/mmio_window.c @@ -189,10 +189,11 @@ int ck_mmio_stage_report(void) uint64_t vs = 0, again = 0; int rrc = crc ? crc : ck_mmio_read(®, &tab, h, 0x08, 4, &vs); /* NVMe VS register */ int wrc = crc ? crc : ck_mmio_read(®, &tab, h, 0x1000, 4, &again); /* one past the window */ + int shrc = crc ? crc : ck_mmio_try_map(addr, 0x1000) == 0; /* 1: a second (shared) map of the live window is refused */ int vrc = crc ? crc : ck_mmio_revoke(®, tab.id, h, tabs, 1); int arc = crc ? crc : ck_mmio_read(®, &tab, h, 0x08, 4, &again); ck_printf("mmio_win: %04x:%02x:%02x.%u bar0 addr=0x%llx size=0x1000 create=%d read(VS)=%d value=0x%llx " - "past-end=%d revoke=%d after-revoke=%d unmapped=%d (read-only, report-only)\n", - nv->segment, nv->bus, nv->dev, nv->fn, (unsigned long long)addr, crc, rrc, (unsigned long long)vs, wrc, vrc, arc, crc ? -1 : !ck_mmio_is_mapped(addr, 0x1000)); + "past-end=%d shared-map-refused=%d revoke=%d after-revoke=%d unmapped=%d (read-only, report-only)\n", + nv->segment, nv->bus, nv->dev, nv->fn, (unsigned long long)addr, crc, rrc, (unsigned long long)vs, wrc, shrc, vrc, arc, crc ? -1 : !ck_mmio_is_mapped(addr, 0x1000)); return CK_MMIO_OK; } diff --git a/native/kernel/dev/mmio_window.h b/native/kernel/dev/mmio_window.h index f72211f2..f638d948 100644 --- a/native/kernel/dev/mmio_window.h +++ b/native/kernel/dev/mmio_window.h @@ -27,12 +27,21 @@ * refusal stays as a second layer. Refuse-not-refcount was chosen on purpose: * a shared page would make revoke depend on a stranger. Windows made with * ck_mmio_window_create (borrowed mapping) still revoke the capability only. + * Exclusivity holds in both directions: while a window is live, the kernel's + * ck_mm_mmio_try_map refuses (NULL) and ck_mmio_map panics for any range that + * overlaps its pages, so a driver cannot share them later either. + * + * RULE: window capabilities must be revoked through ck_mmio_revoke. A bare + * ck_cap_revoke removes the capability and the accessor refuses, but the + * window is never told, so its pages stay mapped (tested in stage_test.c). + * That is the remaining exposure; there is no lazy cleanup, because a revoked + * handle no longer reaches the window. * * Limits (named): BAR size is not discoverable here, so the caller supplies * it from firmware or a fixture; the mapping is Device RW even though the * accessor is read-only (no read-only Device mapping is made); revoke must go - * through ck_mmio_revoke (a bare ck_cap_revoke still refuses the accessor but - * leaves the pages mapped); no interrupts, no DMA, no polling helper, no + * through ck_mmio_revoke (see RULE above); the exclusive-range table holds 8 + * ranges and a ninth window is refused with CK_MMIO_E_MAP; no interrupts, no DMA, no polling helper, no * config-space or COMMAND changes. */ #ifndef AIENOS_CK_MMIO_WINDOW_H #define AIENOS_CK_MMIO_WINDOW_H diff --git a/native/kernel/mm/mmu.c b/native/kernel/mm/mmu.c index c9ed9185..9d497bd5 100644 --- a/native/kernel/mm/mmu.c +++ b/native/kernel/mm/mmu.c @@ -46,6 +46,16 @@ static struct { } ram[RAM_MAX]; static unsigned ram_n; +/* Live exclusive MMIO ranges (ck_mmio_map_exclusive). Fixed table: when full, a + * new exclusive map is refused (fail closed). ck_mm_mmio_try_map and + * ck_mmio_map refuse to share these pages, so an unmap can never pull a + * mapping out from under another driver. */ +#define EXCL_MAX 8 +static struct { + uint64_t lo, hi; +} excl[EXCL_MAX]; +static unsigned excl_n; + static int pt_alloc(void *ctx, uint64_t *phys) { (void)ctx; @@ -68,6 +78,14 @@ static int overlaps_ram(uint64_t lo, uint64_t hi) return 0; } +static int overlaps_excl(uint64_t lo, uint64_t hi) +{ + for (unsigned i = 0; i < excl_n; i++) + if (lo < excl[i].hi && excl[i].lo < hi) + return 1; + return 0; +} + static void must(int rc, const char *what) { if (rc) @@ -322,6 +340,9 @@ volatile void *ck_mmio_map(uint64_t phys, size_t len) if (hi < lo || overlaps_ram(lo, hi)) ck_panic("ck_mmio_map: 0x%llx+0x%llx overlaps RAM", (unsigned long long)phys, (unsigned long long)len); + if (overlaps_excl(lo, hi)) + ck_panic("ck_mmio_map: 0x%llx+0x%llx overlaps an exclusive MMIO window", (unsigned long long)phys, + (unsigned long long)len); int rc = ck_pt_map(&pt, lo, lo, hi - lo, CK_PT_DEVICE); if (rc) ck_panic("ck_mmio_map: 0x%llx+0x%llx rc=%d", (unsigned long long)phys, @@ -399,7 +420,7 @@ volatile void *ck_mm_mmio_try_map(uint64_t phys, size_t len) { uint64_t lo = phys & ~(CK_PAGE - 1); uint64_t hi = (phys + len + CK_PAGE - 1) & ~(CK_PAGE - 1); - if (!len || hi <= lo || overlaps_ram(lo, hi)) + if (!len || hi <= lo || overlaps_ram(lo, hi) || overlaps_excl(lo, hi)) return 0; for (uint64_t p = lo; p < hi; p += CK_PAGE) { uint64_t a; @@ -429,7 +450,8 @@ volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len) { uint64_t lo = phys & ~(CK_PAGE - 1); uint64_t hi = (phys + len + CK_PAGE - 1) & ~(CK_PAGE - 1); - if (!len || hi <= lo || overlaps_ram(lo, hi)) + if (!len || hi <= lo || overlaps_ram(lo, hi) || overlaps_excl(lo, hi) || + excl_n >= EXCL_MAX) return 0; for (uint64_t p = lo; p < hi; p += CK_PAGE) if (ck_pt_lookup(&pt, p, 0, 0, 0) == 0) @@ -441,6 +463,8 @@ volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len) tlb_sync(); return 0; } + excl[excl_n].lo = lo; + excl[excl_n++].hi = hi; if (pt.live) tlb_sync(); return (volatile void *)(uintptr_t)phys; @@ -456,6 +480,11 @@ int ck_mmio_unmap_exclusive(uint64_t phys, size_t len) uint64_t hi = (phys + len + CK_PAGE - 1) & ~(CK_PAGE - 1); if (!len || hi <= lo || overlaps_ram(lo, hi)) return -1; + unsigned e = 0; + while (e < excl_n && !(excl[e].lo == lo && excl[e].hi == hi)) + e++; + if (e == excl_n) /* only a range handed out by ck_mmio_map_exclusive can be taken back */ + return -1; for (uint64_t p = lo; p < hi; p += CK_PAGE) { uint64_t a, at; int lv; @@ -465,6 +494,7 @@ int ck_mmio_unmap_exclusive(uint64_t phys, size_t len) } if (ck_pt_unmap(&pt, lo, hi - lo)) return -1; + excl[e] = excl[--excl_n]; /* the range is free for ordinary maps again */ if (pt.live) tlb_sync(); return 0; diff --git a/native/kernel/svc/tests/ck_host.c b/native/kernel/svc/tests/ck_host.c index ec360e36..76fa74cd 100644 --- a/native/kernel/svc/tests/ck_host.c +++ b/native/kernel/svc/tests/ck_host.c @@ -80,11 +80,6 @@ void *ck_dma_alloc(size_t bytes, size_t align, uint64_t *phys) if (phys) *phys = (uint64_t)(uintptr_t)p; return p; } -volatile void *ck_mmio_map(uint64_t phys, size_t len) -{ - (void)len; - return (volatile void *)(uintptr_t)phys; -} /* Host: no platform MMIO by default (the ACPI platform xHCI list is always * empty). A test may turn on identity mapping (ck_host_try_map_ok) and make * one exact address fail (ck_host_try_map_fail). @@ -96,7 +91,7 @@ volatile void *ck_mmio_map(uint64_t phys, size_t len) * faults, and a later map_exclusive restores PROT_READ|PROT_WRITE. */ #define HOST_PAGE 4096ull #define HOST_MAPS 16 -static struct { uint64_t lo, hi; int unmapped; } hmap[HOST_MAPS]; +static struct { uint64_t lo, hi; int unmapped, excl; } hmap[HOST_MAPS]; static unsigned hmap_n; int ck_host_unmap_calls; @@ -112,9 +107,16 @@ static int host_find(uint64_t lo, uint64_t hi, int unmapped) return -1; } static void host_drop(int i) { hmap[i] = hmap[--hmap_n]; } -static void host_add(uint64_t lo, uint64_t hi) +static void host_add(uint64_t lo, uint64_t hi, int excl) { - if (hmap_n < HOST_MAPS) hmap[hmap_n++] = (typeof(hmap[0])){ lo, hi, 0 }; + if (hmap_n < HOST_MAPS) hmap[hmap_n++] = (typeof(hmap[0])){ lo, hi, 0, excl }; +} +/* Same rule as the kernel: a live exclusive range is never shared. */ +static int host_excl_live(uint64_t lo, uint64_t hi) +{ + for (unsigned i = 0; i < hmap_n; i++) + if (hmap[i].excl && !hmap[i].unmapped && lo < hmap[i].hi && hmap[i].lo < hi) return 1; + return 0; } void ck_host_mmio_reset(void) { hmap_n = 0; ck_host_unmap_calls = 0; } @@ -123,7 +125,12 @@ volatile void *ck_mmio_try_map(uint64_t phys, size_t len) if (!ck_host_try_map_ok || (ck_host_try_map_fail && phys == ck_host_try_map_fail)) return NULL; uint64_t lo, hi; host_range(phys, len, &lo, &hi); - if (host_find(lo, hi, 0) < 0) host_add(lo, hi); + if (host_excl_live(lo, hi)) return NULL; + for (int i; (i = host_find(lo, hi, 1)) >= 0;) { /* pages given back earlier: usable again */ + mprotect((void *)(uintptr_t)hmap[i].lo, hmap[i].hi - hmap[i].lo, PROT_READ | PROT_WRITE); + host_drop(i); + } + if (host_find(lo, hi, 0) < 0) host_add(lo, hi, 0); return (volatile void *)(uintptr_t)phys; } volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len) @@ -136,7 +143,7 @@ volatile void *ck_mmio_map_exclusive(uint64_t phys, size_t len) mprotect((void *)(uintptr_t)hmap[i].lo, hmap[i].hi - hmap[i].lo, PROT_READ | PROT_WRITE); host_drop(i); } - host_add(lo, hi); + host_add(lo, hi, 1); return (volatile void *)(uintptr_t)phys; } int ck_mmio_is_mapped(uint64_t phys, size_t len) @@ -145,12 +152,18 @@ int ck_mmio_is_mapped(uint64_t phys, size_t len) host_range(phys, len, &lo, &hi); return len && host_find(lo, hi, 0) >= 0; } +volatile void *ck_mmio_map(uint64_t phys, size_t len) +{ + if (len && host_excl_live(phys & ~(HOST_PAGE - 1), (phys + len + HOST_PAGE - 1) & ~(HOST_PAGE - 1))) + ck_panic("ck_mmio_map: 0x%llx overlaps an exclusive MMIO window", (unsigned long long)phys); + return (volatile void *)(uintptr_t)phys; +} int ck_mmio_unmap_exclusive(uint64_t phys, size_t len) { uint64_t lo, hi; host_range(phys, len, &lo, &hi); int i = len ? host_find(lo, hi, 0) : -1; - if (i < 0 || hmap[i].lo != lo || hmap[i].hi != hi) return -1; + if (i < 0 || !hmap[i].excl || hmap[i].lo != lo || hmap[i].hi != hi) return -1; ck_host_unmap_calls++; hmap[i].unmapped = 1; return mprotect((void *)(uintptr_t)lo, hi - lo, PROT_NONE) == 0 ? 0 : -1; diff --git a/native/kernel/svc/tests/stage_test.c b/native/kernel/svc/tests/stage_test.c index 11f07637..eb7a27a4 100644 --- a/native/kernel/svc/tests/stage_test.c +++ b/native/kernel/svc/tests/stage_test.c @@ -1637,6 +1637,14 @@ static void test_mmio_unmap(void) CHECK(ck_cap_derive_into(&tab, h, &tab2, CK_R_READ | CK_R_REVOKE, &c) == CK_CAP_OK); CHECK(ck_cap_derive(&tab, h, CK_R_READ, &c2) == CK_CAP_OK); CHECK(ck_mmio_read(®, &tab2, c, 16, 4, &v) == CK_MMIO_OK && v == win_expect(16, 4)); + /* Live window: nobody else may share its pages (a shared page would be + * unmapped under them by the revoke). Overlap of any kind is refused; + * non-overlapping neighbours are unaffected. */ + CHECK(ck_mmio_try_map(addr, WIN_BYTES) == NULL); /* open: same pages */ + CHECK(ck_mmio_try_map(addr + 0x800, 0x10) == NULL); /* inside */ + CHECK(ck_mmio_try_map(addr - WIN_BYTES, 2 * WIN_BYTES) == NULL); /* straddles the start */ + CHECK(ck_mmio_try_map(addr + WIN_BYTES, WIN_BYTES) != NULL); /* the neighbour (already mapped above) */ + CHECK(ck_mmio_try_map(addr + 2 * WIN_BYTES, WIN_BYTES) != NULL); /* NEGATIVE CONTROL: with no revoke, the raw read in a child succeeds, so a * fault below can only come from the revoke. */ CHECK(child_died_on_write(child_read_window, win) == 0); @@ -1663,6 +1671,12 @@ static void test_mmio_unmap(void) CHECK(ck_mmio_revoke(®, tab.id, h, tabs, 2) == CK_CAP_INVALID); CHECK(ck_host_unmap_calls == 1); + /* After the revoke the pages are ordinary free pages again: a shared map + * (what a driver does) is accepted, and then a window is refused. */ + CHECK(ck_mmio_try_map(addr, WIN_BYTES) != NULL); + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &again) == CK_MMIO_E_MAP); + CHECK(child_died_on_write(child_read_window, win) == 0); + ck_host_mmio_reset(); /* The pages are free again for a new owner (what nvme_bind does after the * report); numbers still never repeat. */ CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &again) == CK_MMIO_OK); @@ -1670,7 +1684,21 @@ static void test_mmio_unmap(void) CHECK(ck_mmio_read(®, &tab, h, 0, 4, &v) == CK_CAP_INVALID); CHECK(ck_mmio_read(®, &tab, again, 0, 4, &v) == CK_MMIO_OK && v == win_expect(0, 4)); CHECK(child_died_on_write(child_read_window, win) == 0); - CHECK(ck_mmio_revoke(®, tab.id, again, tabs, 2) == CK_CAP_OK && ck_host_unmap_calls == 2); + CHECK(ck_mmio_revoke(®, tab.id, again, tabs, 2) == CK_CAP_OK && ck_host_unmap_calls == 1); + + /* A BARE ck_cap_revoke (bypassing ck_mmio_revoke) is the known exposure: + * the accessor refuses, but nothing tells the window to give its pages + * back, so they stay mapped. Windows must be revoked through ck_mmio_revoke. */ + ck_host_mmio_reset(); + CHECK(mprotect(win, WIN_BYTES, PROT_READ | PROT_WRITE) == 0); + CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_OK); + CHECK(ck_cap_revoke(tab.id, h, tabs, 2) == CK_CAP_OK); + CHECK(ck_mmio_read(®, &tab, h, 0, 4, &v) == CK_CAP_INVALID); + CHECK(ck_mmio_is_mapped(addr, WIN_BYTES) && ck_host_unmap_calls == 0 && reg.w[reg.next - 1].mapped == 1); + CHECK(ck_mmio_revoke(®, tab.id, h, tabs, 2) == CK_CAP_INVALID); /* too late: the handle is gone */ + CHECK(ck_mmio_is_mapped(addr, WIN_BYTES)); + CHECK(child_died_on_write(child_read_window, win) == 0); /* still mapped */ + ck_host_mmio_reset(); /* A borrowed window (ck_mmio_window_create) revokes the capability only. */ ck_host_mmio_reset(); @@ -1687,6 +1715,7 @@ static void test_mmio_unmap(void) CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_R_READ | CK_R_WRITE, &h) == CK_MMIO_E_RIGHTS); CHECK(ck_mmio_window_open(®, &tab, &f, 2, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_BAR); CHECK(ck_mmio_revoke(NULL, tab.id, h, tabs, 2) == CK_MMIO_E_ARG); + ck_mmio_registry_init(®); /* four windows used: E_FULL would hide the map refusal */ ck_host_try_map_ok = 0; CHECK(ck_mmio_window_open(®, &tab, &f, 0, WIN_BYTES, CK_MMIO_RIGHTS, &h) == CK_MMIO_E_MAP); ck_host_try_map_ok = 1; @@ -1726,7 +1755,7 @@ static void test_mmio_stage_report(void) ck_host_capture_stop(); const char *x = ck_host_capture_text(); CHECK(has(x, "mmio_win: 0000:00:02.0 bar0 addr=0x")); - CHECK(has(x, "size=0x1000 create=0 read(VS)=0 value=0x10400 past-end=-504 revoke=0 after-revoke=-2 unmapped=1 (read-only, report-only)\n")); + CHECK(has(x, "size=0x1000 create=0 read(VS)=0 value=0x10400 past-end=-504 shared-map-refused=1 revoke=0 after-revoke=-2 unmapped=1 (read-only, report-only)\n")); /* Map refused: reported, nothing bound. */ ck_host_try_map_ok = 0; ck_host_capture_start(); From d214a8644817a1f7bdcaf25fad1103f270c6cae0 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Thu, 8 Oct 2026 14:22:53 -0500 Subject: [PATCH 4/4] Crumbs: recompile after B3b review fixes Co-Authored-By: Claude Opus 5.5 --- .crumb | 14 +++++++------- native/.crumb | 14 +++++++------- native/kernel/.crumb | 22 +++++++++++----------- native/kernel/dev/.crumb | 8 ++++---- native/kernel/mm/.crumb | 8 ++++---- native/kernel/svc/.crumb | 14 +++++++------- native/kernel/svc/tests/.crumb | 8 ++++---- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.crumb b/.crumb index 8a1d5223..dbafc4d6 100644 --- a/.crumb +++ b/.crumb @@ -33,8 +33,8 @@ "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "b9a1bf2c3c28708197a62759140771981e1d34ba10cb38c591ccdff1fdb2d51e", - "last_commit": "9696c7d", + "digest": "2508c6a924a31abe677b3d564e8172057fdbb8e4b8c3441ce2ec207f771f6f6e", + "last_commit": "6c9c279", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, @@ -45,15 +45,15 @@ "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:66c2033455f6d4059747d102f8fb3c30033a3256feb34cae6c2203030b4df714", - "compiled_at": "2026-10-08T19:15:06Z", + "children_root": "sha256:c93b50212afee19aa7c152c53fd9329a04047f066f9ef3d18bdcc7eb3919e57e", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:1fcca8b2472b3370a8f82866711392574bd7b56860494b47e97e2129b2a12608", + "digest": "sha256:a90c942c363dd04a1141de44d62ecc2b13027ec64e0e58d992cb142e5e12491f", "evidence_files": 153, "evidence_root": "sha256:29aa8775feb12d9e0e64b41fc1fc48b97e32dc16bf9176562cbe9fe1ea934f00", "files": 3026, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:27d7c98b5b83dc62f4eaa138be89bb0cf961d9cad1b6a133dcd8c246b3b53071" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:50041d54f493aa0ef288579f559dd27646b26b0665e2ba670ee9bee7ccf63aca" }, "owner_lane": "", "provenance": { diff --git a/native/.crumb b/native/.crumb index 5a95fb3b..19b92524 100644 --- a/native/.crumb +++ b/native/.crumb @@ -79,8 +79,8 @@ "purpose": "Directory native/disk. Purpose not yet described by a human." }, { - "digest": "5329c800b73600e87a216d5c1439c10ca7cc6afebe71def6b324a463093d106b", - "last_commit": "9696c7d", + "digest": "0bff4de2cdaf9905ed7745907b1791dbcd8b74346471421b140808c4021a3b86", + "last_commit": "6c9c279", "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:9e99ae3c96e8200d4966cd00e5258778aed19a8703fa62e9bee9f7997d182eb1", - "compiled_at": "2026-10-08T19:15:06Z", + "children_root": "sha256:483e925cab7fe680f03080ef5bae1c6b1fd0b2128f60521f89b214d019ade1a5", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:b9a1bf2c3c28708197a62759140771981e1d34ba10cb38c591ccdff1fdb2d51e", + "digest": "sha256:2508c6a924a31abe677b3d564e8172057fdbb8e4b8c3441ce2ec207f771f6f6e", "evidence_files": 4, "evidence_root": "sha256:e410b845507e00568e15b51a5797af32a97e0e4b8ab4e8487bb7c98e7e0cf335", "files": 453, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:e6c5b0b1bcdfa92ddba1985fbf42020ec6d0434f883aa3b3b7917ba7db6e8ca1" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:f380bef47a92a11422c47452aa0f75a7916cedf8983812a217aea714e109417e" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/.crumb b/native/kernel/.crumb index 7fde730d..c126b142 100644 --- a/native/kernel/.crumb +++ b/native/kernel/.crumb @@ -63,8 +63,8 @@ "purpose": "Directory native/kernel/core. Purpose not yet described by a human." }, { - "digest": "e2191228f95358821035617f00f113aad369327041f737f270b92c6e1ad736fb", - "last_commit": "9696c7d", + "digest": "eb486dd2df49bdb2cfb324751f5d3ef3bfee1d103448c4868d0e66f354f19f57", + "last_commit": "6c9c279", "name": "dev", "purpose": "Directory native/kernel/dev. Purpose not yet described by a human." }, @@ -75,14 +75,14 @@ "purpose": "Directory native/kernel/include. Purpose not yet described by a human." }, { - "digest": "22912c31743025e6c18a4a4f644ad3158d2e3b3c10e01d5b28ff841fe0f7e707", - "last_commit": "9696c7d", + "digest": "8252fab960e4a3bb686f2e864b0d9a0571f43381d5006de2ff6c134c132ef092", + "last_commit": "6c9c279", "name": "mm", "purpose": "Directory native/kernel/mm. Purpose not yet described by a human." }, { - "digest": "8349ed49b642fd5489c8f859f9a67aae899b1b5e7fbae07069fade40dc8fba87", - "last_commit": "9696c7d", + "digest": "0a7eb3875f4a67e425459d8026dfd62df410f4b4b40d052d1f9e9a740ac8688d", + "last_commit": "6c9c279", "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:05416b6052a4fdb866937aeeae0a1878828db6112c2f5eeb92afcb01156ea7c6", - "compiled_at": "2026-10-08T19:15:06Z", + "children_root": "sha256:ecd7fa69cf22a075779debb40e75fe3a7c0dae4f9b6a7e27f5302aacbc14cc05", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:5329c800b73600e87a216d5c1439c10ca7cc6afebe71def6b324a463093d106b", + "digest": "sha256:0bff4de2cdaf9905ed7745907b1791dbcd8b74346471421b140808c4021a3b86", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 289, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:34bed9cfb076fbfa072ded84e6496a3ea73e4d59898b8cd2124994aa840f2bf5" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:948d2b5a45ea4f1ebf616f3b6a9a401105e7955ef9d7739653df46ab7b24f001" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/dev/.crumb b/native/kernel/dev/.crumb index f6fe6ecf..74bb5dc0 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-08T19:15:06Z", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:e2191228f95358821035617f00f113aad369327041f737f270b92c6e1ad736fb", + "digest": "sha256:eb486dd2df49bdb2cfb324751f5d3ef3bfee1d103448c4868d0e66f354f19f57", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 27, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:ed12f5a67c25ce6ff90877044f30aca8ed0727d21b170d520d4d0e745d568de4" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:143b14d79855296492d77e5431b5f5631ffa4ddc64e8e93001b602efd1fde3c2" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/mm/.crumb b/native/kernel/mm/.crumb index bca1f1ee..4b7603a9 100644 --- a/native/kernel/mm/.crumb +++ b/native/kernel/mm/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-08T19:15:06Z", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:22912c31743025e6c18a4a4f644ad3158d2e3b3c10e01d5b28ff841fe0f7e707", + "digest": "sha256:8252fab960e4a3bb686f2e864b0d9a0571f43381d5006de2ff6c134c132ef092", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 7, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:6830af0470b51e0a583f67b37b40e23381ddd4239a46536a556638fa42a62c30" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:e3954d4a28bd18509793abc2e76ab42f73855e9d4c4421a5fddb3c5293eb3683" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/.crumb b/native/kernel/svc/.crumb index 3e61e3d0..3484e323 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": "2059bcd5cb9c44b129f59aa2e02b3136527af0d4fb5681513f8e4711ff061856", - "last_commit": "9696c7d", + "digest": "888b438572314172f18df52857b6944d99eee4da30879a9529dd4fb60b810f34", + "last_commit": "6c9c279", "name": "tests", "purpose": "Directory native/kernel/svc/tests. Purpose not yet described by a human." } ], - "children_root": "sha256:91b86874a76163722da21f2aefb7ad1d4287baf3809a16fded1a1927fb4e4caa", - "compiled_at": "2026-10-08T19:15:06Z", + "children_root": "sha256:94f60cd1c34c5ae4cff0e68696855fcda17faa2e3b8f457890eba212cab8429d", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:8349ed49b642fd5489c8f859f9a67aae899b1b5e7fbae07069fade40dc8fba87", + "digest": "sha256:0a7eb3875f4a67e425459d8026dfd62df410f4b4b40d052d1f9e9a740ac8688d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 35, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:7cb932e4de84619bd9fd38d4f06e6caa95325b63d5cb5bb0047112455902cda1" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:d732de545873e9c9bc878b9e59cafdab9de87402771ec705d17d9a0dfa644fb1" }, "owner_lane": "", "provenance": { diff --git a/native/kernel/svc/tests/.crumb b/native/kernel/svc/tests/.crumb index 1f0a6f52..f93aa900 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-08T19:15:06Z", + "compiled_at": "2026-10-08T19:22:53Z", "compiler": "crumb-compile/1", - "digest": "sha256:2059bcd5cb9c44b129f59aa2e02b3136527af0d4fb5681513f8e4711ff061856", + "digest": "sha256:888b438572314172f18df52857b6944d99eee4da30879a9529dd4fb60b810f34", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 3, - "generated_at_commit": "9696c7d98e324105b6b161626dc82450f1b8ab2b", - "source_tree": "sha256:3dd493c0c389003b5c373ee99e0601275dee20d28b404a80e3eff8bb1b6e4d40" + "generated_at_commit": "6c9c2799bd7e4a2a3f9b4185ae55c15942ed5fdb", + "source_tree": "sha256:9ee97eada964e633dc634752452cd0575794f5643eef5c9f52e4810f58335696" }, "owner_lane": "", "provenance": {