Document the final x86-exp-isa-fixes evidence: the 79-case kernel matrix and its 20 SMP repeats, the two-CPU API suite, the amd64 Alpine SSH and Python comparisons, and the four lowered-kernel stack-audit configurations.
Clarify that CONFIG_WASM_X86 makes every task in an x86-enabled kernel use a 32 KiB shadow stack, while the audit instrumentation is test-only. Preserve the unresolved affinity, wakeup-placement, host-architecture, browser, and workload limitations; the expanded coverage is not a scheduler-resolution claim.
Enforce VEX reserved-field and compatibility-width rules, correct BMI feature gating, and repair affected SIMD and x87 semantics. Serialize every locked x86 RMW path so an unaligned software update cannot race an overlapping aligned host atomic.
Make CONFIG_WASM_X86 kernels use a 32 KiB shadow stack. Deep reference-SIMD frames could exceed the former 16 KiB allocation and later surface as SLUB or page-cache corruption. Capture x86 page-fault present bits before fault handling changes the mapping, and bump the kwemu contract to ABI 6.
Add physical VEX encoding coverage, locked-atomic and mixed-ISA kernel workloads, a stack-bound instrumentation audit, and a disposable amd64 Alpine userland regression. Extend kernel matrix output to retain stdout separately from host stderr so native fault and RNG comparisons remain exact.
The audit covers x64/i386 differential execution, atomics, UP/SMP and JIT/no-JIT kernel runs, and real amd64 SSH and Python userland checks. It retains the documented limits around scheduler placement, non-x86 hosts, browser coverage, and broader workload matrices.
The kernel runs x86-64 ELF programs as their own tasks on kwemu's x86
front end (CONFIG_WASM_X86, on in kw_defconfig): exec picks the ISA from
e_machine, and an x86 task gets x86-64's syscall table (through the same
pt_regs wrappers, with translations where its ABI differs from arm64's:
open flags, struct stat, clone's argument order, packed epoll events,
uname, arch_prctl, MAP_32BIT, strict seccomp), signal frames, ptrace
regsets and core notes, a vDSO, the vsyscall page, AT_PLATFORM, AT_HWCAP
and /proc/cpuinfo in x86's format; kw.x86isa= masks its features. arm64
tasks are unchanged. The kernel patches are "wasm: run x86-64 user space
beside arm64" after the arch patch and three generic ones (erofs without
vmap on a flat vmalloc, eventpoll's packed events, seccomp's strict
syscalls per task); the separate x86-only series (kernel/patches/linux-x64,
KW_ARCH=x64) is gone, and so is the build switch.
base-test.cpio has x86-64 builds of kwtest and abitest beside arm64's
(kwtest-x86_64, abitest-x86_64; abitest_x64 finds itself under that name
and checks the i386 cross exec only where there is an i386 build), and
test/x64-kernel-audit.mjs runs them on the one kernel. i386 tasks are not
there yet (no CONFIG_COMPAT). The distro images still register x86_64
with binfmt_misc (box64, qemu-x86_64), which comes before the kernel's
ELF loader.
Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
GPL-2.0-or-later, MIT for the JavaScript test driver, with the author's
copyright line, as every other file has.
Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
The x86 front end no longer replaces A64 at build time: libkwemu exports
the A64 ABI and the x86 one (kw_x64_run, kw_x64_set_isa,
kw_x64_isa_supported, kw_x64_complete_entropy, kw_x64_load_segment) on
the same struct kw_cpu, and include/kw_emu.h (ABI 5) describes both
(struct kw_x64_regs; KW_EV_FPE, KW_EV_GPF and KW_EV_ENTROPY for x86).
kw_cpu_init and kw_host_reset set up both.
x86 blocks have their own sets in the block cache (blockSetFor: the top
set bit flipped), so the blocks of the two ISAs at one pc never share a
set and switching between an arm64 and an x86 task needs no flush. The
compile-time is_x64 switches in src/emu become comptime hooks of the
tier that looks a block up (Blocks.x86): the i386 key strip, the A64
stats hooks, and the shared x86 code-page set, which only x86 decodes
mark (A64 keeps IC IVAU); a write-TLB fill reads it only once some x86
code has been marked.
zig build test runs the A64 tests as before; zig build test-x64 runs the
x86 ones (kwemu-x64-harness*, installed with the x86 guests by
install-x64). The object bundles compiler-rt (the x86 front end's
128-bit and x87 arithmetic).
Co-authored-by: JeremySu0818 <xinghong.su0818@gmail.com>
With net.tailscale.exitNode (--tailscale-exit-node, setExitNode() at run
time) a tailnet device that offers 0.0.0.0/0 takes all the guest's other
IPv4 traffic and its DNS in place of the backend; while it is not usable
that traffic is refused. WireGuard's source check is now the longest
prefix across peers. The page lists the tailnet's devices, picks the
exit node from a select box in Settings and the top bar panel, and shows
a set-up node's status and live controls apart from the setup form. The
README gains a section on joining a tailnet.
Microphone: kwsnd gains a capture substream fed by the host (SDK option
soundIn, the page's Microphone setting and ?mic=0, the CLI's
--sound-in-wav and --sound-in).
Camera: kwcam is a V4L2 capture device (/dev/video0) fed by the host: I420,
NV12 and YUYV at 320x240 to 1280x720, and H.264 encoded by the host's
WebCodecs encoder where it has one, with bitrate, GOP and key frame
controls (SDK option camera, the page's Camera setting and ?cam=0, the
CLI's --camera). The base's rc writes the udev database entry of
/dev/video*, so programs that list cameras through libudev find it.
kwva (protocol 5): an encode whose input surface is a camera buffer's
dma-buf names the frame to the host instead of sending its pixels, and
pixels an app writes into an exported surface reach the host (put).
The guest joins a tailnet from Node or the page: ts2021 control over
WebSocket, DERP relays, WireGuard and the packet filter in JS, loaded as
a separate chunk only when the option is used. SDK net option, CLI
--tailscale* flags and a page panel. Relay only; exit nodes, IPv6 and
real peer traffic are not covered yet.
WebGL2 on ANGLE's D3D11 backend (Chrome on Windows) has exactly 12
uniform blocks per stage. vrend keeps one for its VirglBlock, so Mesa's
virgl driver saw 11 uniform buffers, turned uniform buffer objects off
and with them GLES 3.0: the guest got OpenGL ES 2.0.
virglrenderer patch 21 declares the system values as plain uniforms
instead when 24 blocks and bindings fit and the ordinary uniform limits
have room for them, so the guest gets all 12 blocks. test/gl/kwgl-ubo12.c
(vtest-check.sh ubo12) draws with twelve distinct buffers in each stage;
bridge-check.sh --ubo N has the page cap the limits the wasm renderer
sees, which reproduces the D3D11 host on SwiftShader (14 per stage).
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: Niklas Olsson <niklas.olsson@hotmail.co.uk>
Node on Windows reports no execute bits (0o666, or 0o444 for a read-only
file, directories included), so the guest could not enter a directory of
a nodeFs mount (EACCES) nor run a script or binary in it, and its chmod
cannot add the bit. On win32, nodeFs now adds x where r is, as WSL's
drvfs shows them (hostMode); other hosts' bits are unchanged.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: ARNO <arnochen101@gmail.com>
* js: keep host file systems in worker-mode snapshots taken with commit: the owner saves its 9p servers' state while the worker holds the kernel at its consistent point, and fails the commit (the kernel goes on) while a request is unanswered or packets it sent have not reached the kernel (the worker counts those it delivered, snapshot-held's vsockIn); a restore in worker mode serves the mounts on the owner before the boot and passes the connections to keep to the worker's device (vsock.raw.keep)
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Claude <noreply@anthropic.com>
* js: describe host file systems in worker-mode snapshots where the docs still said inline only: VsockSnapshot.mounts, createKernel's restore, MountTable.snapshotBlocker() and the WASI binfmt test's unmount; rewrap the docs
---------
Co-authored-by: vibepodml[bot] <319756436+vibepodml[bot]@users.noreply.github.com>
Co-authored-by: Michael Lohr <michael@lohr.dev>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Pooya Parsa <pooya@pi0.io>
readTexture destroyed its MAP_READ staging buffer only after a
successful map, so a rejected mapAsync (a lost device, a validation
error) leaked it. Destroy it in a finally block, and check both the
failing and the succeeding path in test/vk.test.ts.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: Niklas Olsson <niklas.olsson@hotmail.co.uk>
ConsoleRouter marks user space on a shell prompt that ends in #, $, %
or >, but the Alpine and Debian images' prompt (kw-prompt.sh) ends in
"⇒ ", so a prompt that is user space's first output went unnoticed and
the page fell back to its 300 ms timer. Match ⇒ as well, as
guest/tools/vm-run.ts already does, and test the router on both
prompts without a boot.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: João Lucas de Oliveira Lopes <jlucaso@hotmail.com>
* Enable Docker IPv4 bridge networking in Debian guests
* kernel: leave out the netfilter and bridge defaults Docker does not use
NETFILTER_INGRESS and NETFILTER_EGRESS (hooks for nft's netdev family,
which is not built), NF_CT_PROTO_SCTP and BRIDGE_IGMP_SNOOPING come on
by default with the options the Docker bridge needs; turning them off
saves 78,289 bytes of vmlinux32.wasm (25,917 bytes gzip). Re-export the
series: 0049, 0052 and 0055 carried index lines for the old
kw_defconfig.
* kernel: fix the conntrack hash size at 1024 buckets
Built-in conntrack allocates its hash table and the NAT bysource table,
which takes the same size, at boot also without rules, sized from RAM:
512 KiB each above 1 GiB, as on the page's 2 GiB default. A new generic
patch adds NF_CONNTRACK_HASHSIZE; kw_defconfig sets it to 1024, 8 KiB
per table, with nf_conntrack_max 8192. A 2 GiB guest keeps about 940 KiB
more free after boot.
---------
Co-authored-by: Pooya Parsa <pooya@pi0.io>
* js: hard links on host file systems: Fs gets an optional link(target, path), which the 9p server calls for Tlink of a regular file (it answered EPERM always); nodeFs makes them with fs.link, refusing a source that is not a regular file and undoing a link whose new name is not the file it lstat'ed (Darwin's link(2) follows a symlink, which would name a file outside the directory); MemoryFs still answers EPERM, as do a directory, a symlink and a read-only mount, and a fid restored without its file answers ESTALE; package managers that put a file in place with a link (uv's lock and cache, cargo, pnpm's store) work on a nodeFs mount and on tabc's volumes; tests in 9p.test.ts and api.test.ts (ln in the guest, one inode on the host)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* js: nodeFs runs a hard link alone, so the guest cannot rename, remove or symlink a source or a name into place during it (on Darwin, link(2) follows a symlink); link uses the bigint lstat; a restore leaves a file stale that was open under a removed name even when a hard link still names it (documented); the api hard-link test uses its own directory (below scratch it broke the vm.mount() test's listing) and no longer checks a directory link, which the guest's VFS refuses before 9p; the 9p test removes its directories and checks that a link and a rename do not overlap
* js: nodeFs's hard link checks that every directory on both its paths is a directory, not a symlink (ESTALE), and its lock is per host directory with waits and holds bounded to 10 s (EAGAIN), so a hung rename no longer stalls links and renames of every mount; tests for both, the Tlink test's title says EROFS, the api test unmounts in t.after; Fs.link says the target's type may have changed since the walk
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Pooya Parsa <pooya@pi0.io>
The SDK named the project's Wisp server (DEFAULT_WISP_SERVERS), and the
Node entry sent Origin: http://localhost to pass that server's allow
list (NODE_WISP_HEADERS). The server accepts only the page's origins,
so both are gone: wispBackend() takes the caller's server, and Node
sends handshake headers only when `headers` asks for them. The page
keeps wss://wisp.unkernel.dev:6680/ as its own default (web/src/net.ts).
The live Wisp test takes its server from UNKERNEL_TEST_WISP.
The README and the SDK docs now say what a guest sees over Wisp: no
half-close (a client that waits for the server to see end of file
hangs), placeholder addresses for every name, no connect
acknowledgement. wispBackend() takes a `lookup` resolver for real
addresses, and its fake address table now evicts the least recently
used name instead of wrapping. The default server is
wss://wisp.unkernel.dev:6680/.
The live Wisp test waited for its marker anywhere in the screen, so the
shell's echo of the command satisfied it; it now waits for the marker at
the start of a line.
Refs #44
Sockets: sock_accept, sock_recv, sock_send and sock_shutdown on sockets the program inherited, with socket file types, poll and non-blocking; KWWASI_TCPLISTEN=ADDR:PORT[,...] opens listening TCP sockets at descriptors 4, 5, ... (exit 126 when one is already open); a write to a socket whose peer went away is EPIPE, not SIGPIPE.
Threads: modules that import wasi.thread-spawn and a shared env.memory run on the shared path, each wasm thread with a worker, a channel and a kwwasi connection of its own (a kwwasi pthread sharing the process's descriptors), so a thread blocked on stdin holds up no other; proc_exit or a trap in any thread ends the program; the message path refuses such a module with exit 126.
Clocks: realtime and monotonic follow the guest's (kwwasi sends both readings at START, no request per call); the CPU clocks are the worker's CPU time on Node, the process clock covering every thread through worker.cpuUsage(); unknown clock ids are EINVAL and the resolution is the timer's measured step.
Files: fd_allocate; fd_fdstat_set_flags refuses a sync flag change with ENOTSUP; more Linux errnos mapped; KWWASI_CWD=cwd resolves every path without a leading "/" from the cwd, with no guessing.
A wasm64 module is refused with exit 126, and a sleep on the message path no longer ends a fraction of a millisecond early. The kwwasi protocol is version 3. test/wasi-binfmt.ts runs its guest commands as root and covers the above.
web/src/audio.ts becomes js/web/audio.ts. It creates no AudioContext
before the page has had a gesture, holds the latest 10 s of what plays
until then (a clip that has ended plays whole, a stream joins live), and
has state, onChange, muted, resume() and close() for a page's control.
test/audio.test.ts runs the worklet and the sink without a browser.
Closes#17
virglrenderer patch 0020: on a WebGL host a used sampler unit holds no texture rather than one attached to the draw framebuffer or of another base type than its sampler. unkernel-check.mjs --drm gains step t (test/gpu/feedback.c).
virglrenderer builds with -Dcheck-gl-errors=false and patch 0019: a host GL error is logged and counted (stats.glErrors) and the context goes on; GL_OUT_OF_MEMORY stays fatal.
An SMP kernel imports a shared memory, which the JS API does not show.
boot() assumed an unshared one, allocated it, got a LinkError and
allocated again, shared. It now guesses the sharing from the atomics
feature in the module's target_features section, as moduleIsMemory64()
does for the memory type; the retry stays for a wrong guess (a module
with atomics on an unshared memory).
memoryFallbackMiB only applied to the unshared allocation: where the
shared one then failed, boot was rejected with the LinkError and no
fallback was tried. It now applies to the shared allocation.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
With shared memory, the worker's PCM goes to the owner through a
single-producer, single-consumer SharedArrayBuffer ring (sound-ring.ts)
instead of a message per chunk: the owner drains it into the sink's
onChunk on coalesced "sound-wake" messages, or hands it to the new
SoundSink.onRing for a reader of the sink's own (an AudioWorklet).
State changes are records in the ring as well as messages, numbered
alike, so a sink sees states and PCM in the kernel's order however late
the messages are. The delay the kernel reports is the sink's answer plus
the frames still in the ring, reset with each stream. A full ring drops
the newest PCM, which the owner logs. shared: false keeps the
"sound-chunk" and "sound-queued" messages.
yieldToEventLoop() without setImmediate (browsers) reuses one
MessageChannel, with one message, so one task, per waiting yield.
Idle waits of 1 to 4 ms also wait on a timed Atomics.waitAsync where a
SharedArrayBuffer exists: browsers raise a nested setTimeout below 4 ms
to 4 ms (about 5 ms between wakes in Chrome and Safari workers, against
2.5 ms, measured 2026-11-24).
Co-authored-by: Adam Meghji <566793+adammeghji@users.noreply.github.com>
kwtty login execs the login shell with the signal dispositions it was
started with, unlike login(1). Debian's kw-init, a bash script, starts
it as a background command, which a non-interactive bash runs with
SIGINT and SIGQUIT ignored, so the shell and every program it ran
inherited that, and Ctrl-C could not stop programs such as sleep or
python3 -m http.server.
Reset every signal to its default and unblock them all, as kwtty serve
already does for its sessions, and check the console's SigIgn on every
image. The Alpine image was not affected, since busybox init resets
signals for the programs it starts.