Commit Graph

323 Commits

Author SHA1 Message Date
Pooya Parsa
a41458c687 js: skip the rest of a kernel compile from bytes once its signal aborts 2026-12-05 00:10:06 +00:00
Kotaro Chikuba
f4a0b72cf0 kwemu: keep same-page JIT regions when chaining (#193) 2026-12-05 01:04:04 +01:00
Kotaro Chikuba
3f71ede86f js: use Wasm SIMD to sum packet checksums (#189) 2026-12-05 00:50:12 +01:00
Kotaro Chikuba
c554197790 js: convert XRGB8888 framebuffer pixels with Wasm SIMD (#188)
* js: convert XRGB8888 framebuffer pixels with Wasm SIMD

* js: keep the pixel SIMD scratch buffer off address 0

* js: move the frame conversion test to test/display.test.ts and check the embedded module

The test needs no kernel. It now also covers readRGBA()'s packed and padded paths and a shared source, and rebuilds pixel-simd.zig where zig 0.16 is on PATH to compare it with the embedded bytes.

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-05 00:49:32 +01:00
Kotaro Chikuba
f3fffb594f js: speed up SMP kernel reconstruction from the bundle (#185)
* js: apply kernel patch runs without expanding the diff buffer

* js: skip WebAssembly addresses outside the remapping table

* js: write remapped Wasm into one output buffer
2026-12-05 00:49:17 +01:00
Kotaro Chikuba
ba600f0d36 js: use a Zig SIMD scan for zero-filled blocks (#187)
* js: scan zero-filled blocks with Zig WebAssembly SIMD

Use an explicit vector scan for sparse disk blocks and snapshots without a chunk map. Preserve the JavaScript path for short scans and hosts without SIMD.

* js: refuse a zero-scan span outside the view

* js: keep the zero scan's scratch off address 0 and test the embedded module against zero-scan.zig

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-05 00:48:10 +01:00
Kotaro Chikuba
3c128a9d4e js: overlap worker kernel and initramfs preparation (#186) 2026-12-05 00:43:06 +01:00
Ramon
a714775385 a64/jit: translate LD2-4/ST2-4 (multiple structures) inline (#35)
* a64/jit: translate LD2-4/ST2-4 (multiple structures) inline

* a64/jit: run the LD2-4/ST2-4 unit test from a warm data TLB

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-05 00:21:37 +01:00
Andrey Sukharev
7a5dacc678 a64/jit: use Wasm wide multiply for UMULH and SMULH (#97)
* a64: use Wasm wide multiply for UMULH and SMULH

* a64/jit: document the wide multiply probe and its capability bit

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-04 23:49:59 +01:00
Yubinghan
9d9327abf5 js: tell the JIT the memory is shared where the page hides SharedArrayBuffer (#173)
* js: tell the JIT the memory is shared where the page hides SharedArrayBuffer

A page that is not cross-origin isolated has no SharedArrayBuffer global,
yet an SMP kernel there (cpus > 1, run on one CPU) has a shared memory.
caps() left out CAP_SHARED, so every compiled module failed to
instantiate ("mismatch in shared state of memory") and the guest ran on
the interpreter only. Ask !(buffer instanceof ArrayBuffer), as compile()
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* js: test for a shared memory in virtqueues without the SharedArrayBuffer global, as the JIT does

* ci: run test:jit with the SDK unit tests

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-04 23:19:05 +01:00
Pooya Parsa
7fc2d4e7fa guest: boot with address-space randomisation off; kw.aslr=1 (SDK aslr, CLI --aslr) turns it on 2026-12-04 21:23:01 +01:00
Pooya Parsa
55fcda9c38 docs: update the kwemu performance notes: where transfer and front-end cost go, rejected designs, the larger data TLB 2026-12-04 21:06:59 +01:00
Pooya Parsa
938dd8624b a64: fuzz the scalar AdvSIMD SCVTF/UCVTF and FCVTZS/FCVTZU forms
The block fuzz now emits them (S and D, signed and unsigned), and the
JIT's scalar FP test generator draws the W/X forms of FCVTZS/FCVTZU
again: its picks of them had all gone to the V-register forms.
2026-12-04 21:06:59 +01:00
Pooya Parsa
8513eb80f4 a64/jit: run SCVTF/UCVTF and FCVTZS/FCVTZU with the integer in a V register inline
The scalar AdvSIMD forms (scvtf d0, d0; fcvtzs d0, d0) took the generic
interpreter call from compiled code: 1.17M calls per run of a Perl
kernel. They now share the W/X forms' fast paths (perl-k6 about 6%
faster, 2026-12-04).
2026-12-04 21:06:59 +01:00
Pooya Parsa
8db69bcd64 kwemu: grow the data TLBs to 16384 entries, with a fill log and a reverse map from host page to write-TLB entries
markCode scanned the whole write TLB each time a page got its first
decoded chunk, about 40K times per npm --version run (again after every
nursery reset), so a larger TLB made npm 18% slower. The reverse map
finds a page's write entries through one short chain, so markCode and
resetNursery no longer depend on the TLB size; a log of the last 256
fills lets flushAll clear only those. The 544.5 KiB this takes per CPU
comes out of the nursery (35K of 320K ops): KW_CPU_SIZE and the ABI stay.

Unit tests check the map and the code_flag invariant after every fill,
flush and mark change (rmapCheck), and two new tests cover write entries
cached before a page gains code, on one CPU and on two.
2026-12-04 21:06:59 +01:00
詹詠翔
b5d17268ce js: compute the package root so that Turbopack does not take ".." for an asset (#176) 2026-12-03 13:11:31 +01:00
Stefano De Rossi
7557559fcc README: name WebVM / CheerpX in the syscall emulators row (#179) 2026-12-03 13:06:14 +01:00
Andrey Sukharev
7c64ce4332 guest: Use Claude Code’s fullscreen interface in the terminal (#165)
* guest: Enable Claude Code fullscreen by default in the terminal

* guest: Set Claude Code fullscreen in the install shim
2026-12-03 11:36:54 +01:00
Pooya Parsa
32d1e791f3 web: fix the iOS New Tab button and make the phone themes' home bars easier to use
iOS: the + in a window's navigation bar now takes its presses (its
wrapper's larger target covered it), and in a home screen app the status
bar's controls no longer reach below its 24 pt row over the navigation
bar. iOS and Android: the home bar's strip is taller, its target nearly
the strip's width and only 10 px over the window, with no text selection
or callout on a long press; a swipe up the browser cancels after it went
far enough still goes home or to the switcher. Android: a folder's small
icons fill their square cells instead of drawing as flat ovals.
2026-12-03 09:10:03 +00:00
Pooya Parsa
2a585ee1b1 docs: add a Wayland Windows page to the SDK docs 2026-12-02 21:37:31 +00:00
Pooya Parsa
b033dc7b50 web: add desktop themes: KDE Plasma, GNOME, iOS, Android and Windows 2000
A theme is a stylesheet under :root[data-desktop] and React parts in place of the top bar, the Dock, the launcher and a window's title bar (web/src/themes); it loads when first shown and switches without a reload. Without a choice the device picks it: iOS, Android, else KDE.

Also: the desktop's headless core (window manager, commands, apps, pins) moves to web/src/core with its tests; terminal tabs are drawn by the theme's title bar; Settings and System get a sidebar drawer in narrow windows; the first paint is a minimal splash; the console's auto-hide is removed.
v0.3.0-261202-b033dc7
2026-12-02 20:27:00 +00:00
pi0x
9772730203 js: warn once when a distro image without the account user runs programs as root (#158)
exec() and spawn() run programs as the account "user" by default, and kwtty falls back to root where /etc/passwd has no such account. On an image of your own that lacks it, programs ran as root without any sign of it.

For a kernel that boots a distro image, the first program that names no user now asks kwtty for "user" by name (not critical, so a guest from before the USER option runs it as root as before). When kwtty answers "no user user", the SDK logs one warning through createKernel's log and opens the same session with the default, so the account used does not change. Later programs send the default as before. The base shell, which has root only, gets no check and no warning.

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 21:03:01 +01:00
pi0x
c17c6b7b34 js: give PtyError the stage and errno name of a program that cannot start (#157)
exec() and spawn() reject with PtyError EREMOTE and only the guest's
message when a program cannot start, so a caller that must map this to a
shell exit status or tell a missing program from a missing directory has to
parse the text. PtyError now has stage ("exec", "chdir" or "user") and
guestCode (the errno name, e.g. "ENOENT", "EACCES", "ENOTDIR"),
derived on the host from kwtty's fixed message formats, with the strerror
texts of musl and glibc. No protocol change: it works with every existing
image and snapshot. A message that does not match, or an unknown errno
text, leaves the fields undefined; code and message are unchanged.

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 15:15:22 +01:00
pi0x
55b582b887 js: report the CPUs the guest runs on, and why it got fewer than asked (#159)
stats().cpus said what createKernel() was asked for, not what the guest
got: cpus above the kernel's NR_CPUS (16) left the guest on 16 while
stats().cpus and snapshots said more. A kernel without SMP, or a thread
that cannot start CPU threads, booted on one CPU with only a log line.

The host now offers the SMP kernel at most MAX_CPUS (exported), so
stats().cpus and the snapshot's count are what the guest runs on;
snapshotCpuMismatch() compares counts as the kernel takes them. When the
guest gets fewer CPUs than asked, stats().cpuLimit is { requested, reason }
("max", "module-not-smp", "kernel-not-smp", "not-isolated",
"not-worker", "unsupported"), in worker mode too. createKernel() still
boots, and the log line stays.

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 15:12:07 +01:00
pi0x
2878879c4e js: end the idle WASI program workers when the kernel exits (#160)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 15:09:59 +01:00
pi0x
595d90f8a6 js: reject detachable on pipes in spawn() and exec() (#156)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 15:08:42 +01:00
pi0x
eb6f2a2495 test: read the region members counter from its slot in work-bench (Ax core+7, not +8) (#153)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 13:18:35 +01:00
Joshua Scarsbrook
d43fc9b220 a64/jit: accelerate floating-point reductions and vector arithmetic (#151) 2026-12-02 13:02:13 +01:00
Coenraad Loubser
ac0554ad68 kwsparse: Reject unrepresentable disk and block sizes (#91) 2026-12-02 13:00:38 +01:00
Coenraad Loubser
271c8af4a3 disk: Complete short transfers when reading and writing disk images (#90) 2026-12-02 12:59:36 +01:00
minchenlee
bba44ebc06 kernel: limit FUSE readdir replies to one page with a flat vmalloc (#127) 2026-12-02 12:58:35 +01:00
hELLO,tHIS'S jOSHUA
303320394b vk: skip readback for storage buffers shaders only read (#122) 2026-12-02 12:57:32 +01:00
Coenraad Loubser
a023438bba block: Preserve discards during an in-flight save (#86) 2026-12-02 12:55:52 +01:00
pi0x
b6f98d9e2b js: add an SNI/Host sniffing backend with a policy callback (#152) 2026-12-02 12:51:13 +01:00
pi0x
dd108fa943 kwemu: chain compiled modules in desktop Safari, where it measures 10-16% faster on Perl, and add /jit-probe.html, which times guest work with chaining off and on in a browser (KW_JIT_TAIL=1 or 0 answers instead of the engine test) (#148) 2026-12-02 10:09:14 +01:00
pi0x
bdcc90c51f js: start the inlined Node workers from data: URLs (#143) 2026-12-02 09:51:17 +01:00
pi0x
8580d4e79a docs: document SDK defaults and limits for embedders (#145) 2026-12-02 09:48:01 +01:00
pi0x
903ac21686 test: make the SDK API suite pass reliably (#147)
* test: expect the JIT host's fused multiply-add, tail call and chaining caps, and export jitTail() beside jitSimd() and jitFma()

The JIT rework added caps bits 6 (fused relaxed multiply-adds), 7 (cheap
tail calls), 8 (module format v2, KW_JIT_V2=1) and 9 (chaining, unless
KW_JIT_CHAIN=0), but the JitHost test still expected bits 0-5 only, so it
failed on every run (755, not 51, on Node 24 on x86-64). The test now
derives the expected caps from the same probes and variables.

* test: expect shm views in place in worker mode with an SMP kernel

With UNKERNEL_TEST_CPUS=2 the worker shares the kernel's memory with this
thread (shm.ts, In place), so views() works there instead of failing with
EOPNOTSUPP; the shm test failed on every 2-CPU run. It now checks the
views on the shared memory there, and the EOPNOTSUPP on the UP kernel.

* test: find the forced H.264 key frame by the source's request, not by a chunk window

The camera H.264 test wanted the key frame kwcap forces after the 16th
chunk among chunks 16 to 22. The source makes it next, but the chunks it
made before reach the guest first: the host's queue and the guest's
filled buffers, as many as the guest lags behind the source's clock. With
the full suite at once the inline kernel's timer ran late, the pattern
source caught up several frames at a time, and the forced key frame came
later (or on the GOP's own key frame at 24). The test now records the
chunk the source makes after each key frame request, checks that the
guest gets that chunk as a key frame, with only the GOP's key frames
before it and the GOP counting from it, and streams 60 chunks, enough for
the queue's 32 and the guest's buffers.

* test: judge shm reads through the ring by the reads during which this thread was free

The ring's answer comes as a message to this thread, which also runs the
suite's inline kernels. The check skipped itself when this thread's timer
delay was high, but it measured that delay only after the 25 reads, so a
busy spell during the reads failed it (median 32.5 ms with a delay of
1.4 ms measured afterwards). Each read now records this thread's longest
timer delay while it runs, and the median is asserted over the reads that
saw no delay of 3 ms or more (when there are at least 3 of them).

* test: run worker-mode capture from a read() source after the concurrent suite

In worker mode the sound in and camera tests' read() sources answer on this
thread, and the worker records silence or a black frame wherever the
answer comes late. With the whole suite at once this thread runs every
inline kernel, and the source fell 200 ms or more behind at the start of a
stream: kwrec got 2357 and 2854 of its 3000 samples (worker; worker with
messages), the camera 3 of 8 pictures (worker with messages). Those four
tests now run in a suite of their own after the concurrent one, alongside
each other only, with their assertions unchanged; the inline ones and the
onRing ones (a producer on a thread of its own) stay in the concurrent
suite.

* test: read a guest's background counter again when its file is empty

The snapshot and session tests' guests count in the background with
echo $i > FILE, which truncates the file before it writes, so a cat in
between reads nothing, 0, and fails a "counts on" check (or weakens the
next one). The host now reads the counter again while its file is empty,
at most 50 times. A rename per write in the guest would also do, but at a
fork per write it loads the guest (and, inline, this thread) twice as
much.

* test: let a restored recording end before boot() returns in the snapshot capture test

A restore hides the stopped time from the guest's clock, so the restored
guest has what was left of its 3 s recording. Where the snapshot landed
late in it (a busy host), kwrec's own stop and close came before boot()
returned, and the test, which wanted nothing after the replayed open,
prepare and start, failed. It now asserts the replay first, then nothing
or the guest's stop and close, with capturing to match.

* test: derive the SMP kernel once for UNKERNEL_TEST_CPUS runs instead of at every boot

Given the bundle and more than one CPU, createKernel() derives the SMP
kernel from it on the calling thread at every boot (about 0.2 s of
patching), and in a 2-CPU run every boot() did that. The suite's boots at
once held this thread, which runs the inline kernels and the device
sources, for over 3 s: glimmer's 3 s of sound took 6.3 to 6.8 s, the PCM
ring from the worker CPU (2.97 s of that stream) overflowed and dropped
346 to 890 frames glimmer had written without an underrun, and the H.264
source made too few chunks during the guest's stall to overflow the
queue. With UNKERNEL_TEST_CPUS > 1, boot() now boots the SMP kernel that
compileTestKernel() derives once wherever it runs on more than one CPU;
sharedKernel() still boots the bundle.

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-02 09:41:39 +01:00
pi0x
f06079e947 js: unwind a stopped kernel's stacks so that it can be collected (#141) 2026-12-01 23:25:57 +01:00
pi0x
8360c5d82b js: use a cached distro image without the network or a full rehash, and fall back to a temporary cache directory (#142)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-01 23:25:32 +01:00
pi0x
c742c69de7 js: make createKernel()'s signal abort the boot only, not the running kernel (#140)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-12-01 23:21:49 +01:00
pi0x
4d2ccde92c docs: allow several kernels per thread and give the Debian image's real size (#138) 2026-12-01 23:19:46 +01:00
pi0x
cd674065cf js: read file: URLs and paths in the Node entry's loadKernelModule() and loadBytes() (#139) 2026-12-01 23:18:09 +01:00
pi0x
07f198bd1f kwemu: JIT rework (chaining, exact code marks, fused multiply-add) (#135) 2026-12-01 21:20:37 +01:00
Harrison @ Movenis
ad2302694d web: keep the Transfers button visible while idle (#118)
Co-authored-by: harrisonk0 <238985628+harrisonk0@users.noreply.github.com>
2026-11-30 23:46:14 +01:00
Pooya Parsa
3ef745b6d1 web: add a Kubernetes app: k3s in the Debian guest, running a single-node cluster with an nginx sample or joining one; apps can need a number of CPUs (the app needs 2: the SMP kernel) v0.3.0-261130-3ef745b 2026-11-30 14:25:37 +01:00
Pooya Parsa
bf46d833d0 kernel: give the Kubernetes options a bpf(2) for device filters only
BPF_SYSCALL with CGROUP_BPF was 70% of what the options cost, for runc's device filter. A new generic patch, BPF_CGDEV_ONLY, loads and attaches cgroup device programs only and runs them on the interpreter, with a verifier of its own: the SMP kernel grows 128 KB gzip instead of 460 KB. Checked with a runc container on cgroup v2.
2026-11-30 14:25:37 +01:00
Pooya Parsa
ed876d7f79 kernel: make kwdiff take a far match only when it is clearly longer, so the SMP patch compresses better
A match more than 4 KiB away from where the current one continues now has to be 32 bytes longer instead of 8. New code otherwise became tens of thousands of short copies from unrelated places, each a seek a compressor cannot predict. The SMP patch with the Kubernetes options goes from 1.51 to 1.30 MB gzip; the format, the loader and the time to make it are unchanged.
2026-11-30 14:25:37 +01:00
Pooya Parsa
708a18ef58 kernel: enable what a Kubernetes node needs in the SMP kernel
The cgroup v2 memory, CPU and cpuset controllers with CPU limits, bpf(2)
with cgroup BPF, keys, bridge netfilter, the iptables pieces kube-proxy and
flannel use, nft ct and masq, the conntrack table in procfs, and VXLAN, in
kw_smp.config only: k3s needs cpuset, which needs SMP, so the UP kernel
stays as it is.

Co-authored-by: Greg Bell <code@gregbell.ca>
2026-11-30 14:25:37 +01:00
pi0x
6234100fc9 docs: fill the SDK documentation gaps and refresh the README's features (#110)
* docs: document snapshots, host commands, Tailscale, VA-API, fetchRoutes, UDP, the microphone and the camera in the SDK docs and README, and list the newer devices and uses in the README's introduction

* docs: split the Display page into Display and Input, and Sound and Camera

---------

Co-authored-by: Pooya Parsa <pooya@pi0.io>
2026-11-30 11:23:00 +01:00