The shortest period and tick drop from 5 ms to 2 ms for programs that
ask for low latency. A buffer is 10 ms or more as before (two 5 ms
periods), and a late tick still hands over up to 15 ms' worth when ticks
are shorter than 5 ms, so a short period tolerates the same host stall.
Programs that leave the period to alsa-lib, plain aplay, OSS without
SETFRAGMENT and requests of 256 frames or more negotiate what they did;
snd_pcm_set_params() with a latency under 20 ms now gets four periods of
2.5 to 3.75 ms (measured on Node, 2026-11-24).
Co-authored-by: Adam Meghji <566793+adammeghji@users.noreply.github.com>
The user page tables gain a level: the PGD now holds PUD tables (P4D
folded), and kwemu's walker and the kernel's uaccess walk read four
levels. TASK_SIZE is 1 << 48, and kwemu faults addresses at or above it.
KW_ABI_VERSION stays 4: no release carries ABI 4 yet.
TASK_SIZE was 1 << 38, the lower half of Sv39 carried over from the
riscv64 guest, so the .NET runtime failed at startup ("GC: Reserving
274877906944 bytes (256 GiB) for the regions range failed"). The kernel
never maps its own memory in the user page tables, so user space can
have every address the three levels index. kwemu now faults addresses
at or above 1 << 39 instead of accepting a sign-extended upper half,
which would alias pgd slots 256-511. KW_ABI_VERSION is 4.
kwtty's sessions get RLIMIT_NICE 40, as pam_limits gives a desktop's audio users: SDL asks for nice -20 for its audio thread, which at nice 0 shares the emulated CPU with the game's busy threads and misses its periods (ALSA underruns, gaps in the sound). kwsnd called snd_pcm_period_elapsed() on every tick, and the core takes a report that falls short of the next period more than half a buffer after the pointer last moved (the first tick after a stall of the machine) for a missed buffer and stops the stream; it now reports when the pointer crosses a period boundary or reaches appl_ptr (the end of a drain, an underrun), and works from its own position between reports.
kw_smp.config sets NR_CPUS to 16 (the wasm SMP patch). A boot on fewer CPUs costs only a few KiB of static per-CPU arrays: the possible CPUs are the ones the host offers. kwtest's spread check starts two threads per CPU up to 32, so it covers more than 8 CPUs.
The bundle (unkernel.wasm) carries a small busybox initramfs that mounts a
distro image labelled kwroot under an overlay root, or starts the base shell
without one. guest/ replaces kernel/guest/: base/, distro/NAME/, shared lib/
and tools/. Images are laid out for their boot by a patched mkfs.erofs and a
recorded boot file list, with a prefetch hint in the image header. Debian
bakes its apt lists and cache, a set of everyday packages and a
command-not-found installer.
binfmt_misc hands a wasm module to kwwasi (kernel/guest/kwwasi.c), which
connects to the host over AF_VSOCK port 1021 and serves the program's
file I/O with its own descriptors, cwd and credentials. The host
(js/core/wasi-exec.ts, serveWasiPrograms(), the CLI's --wasi) compiles
the module once and runs each program in a worker of its own
(js/core/wasi-program.ts) with WASI preview 1, or preview 0 adapted.
Requests cross through a SharedArrayBuffer where one can be used, else
with JSPI and messages. kwwasi sends a module only when the host has not
compiled it for that file, resolves paths against the cwd or / by what
exists, and maps open flags from their asm-generic values to the
guest's.
alpine.sh builds kwwasi and kw-binfmt.sh registers it; no image with
them has been built yet, so test/wasi-binfmt.ts brings kwwasi in through
a mount.
Both checks last tens of milliseconds. When fork placement put both
threads on one CPU (the other one busy for a moment), they could end
before the balancer's first pull, one or two ticks at HZ=100, and the
check failed on its CPU mask: 3 of 35 runs with --smp 2. Each thread
now pins itself to CPU id % online (the main thread restores its mask
afterwards); move: still checks the spreading. 40 runs on 2 and 4 CPUs
pass.
alpine.sh builds kernel/guest/abitest.c (freestanding) beside kwtest and
kwbench, and the release workflow runs it on the UP kernel and on 2 CPUs.
Its SA_RESTART check waits for the parent's alarm with a sleep instead of
a busy loop, which the JIT finished before the alarm.
setup.sh checks xz and sha512sum (the package rebuild's toolchain and
source sums) and reports qemu-aarch64 (optional, zig build test's
comparison). build.sh's disk check also covers alpine-opt.sh, kw-path.sh
and the bwrap shim, which alpine-disk.sh now installs like the initramfs.
The demos' texts called the guest riscv64 (and its CPU a RISC-V
emulator); they now say aarch64. The SQLite demo read the riscv ISA
string from /proc/cpuinfo; it now loads the Features line and groups it
(FP and SIMD, crypto, CRC, LSE atomics). Doom's first run builds in
under a minute, which its README and tile say.
Every visible demo's run.sh was run on the aarch64 guest through the SDK
(2026-11-18): .agents/web.md lists the first-run times. The stand-ins
and qemu-user (x86_64, riscv64, i386, arm) were rechecked too.
Ubuntu 25.10 and later were out of reach on riscv64 (RVA23 with V); the
arm64 baseline is ARMv8.0, so the newest release runs. Pin
ubuntu-base-26.10-base-arm64.tar.gz from its versioned release directory
for kernel/build.sh ubuntu and the page's Ubuntu demo, which was still
fetching the riscv64 24.04.5 tarball. The demo re-extracts a tree whose
bash is not an aarch64 program, and skips the page's download only for
an aarch64 tree.
Checked 2026-11-18: the disk boots to kw-init's shell (glibc 2.44, apt
3.3.3), apt-get update and installs work, systemd 261 boots to running
with no failed units, and the demo's chroot runs apt from the pushed and
from a self-fetched tarball.
kernel/guest/dosbox and dosbox-build/ waited for prebuilt guest packages
that are not coming; the launcher's Windows 3.1 demo (web/src/demos/windows.ts)
existed only for them. fbDOOM and the hidden FreeDOS demo stay; status.md
says where they stand on the aarch64 guest.
A data disk records the architecture of the image that uses it. One
written by another architecture (a riscv64 disk on the aarch64 guest)
loses its installed packages and system changes once, with a notice on
the console and the page; root's home is kept.
The riscv64 interpreter, its JIT emitter, test guests and drivers are
gone; kwemu keeps the ISA-neutral core (MMU, TLBs, code marking, block
cache, JIT core) and the A64 CPU. The arm64 user ABI is one kernel
patch, the last of the series, and the contract between the kernel and
kwemu starts again at KW_ABI_VERSION 2.
Exclusives, LDAR/STLR and the LSE atomics run inline (wasm atomics on
SMP), as do DC ZVA, barriers, loads into XZR and USHL/SSHL. The
code-page filter scans the write TLB only when a mark slot changes
state, and runOps has one copy of the path that leaves a block.
With a host that compiles wasm SIMD (a JIT host capability; the scalar
form remains as the fallback), V registers live in v128 locals and the
integer AdvSIMD ops, AES rounds, PMULL and the SHA families are
translated inline. The image's libcrypto picks its code paths from
HWCAP again, and SHA512 is advertised by default.
busybox, zlib, openssl and apk-tools are rebuilt from pinned aports
commits for kwemu and installed by default. ~/.local/bin is first on
PATH for login shells and kwtty's programs, and the page writes fx,
claude and opencode stand-ins there that install the real program on
first use.
The JIT's ISA-neutral core (regions, thresholds, entry, growth) is
factored out behind ISA hooks, and the A64 emitter sits on it with one
file per op family: ALU, bitfield, multiply and divide kinds with lazy
NZCV, every load and store kind, and every branch kind with side exits.
The decoded-block cache is generic over an ISA's block hooks. A64 code
is decoded once into ops (one instruction, one op) that runOps executes,
with coherence on SMP through a shared code epoch. The tier is tested
against the reference interpreter.
User space is now unmodified aarch64 Linux ELF. kwemu gets an A64
interpreter (src/a64): integer, scalar and vector floating point,
AdvSIMD, exclusives and load-acquire/store-release, the EL0 system
registers, AES, PMULL, SHA1, SHA256 and CRC32. The kernel runs arm64
user space (signal frames, HWCAP, ptrace regsets, the arm64 syscall ABI),
and the guest image, the bundle, kwtest and the page's texts are built
for aarch64.
IP_ADVANCED_ROUTER with IP_MULTIPLE_TABLES gives ip rule and more than one routing table, so tailscaled uses its table 52 instead of falling back to the main table. VETH links network namespaces, DUMMY gives a throwaway interface. Together +64 KB raw, +24 KB gzip and 20 KiB of RAM. kwtest tries all three in a network namespace of its own.
A CPU 0 stopped by another CPU parks in wasm_idle(-1), but its host's
idle wait ends at once while CPU 0's word of pending interrupts is not
0. The stop bit stayed there (taken in cpu_relax(), or raised again by a
CPU whose session ended), so CPU 0 was resumed in a loop of microtasks
that starved its host's event loop, and the exit from the other CPU was
never taken. Inline SMP kernels hung that way in pnpm test:api on 2 CPUs
(3 of 13 runs) once exec started new images on the other CPU, where
poweroff then stopped CPU 0. kw_ipi_stop() now clears the word before
each wait (folded into "wasm: SMP"; the later patches change only in
their hashes).
On SMP a CPU inside a JIT compile (kwemu's gathering and emitting, the
host's new Module and Instance, V8's first-call compile) or inside its
20 ms yield to the host took no interrupt for 0.1 ms to tens of ms, and
every TLB shootdown to it waited that long.
kwemu (ABI 8) marks a compile with jit_busy in struct kw_cpu and does a
flush another CPU asked for through flush_all when it ends, then looks
the block up again; a compile waits while an interrupt is pending. Every
module returns at once for cpu = 0, and the host calls it so inside
kw_host_jit_compile (new flags argument), so V8's lazy compile falls in
the window. The kernel (patch 0037) skips compiling and yielding CPUs as
it skips lazy ones, and yields after taking pending interrupts. The JIT
host no longer nudges the collector on a free.
kwipi churn on 2 CPUs: shootdown p99.9 130 to 13 us, max 20 to 3.9 ms,
calls over 1 ms 194 to 3; throughput and compile counts unchanged
(kwemu.md, Numbers, Compile stalls).
kernel/build.sh smp builds the SMP kernel (kw_defconfig + kw_smp.config,
kwemu with atomics) from the same tree into vendor/build/kernel-smp; all
builds both kernels, and every bundle refresh adds the UP-to-SMP patch
when the SMP kernel is the same build of the tree (KW_SMP=1 requires it,
KW_SMP=0 leaves it out). kernel stays the UP-only quick loop. The patch is
cached in kernel-smp/up.kwpatch. Fixed build stamps (user, host, a build
id hashed from the tree and kwemu sources, the tree's newest commit date)
make kernels and patch reproducible while every other build keeps its own
banner for snapshot matching. Configs are checked against their fragments
after a reconfigure. KW_BUILD, KOUT_SMP, KWEMU_SMP and LINUX_REPO make the
script runnable against another tree and output root.
bundle.mjs --smp refuses two kernels that are not the UP and SMP builds
of one tree (banner, KW_ABI_VERSION, wasm_cpu_start, memory type), with
--smp-optional to warn instead and --smp-patch to reuse a cached patch.
The release workflow builds both kernels, runs kwtest on 2 CPUs and the
kernel patch tests (unexercised).
Off by default: one CPU loads the UP bundle as before. With several the
page loads the SMP bundle (only then) and boots it in worker mode. The
choices are disabled with the reason where the page cannot (no SMP
kernel in the bundle, no cross-origin isolation, no Atomics.waitAsync),
and a failed SMP download or start reloads once on one CPU. Suspend is
hidden with several CPUs; a suspended session is offered to resume on
one CPU.