aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
GitHub aien-dev/aienux#275 (code only)
Apply it
git checkout -b patch-dceb9c3f24a12ec1 61bd76a6be67de58021a4b96606d57f50c5d03a2 curl -fsSL https://interplane.io/drakestapleton/aienux/patches/dceb9c3f24a12ec1.patch | git am
Provenance
github-import 1
aien-dev/aienux
275
096f1cd21e35833414b81afb8833660bbc0eae27
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":275,"url":"https://github.com/aien-dev/aienux/pull/275","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:06Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 32247b0d..663d818c 100644 --- a/.crumb +++ b/.crumb @@ -21,39 +21,39 @@ "generated": { "children": [ { - "digest": "01210bd71bb028e239a12e613785e4a897a1dbf78c92ea2aa756a4e5e1aee1b5", - "last_commit": "fbbfc9c", + "digest": "ebc8d5c8bacd11bfcc717785e74cb4de592e0aab8f41a6f81f75f4cda158dc21", + "last_commit": "7acfbcf", "name": "crates", "purpose": "Directory crates. Purpose not yet described by a human." }, { "digest": "bd7eb99f15a1f1a63969943ca3c980811ed110709dc9b3861f5aad6fd25fa84c", - "last_commit": "f23da68", + "last_commit": "61bd76a", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { "digest": "cd19d20499065a773a3cb624c5e3cb1b5ed3ddf4e4ecec2e433c0e39ac5c1088", - "last_commit": "f23da68", + "last_commit": "61bd76a", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, { "digest": "dbd714ff3e2649a9d09a4d9d6d2b188b1c054e89a0524b9af1153832a8017355", - "last_commit": "ecd12c6", + "last_commit": "61bd76a", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:2804306afa73df8ef1d07958ce103abaea28a4a6a5812177f5601e69bdfa7029", - "compiled_at": "2026-10-06T19:43:14Z", + "children_root": "sha256:a8e3278cd0ec3ee7cc459bd7ec6de012d7ecf2bd069d662eb3b0a636f82b95a7", + "compiled_at": "2026-10-07T01:17:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:73415459a0b259a8b947f9aebe22f6c9a2e90280992d893e2dd969b91b177f69", + "digest": "sha256:bc5459023162d6704fe65d95e5cf52148c2690bac645fa538da105aa41164ae1", "evidence_files": 153, "evidence_root": "sha256:29aa8775feb12d9e0e64b41fc1fc48b97e32dc16bf9176562cbe9fe1ea934f00", - "files": 2881, - "generated_at_commit": "71bae34a73d2aaf85f4879f26a2f1b7c5ef396c4", - "source_tree": "sha256:ab58f9a8693161163a71f959f3d0245a961872721c6fbdccd0b87d577ef80376" + "files": 2882, + "generated_at_commit": "7acfbcf2acfbc8c505a60d0e20cebf4d5f963c00", + "source_tree": "sha256:b7a3f5eda4406e5ab78c40e9223e20046253708659105c291623090026c75dda" }, "owner_lane": "", "provenance": { diff --git a/crates/.crumb b/crates/.crumb index 4b025ecb..b65d0d54 100644 --- a/crates/.crumb +++ b/crates/.crumb @@ -95,8 +95,8 @@ "purpose": "Directory crates/aienos-artifact-tool. Purpose not yet described by a human." }, { - "digest": "2baed8a0de57e0bf8b2dca0ee81b3a54e6eba14af1c3003a3602f9dab68f9c16", - "last_commit": "761e63d", + "digest": "41559b6187a30de12fdf5ee7e749662f3576d60e4bf0e0753284c05aa64baec0", + "last_commit": "7acfbcf", "name": "aienos-boot", "purpose": "Directory crates/aienos-boot. Purpose not yet described by a human." }, @@ -138,7 +138,7 @@ }, { "digest": "300f31a0ce9337241a05c7572903142461ffe712a01b65a10fa5b4908e22b898", - "last_commit": "3e283fa", + "last_commit": "fbbfc9c", "name": "aienos-kernel", "purpose": "Directory crates/aienos-kernel. Purpose not yet described by a human." }, @@ -149,15 +149,15 @@ "purpose": "Directory crates/aienos-store-tool. Purpose not yet described by a human." } ], - "children_root": "sha256:80afd5760409e57ea115f520e749fd1aebf1ae9081c3cac51b74f5040e4bd457", - "compiled_at": "2026-10-04T20:01:05Z", + "children_root": "sha256:1334b8befdc1f899fa2171246a25c0dcb502d6ea6bb724f007e22b884f6040c3", + "compiled_at": "2026-10-07T01:17:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:01210bd71bb028e239a12e613785e4a897a1dbf78c92ea2aa756a4e5e1aee1b5", + "digest": "sha256:ebc8d5c8bacd11bfcc717785e74cb4de592e0aab8f41a6f81f75f4cda158dc21", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 230, - "generated_at_commit": "79456d09c1e2aaf0c84f853f0e3d76b864475bb7", - "source_tree": "sha256:11eb0a5001e101305105883fff52a6f4a16fd5f6a8961f6e2a46af1d9a838eeb" + "files": 231, + "generated_at_commit": "7acfbcf2acfbc8c505a60d0e20cebf4d5f963c00", + "source_tree": "sha256:dd6b4a3aade84dd3a50986ad97114e1338b5e3b820119356f4ffbb599e099e0b" }, "owner_lane": "", "provenance": { diff --git a/crates/aienos-boot/.crumb b/crates/aienos-boot/.crumb index ad57ebf2..99a86266 100644 --- a/crates/aienos-boot/.crumb +++ b/crates/aienos-boot/.crumb @@ -13,21 +13,21 @@ "generated": { "children": [ { - "digest": "ffebb91d711dc4911ad9ca79f85a8a10daa308384a3e90e9ac1df7e850c0dab0", - "last_commit": "761e63d", + "digest": "4789715d6543656d583f0d02f332d316551419889580740df2fe1b0448da7c7a", + "last_commit": "7acfbcf", "name": "src", "purpose": "Directory crates/aienos-boot/src. Purpose not yet described by a human." } ], - "children_root": "sha256:d52cafd997d738e954e4c117467a1ea9da2617e7254752eba79008e29b6f872a", - "compiled_at": "2026-10-04T13:47:18Z", + "children_root": "sha256:8c0204d0fb3e2b20aca2f701cb6dda4bbadf8f2fbcd438535cb1d1092dd96278", + "compiled_at": "2026-10-07T01:17:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:2baed8a0de57e0bf8b2dca0ee81b3a54e6eba14af1c3003a3602f9dab68f9c16", + "digest": "sha256:41559b6187a30de12fdf5ee7e749662f3576d60e4bf0e0753284c05aa64baec0", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 8, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:f5f1e254a30514f74851b06d40f83e4501ebec45a1d9a26b4b8933f117b9a7c9" + "files": 9, + "generated_at_commit": "7acfbcf2acfbc8c505a60d0e20cebf4d5f963c00", + "source_tree": "sha256:1d4d7212af5f4f030a40c8235fb130cef357fcbc89cbf0008c905a2581ce88aa" }, "owner_lane": "", "provenance": { diff --git a/crates/aienos-boot/src/.crumb b/crates/aienos-boot/src/.crumb index 44c13502..fa1009af 100644 --- a/crates/aienos-boot/src/.crumb +++ b/crates/aienos-boot/src/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T13:47:18Z", + "compiled_at": "2026-10-07T01:17:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:ffebb91d711dc4911ad9ca79f85a8a10daa308384a3e90e9ac1df7e850c0dab0", + "digest": "sha256:4789715d6543656d583f0d02f332d316551419889580740df2fe1b0448da7c7a", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 7, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:03c42e245e8545c8ad5586be9e6d18b3c83752555bf685e2a0289750c25dd14b" + "files": 8, + "generated_at_commit": "7acfbcf2acfbc8c505a60d0e20cebf4d5f963c00", + "source_tree": "sha256:9a83a72aecac6d09708eeb569bcae69321d2558558c31062cf0d8421400b89ab" }, "owner_lane": "", "provenance": { diff --git a/crates/aienos-boot/src/handoff.rs b/crates/aienos-boot/src/handoff.rs index 9849ac11..1a472f43 100644 --- a/crates/aienos-boot/src/handoff.rs +++ b/crates/aienos-boot/src/handoff.rs @@ -21,6 +21,8 @@ //! /boot/efi/EFI/AIENOS/BOOTREPORT.TXT //! /sys/firmware/efi/efivars/AienosBootReportV1-a1e05b0e-7c3d-4f51-9b6a-2d8e4c1f0a37 +// Links the `wcslen` definition (see wcslen.rs); rustc 1.99 emits calls to it. +extern crate aienos_boot as _; extern crate alloc; use aienos_kernel::acpi; diff --git a/crates/aienos-boot/src/lib.rs b/crates/aienos-boot/src/lib.rs index 89309f18..a2608e51 100644 --- a/crates/aienos-boot/src/lib.rs +++ b/crates/aienos-boot/src/lib.rs @@ -34,3 +34,7 @@ compile_error!( /// Whether this build carries the unsafe, QEMU-only NVMe DMA bypass. pub const UNSAFE_NVME_DMA_BYPASS: bool = cfg!(feature = "unsafe-debug-nvme-dma-without-smmu"); + +// `wcslen` for the UEFI target, which has no C library (rustc 1.99 / LLVM 23 +// emits calls to it from the `uefi` crate). See wcslen.rs. +pub mod wcslen; diff --git a/crates/aienos-boot/src/rollback_mock.rs b/crates/aienos-boot/src/rollback_mock.rs index ebfd2237..a0d67016 100644 --- a/crates/aienos-boot/src/rollback_mock.rs +++ b/crates/aienos-boot/src/rollback_mock.rs @@ -1,6 +1,9 @@ #![no_std] #![no_main] +// Links the `wcslen` definition (see wcslen.rs); rustc 1.99 emits calls to it. +extern crate aienos_boot as _; + extern crate alloc; use alloc::vec::Vec; diff --git a/crates/aienos-boot/src/wcslen.rs b/crates/aienos-boot/src/wcslen.rs new file mode 100644 index 00000000..c259c280 --- /dev/null +++ b/crates/aienos-boot/src/wcslen.rs @@ -0,0 +1,64 @@ +//! `wcslen` for the UEFI target. +//! +//! Since rustc 1.99 (LLVM 23) the loop-idiom pass turns any "count 16-bit +//! units until zero" loop into a call to `wcslen`, and the UEFI targets ship +//! no C library to provide it (rust-lang/rust#160827, #163614). The `uefi` +//! crate has such loops (`proto::shell`, `proto::driver::component_name`), +//! so every image that links it fails with `undefined symbol: wcslen`. +//! +//! This defines the symbol for the UEFI target only. The counting loop uses +//! volatile reads so LLVM cannot turn the body of `wcslen` back into a call +//! to itself. + +/// Number of `u16` units before the first zero unit. +/// +/// # Safety +/// `s` must point to a readable, zero-terminated run of `u16`. +pub unsafe fn wide_len(s: *const u16) -> usize { + let mut n = 0usize; + // SAFETY: the caller guarantees the run is readable up to its terminator. + while unsafe { core::ptr::read_volatile(s.add(n)) } != 0 { + n += 1; + } + n +} + +/// C `wcslen` for a 16-bit `wchar_t` (the UEFI ABI). Only for target_os = "uefi". +/// +/// # Safety +/// `s` must point to a readable, zero-terminated run of `u16`. +#[cfg(target_os = "uefi")] +#[no_mangle] +pub unsafe extern "C" fn wcslen(s: *const u16) -> usize { + // SAFETY: same contract as this function's. + unsafe { wide_len(s) } +} + +#[cfg(test)] +mod tests { + use super::wide_len; + + fn len(v: &[u16]) -> usize { + unsafe { wide_len(v.as_ptr()) } + } + + #[test] + fn empty_string_is_zero() { + assert_eq!(len(&[0]), 0); + } + + #[test] + fn counts_units_before_first_zero() { + assert_eq!(len(&[b'a' as u16, b'b' as u16, b'c' as u16, 0]), 3); + } + + #[test] + fn stops_at_first_zero_not_slice_end() { + assert_eq!(len(&[1, 2, 0, 3, 4, 0]), 2); + } + + #[test] + fn high_unit_values_are_not_terminators() { + assert_eq!(len(&[0xFFFF, 0x8000, 0x0100, 0xD800, 0]), 4); + } +}