Commit Graph

233 Commits

Author SHA1 Message Date
Pooya Parsa
366dbeb6fe js: fall back to __heap_base when the kernel has no _end
The initrd size check reads the export _end, which Linux's linker script
defines. A kernel linked without a script exports only wasm-ld's
__heap_base, and booting it with an initrd failed with "missing export
_end". Upstream's kernels export _end and keep using it.

Co-authored-by: Tsiry Sandratraina <tsiry.sndr@rocksky.app>
2026-11-28 20:07:47 +00:00
Pooya Parsa
c4a2fb0fa9 vk: make the translator's output depend on the input alone
std's HashMap seeds each map differently (on wasm32 from a count of the
maps made before), and several passes emit ids and declarations in map
order, so the same module translated twice in one instance could give
different WGSL (small.comp: declaration order and names). The passes'
maps and sets now have a fixed seed (crate::HashMap and HashSet), the
8/16-bit storage pass also emits its groups and typed constants sorted,
and vk/naga/test/run.ts translates every test shader a second time and
requires the same output.
2026-11-28 19:34:29 +00:00
Pooya Parsa
d4f31f8494 web: add a FilmCraft app to the launcher's Media folder: the video editor's aarch64 AppImage, fetched by the page from the mirror's copy of the GitHub release and extracted once, on guest Vulkan 2026-11-28 19:23:52 +00:00
Pooya Parsa
990ab2e2cd vk: translate the integer GLSL.std.450 ops and the bool vector logical ops naga's own SPIR-V writer emits (#57)
wgpu apps on guest Vulkan failed at pipeline creation on two spv-in gaps,
both in SPIR-V that naga's writer produces:

- GLSL.std.450 integer min, max, clamp, abs, sign and MSB take their
  signedness from the opcode, but spv-in takes it from the operands. The
  writer's Restrict bounds checks are UMin with a u32 result on i32 indices
  and UMin on signed image coordinates, so mixed operands failed validation
  (min(i32, u32), FilmCraft's effects) and signed ones became a signed min
  that no longer clamps negative values; glslang's findMSB(uint), FindUMsb
  with an int result, failed too. Operands and results of the other
  signedness are now bitcast to the opcode's.
- OpLogicalAnd/OpLogicalOr on bool vectors, which the writer uses to guard
  integer vector divisions (egui-wgpu 0.37's fragment shaders: every egui
  0.37 app), are typed by spv-in as scalars only; they become OpSelect with
  an all-false or all-true vector.

Checks in vk/naga/test (intsign.comp, boolvec.comp, and each with the
writer's shapes patched in).
2026-11-28 19:23:52 +00:00
abeer0
68e463dbc5 chore: fix a typo in the fake-llvm wrapper comment (#40) 2026-11-28 20:08:23 +01:00
chungchihhan
6a6a0e396c Enable Docker IPv4 bridge networking in Debian guests (#59)
* 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>
2026-11-28 20:04:04 +01:00
Pooya Parsa
25e0add13f kernel: fold the patch series and export it without churn
Fold the 56 kernel patches into 32: one arch patch (which now includes
the riscv ISA patch, parking, atomics, SMP, blocking waits, unfair
spinlocks, the arm64 user ABI, pc sampling, ptrace, single-step and core
dumps), each driver with its SMP part, the generic changes one per piece
(the cond_resched() poll split out of the arch patch), and kw_defconfig
last. The messages describe the code as it is; every patch that was
kernel-wasm@localhost's is Pooya Parsa's. The tree is unchanged.

kernel/build.sh patches (kernel/tools/export-patches.sh) exports the
series without what changed in every later patch on each edit: no
numbers in the file names (the order is the new series file, which
build.sh applies), a zero commit hash, no git version signature and no
index lines, with the diff options fixed.
2026-11-28 18:55:49 +00:00
shi-wang
d6249de8de README: name the Wisp proxy the page uses by default (#60)
* README: name the Wisp proxy the page uses by default

The paragraph only said "a Wisp proxy", which leaves the reader to assume it
is their own. Name the default endpoint, say what it sees of a guest's
traffic, and keep the ?wisp= escape hatch in the same paragraph.

Refs #3

* Apply suggestion from @pi0

* Options: say whose Wisp server the default choice is

The Network section offered "Wisp" without saying that it is this project's
server and that the guest's traffic goes through it. One line under the choice
says both, next to the custom-servers field that replaces it.

---------

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
2026-11-28 19:35:54 +01:00
Pooya Parsa
c7ad16303d vk: fill the gaps games, mpv and Vulkan 1.2 callers hit (#32, #33) and add texel buffers: timeline semaphores are offered (values reached at the submit as fences are, a queue wait for a value nothing has signalled holds that submit and the later ones in the ICD until it is given), with imageless framebuffers, separate depth/stencil layouts, multiDrawIndirect, HOST_CACHED on the host-visible memory type, image_format_list and swapchain_mutable_format, and one more inter-stage location for wgpu-hal; the translator marks storage buffers a module never writes read-only, reflects only the resources an entry point reaches, drops OpLine, folds OpSpecConstantOp on integers, booleans and composites, lowers isinf/isnan and int[1] sample masks; the host sizes uniform bindings in 16-byte steps, copies block-compressed images in whole blocks and between size-compatible formats, binds placeholders for unwritten textures and samplers, takes storage bindings at unaligned offsets in dispatches through a scratch copy, rewrites indexed triangle fans as lists and no longer truncates sizes of 2 GiB and more; texel buffers (VkBufferView, both descriptor types) run as a storage buffer of words plus a per-view parameter block, decoded by the view's format in WGSL; the base profile exports LIBGL_KOPPER_DISABLE=1 so Mesa's zink stays off kwvk; mpv's gpu-next (yuv420p and rgb24), DDNet with its own SPIR-V and vkd3d's texel-buffer pipelines run; checks in test/vk (vk-timeline, vk-texel, host cases, translator shaders) and a games stage for the test disk 2026-11-28 13:05:33 +00:00
Pooya Parsa
9b16ce7f16 guest: add /usr/bin/sleep to Debian's boot set: kw-init's D-Bus machine id waits with sleep 1 on a fresh boot, which read it lazily from the end of the image 2026-11-28 00:42:54 +00:00
Pooya Parsa
bc6e5ba6a0 net: forward the guest's pings to an optional backend ping hook 2026-11-27 23:44:46 +00:00
Pooya Parsa
11edd82ca2 guest: let users open ICMP echo sockets, so ping works without root 2026-11-27 23:44:12 +00:00
Néstor
34761073e0 js: carry the guest's UDP through the direct and Wisp backends (#47) 2026-11-28 00:12:57 +01:00
Pooya Parsa
30aa355637 js: keep 9p fids consistent across removes and renames 2026-11-27 23:11:06 +00:00
Pablo
30d35d0a80 js: hard links on host file systems (Fs.link, 9p Tlink) (#46)
* 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>
2026-11-27 23:25:41 +01:00
Pooya Parsa
d80c033106 net: drop the default Wisp server from the SDK
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.
2026-11-27 22:24:02 +00:00
Pooya Parsa
287e41464f net: document Wisp's limits, add a lookup option, move to wisp.unkernel.dev
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
2026-11-27 22:15:52 +00:00
Pooya Parsa
0d4be496af web: add llms.txt 2026-11-27 21:44:35 +00:00
Pooya Parsa
b9b962c3ca web: link the docs for agents 2026-11-27 21:37:40 +00:00
Pooya Parsa
fd78ca9ad0 docs: serve cross-origin isolated, so the page's Docs window embeds them in every browser 2026-11-27 21:34:12 +00:00
Pooya Parsa
53e1fe6bb6 docs: add credits 2026-11-27 21:32:46 +00:00
Pooya Parsa
b803bdd0a5 web: add docs app 2026-11-27 21:23:34 +00:00
Pooya Parsa
cb784c6e2c chore: init docs 2026-11-27 21:11:51 +00:00
Pooya Parsa
e86777e0c5 web: drop the release copy: a release is always loaded from the mirror
A release build (and a dev server without a local build) downloads only
the release's page.json; the copy in web/kernel/release/ with its checks,
the GL and Vulkan downloads and KW_MIRROR=0 are gone. A release without
page.json is refused with what to do.
2026-11-27 16:20:33 +00:00
Pooya Parsa
08af7d9fe2 web: load the kernels, renderers and distro images from the release mirror
A page build with a release that carries page.json downloads only that
and points the page at mirror.unkernel.dev's copy of the release assets
(CORS, Range, immutable); nothing is copied into the output. The release
workflow now also publishes a gzipped copy of every .wasm, which the SDK
gunzips when a body starts with gzip's magic (the mirror sends files as
they are).
2026-11-27 16:10:47 +00:00
Pooya Parsa
3b71fa5637 ci: publish assets as artifacts v0.2.0-261127-3b71fa5 2026-11-27 15:35:45 +00:00
Pooya Parsa
87fcbbf991 wasi: close preview 1 gaps: sockets, wasi-threads, guest clocks and CPU time, fd_allocate
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.
2026-11-27 12:53:50 +00:00
Pooya Parsa
fd204d3130 web: add a Steam app to the Games folder: Valve's native aarch64 client (the Steam Frame's, unsupported elsewhere) as windows of the page through xwl.sh; steam.sh takes the client binary out of the package Valve's linuxarm64 manifest names (SHA-256 checked), makes the ~/.steam links, starts the client again after it updated itself or gave up on its first update, and runs the UI unpinned on fewer than three CPUs; the packages are what the client's binaries need; for games (x86) it puts a script in place of the FEX tool's emulator that leaves them to box64, and adds a compatibility tool that does the same (neither has run a game: box64 0.3.4's 32-bit mode lacks libc functions Steam's library needs) v0.2.0-261126-fd204d3 2026-11-26 00:44:09 +00:00
Pooya Parsa
39cf306b5b guest, web: show X apps' windows as windows of the page through xwayland-satellite: the Debian image carries Fedora 43's aarch64 build (glibc 2.34 at most; pinned from Koji, taken out of the RPM by tools/rpmfile.py) with libxcb-cursor0 and libfontconfig1 (4.3 MiB more erofs, the same 4 MiB boot prefetch), and wland 0.1.0-261125-0023837 on both sides, whose relay holds X display :1 (:0 is the KMS Xorg's) and starts satellite for the first X client on its scale-1 socket, so X apps that know no DPI come out the right size on HiDPI; Wayland shells get DISPLAY from the relay where Xwayland is installed, and the relay runs with the distro's PATH; the Xwayland wrapper adds -shm without libEGL (rootless Xwayland's glamor aborted in libepoxy); the launcher's xwl.sh runs satellite by default (the image's, else Fedora's RPM fetched once), on the scale-1 socket where there is one, so X11, XPaint and the D3D12 demos are rootless and Xfce alone stays rootful (XWL_ROOTFUL) 2026-11-26 00:16:39 +00:00
Pooya Parsa
6ea924bda9 guest: run x86_64 and i386 binaries through box64 on the Debian image: kw-init registers both ELF types in binfmt_misc with /usr/local/libexec/kw-binfmt, which on first use adds the Debian architecture, fetches its package lists and installs box64 and that architecture's libc6, libgcc-s1 and libstdc++6; .agents/x64.md records what runs, the measurements against qemu-user and the notes on a native front end 2026-11-25 23:47:49 +00:00
Pooya Parsa
96e4bd7ebb guest: preinstall dbus-daemon in the Debian image, for session buses (dbus-run-session; nothing starts at boot): 0.5 MiB more erofs, the same 4 MiB boot prefetch; the image leaves out D-Bus's random machine id, which kw-init makes once per machine, a second after the console starts (during the boot it delays the prompt by 15 ms) 2026-11-25 15:37:25 +00:00
Pooya Parsa
235955c313 web: fetch VLC through the page's mirror: the daily build's index and packages from /ppa and the libraries from /ports first, then the upstreams over plain http (Launchpad's https answers half of the requests with 503), with the index checked against the PPA's pinned signing key (sqv); a bundle's file can name a CORS mirror, which getFiles() tries before Wisp 2026-11-25 15:30:46 +00:00
Pooya Parsa
46eb0c8314 web: pin only Terminal and Settings in the Dock by default, on desktops and phones (the launcher's groups, glmark2 and Galculator are no longer pinned); the static first paint's Dock has the two in that order 2026-11-25 15:03:29 +00:00
Pooya Parsa
cec0a49f5d vk: make a wgpu app's graphics pipelines for the negative viewport height it draws with: the ICD sends the app's engine name in the hello, and for wgpu-hal the host translates vertex stages without the y flip and builds that variant in vkCreateGraphicsPipelines (it was built in the first submit, after an unused flipped one); the other orientation is a variant at draw time, logged once per connection with the engine's name; the host check draws both ways after destroying the shader modules and runs its SPIR-V suite with the toolchain's glslc v0.2.0-261125-cec0a49 2026-11-25 14:31:55 +00:00
Pooya Parsa
3f7bb3849b web: free the Mac's select all and Ctrl-A: on Apple devices the shortcut prefix is ⌘J (it was Ctrl-A and ⌘A), so ⌘A selects all and Ctrl-A always reaches the guest; Ctrl-C in a terminal there sends ^C also with text selected, and keys pressed with ⌘ in the Display window are released when ⌘ comes up (browsers send no keyup for them); elsewhere Ctrl-A in a text field of the page with text in it is select all 2026-11-25 14:28:57 +00:00
Pooya Parsa
9b4b9d0878 web: add Zed to the Tools folder: its own aarch64 build (1.29.3, 82 MiB, SHA-256 checked) fetched in the guest on first run and unpacked as zed.dev/install.sh does (GitHub sends no CORS headers; the page's mirror is asked first), started with --foreground on guest Vulkan, with Zed's own Open and Save As pickers in a new settings file (the guest has no desktop portal) 2026-11-25 14:11:34 +00:00
Pooya Parsa
e16c37ad6f vk: let wgpu apps (Zed) create a device and draw: the ICD reports maxFragmentCombinedOutputResources as the sum of storage buffers, storage images and color attachments (8 made wgpu derive 3 color attachments) and every bind group as a descriptor set (a layout with all of them and push constants fails in vkCreatePipelineLayout), and a pipeline's stages keep their shader module, so a variant made at draw time translates it after the app destroyed it 2026-11-25 14:02:24 +00:00
Pooya Parsa
c78039944a web: add VLC and mpv to the Media folder: VLC 4 (VideoLAN's daily build with its libraries from Ubuntu, unpacked under ~/.apps/vlc; the page fetches the libraries as an app's bundle, many files at once, pushed in batches) and mpv set up for guest VA-API (--vo=dmabuf-wayland, video-sync=desync, the builtin scripts off) 2026-11-25 13:09:11 +00:00
Pooya Parsa
1f0648d812 va: guest VA-API on the browser's WebCodecs (kwva): a libva driver in the base's kw layer sends each picture over vsock to a VideoDecoder or VideoEncoder on the page (createKernel({ va }), on by default on Debian, ?va=0); it decodes VP9, H.264, AV1 and HEVC (HEVC not yet run in a browser), encodes VP9, reads pictures back as exact NV12, exports surfaces as dmabufs of virtio-gpu resources and draws a decoded VideoFrame into a BGRX surface on the GPU (mpv --hwdec=vaapi --vo=dmabuf-wayland: 1080p H.264 at 30 fps on an M4 Pro) 2026-11-25 13:09:05 +00:00
Pooya Parsa
75694e278f kernel: optimize the lowered kernel with Binaryen -O2 (about 4% smaller, Debian shell commands about 3.5% faster in Node) and build kwemu with bulk memory, sign-ext, nontrapping-fptoint and mutable globals, which the kernel's C objects already need v0.2.0-261124-75694e2 2026-11-24 22:09:38 +00:00
Pooya Parsa
f6d7a4ee18 web: fx (local model) runs fx with FX_PERMISSION_MODE=full-access (no questions before tool calls; the caller's mode stays) and leaves a thinking model's reasoning on (THINK=0 turns it off) 2026-11-24 22:08:35 +00:00
Pooya Parsa
d21b013897 js: in worker mode on the shared transport, send vsock packets for the guest as one transferred message while the kernel waits idle, instead of copying them twice through the ring (a cold 26 MB read from a host mount: 125 to 102 ms); the worker counts delivered messages in VS_ACK so the stream keeps its order (#16) 2026-11-24 21:40:00 +00:00
Pooya Parsa
48f4732df5 web: Ollama and fx (local model) offer the registry's quantized tags (Qwen3 0.6B and 1.7B the defaults, no fp16 entries) and the llama.cpp, Ollama and fx apps drop the hints that quantized models abort 2026-11-24 21:21:48 +00:00
Pooya Parsa
7d74d40f94 vk: run llama.cpp's quantized models: the translator keeps barriers in uniform control flow past invocation-dependent continues, reads num_workgroups and workgroup_id without naga's private copy, runs workgroups wider than the device's limit as virtual invocations and lowers subgroup builtins of shaders without subgroup operations; a compute pipeline WebGPU refuses as read_write is made with its read-only buffers kept; the subgroup size is agreed in the hello (32, KWVK_SUBGROUP_SIZE: Qwen2.5 0.5B Q4_K_M 75 to 22 ms a token on an M4 Pro); timestamp queries resolve once at the read and never go backwards 2026-11-24 21:21:48 +00:00
Pooya Parsa
6e71333536 vk: pin glslc (shaderc v2026.4, built from source by vk/glslc.sh) and the SPIR-V headers for test/vk/guest/build-llama.sh, which cross-builds against the pinned Vulkan headers 2026-11-24 21:21:48 +00:00
Pooya Parsa
5a4ba76d79 js: export the page's Web Audio sink as createAudioOut() from unkernel/web (#17)
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
2026-11-24 20:41:32 +00:00
Pooya Parsa
0f4029e7ae web: hide the Dock and darken the top bar while a window is maximized, and make the Dock a lower full-width bar in compact mode 2026-11-24 19:30:45 +00:00
Pooya Parsa
c5ec8fdd97 gl: keep textures that WebGL refuses off used sampler units, so that such a draw lands (#27)
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).
2026-11-24 18:56:21 +00:00
Pooya Parsa
560dec5336 web: add a resource widget to the desktop, drop the meters' hover popover, and move the photo credit to the page's corner 2026-11-24 18:38:23 +00:00
Pooya Parsa
0da40f0a35 gl: let a WebGL error drop one call instead of putting the guest's context in error (#27)
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.
2026-11-24 18:12:50 +00:00