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>
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.
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).
* 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>
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.
* 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>
* 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
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.
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).
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.