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.
* web: add a terminal colour theme option (Auto, Dark, Light)
* web: add an option to turn off the Terminal window's see-through glass
* web: default the terminal colours to Auto
* web: add a page colour theme option (Auto, Dark, Light)
* web: give the chrome's materials in style.css a light variant
* web: give the components' chrome classes a light variant
* web: follow the theme in the charts, the alerts' caution badge and the Docs window
* web: fix the light theme's Dock glyphs, Resume card veil and Browser toolbar hover
* web: read the shown theme from the store and type the option field names
* web: darken the light theme's faint and error colours to 4.5:1 on tints
* web: give the light terminal mid-tone colours that read under black text
* web: lighten the light terminal's green, yellow and cyan for black text on them
* web: use the dark terminal's green in the light terminal
* web: give the light terminal's green, yellow and cyan 4.5:1 on white, as its red, blue and magenta
* web: give the light theme a white status bar on iOS
* web: make the Docs window opaque
* web: post a theme change to the Docs window instead of reloading it
* docs: upgrade undocs nightly, for the Docs window's theme messages
---------
Co-authored-by: Pooya Parsa <pooya@pi0.io>
On the SMP kernel a workqueue worker in the middle of an item could wait
for kernel threads that had already parked, never reach its own park
point, and end the cycle with -EBUSY naming it. A netns teardown's
cleanup_net() does that: it waits for grace periods, the expedited
grace-period worker and other work items. A cycle started right after an
`unshare -n` exit failed 13 times in 15 on 2 CPUs and 12 in 15 on 4; beside
a loop of netns teardowns 22 of 30 and 20 of 30 failed. Docker's
containers (#59) make such teardowns routine in Debian guests.
- The TREE_RCU grace-period kthread parks only while no grace period is
in progress or requested, so that a kernel thread in synchronize_rcu()
or rcu_barrier() can reach its park point (a fixup of the park points
patch).
- Between the user and the kernel-thread phases kwparkd waits, at most
HZ/2, until every workqueue worker is idle (in TASK_IDLE), while every
kernel thread still runs (kw_park_settle_work(), a fixup of the arch
patch).
With both, every cycle of those runs passed (120 on 2 and 4 CPUs). An idle
cycle's median went from 17.9 ms to 0.3 ms on 2 CPUs; a cycle that waits
for a teardown takes 60-230 ms. kwtest's park check is unchanged (2-5 ms
mean). parking.md describes the settle step and the grace-period rule.
Based on Martin Brook's patches on the android branch of
martinbrook/unkernel (cc78ca9, 4849ed9). His settle step also ran
rcu_barrier() and waited only for workers in an uninterruptible sleep:
here the barrier cost 40-50 ms in every cycle, and a worker between two
waits (runnable) ended the wait early, so 11 of 15 cycles still failed.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: Martin Brook <martin.brook100@googlemail.com>
get_user() and put_user() of an aligned 1, 2, 4 or 8 bytes are now one
load or store through kw_user_addr() instead of a memcpy (memory.copy,
which the Wasm spec does not make single-copy atomic on a shared
memory), so a futex word read beside another CPU's stores cannot tear;
an unaligned access still goes through raw_copy_*_user().
kwfb's set_par checks the mappings, allocates and switches the buffer
under info->mm_lock, which fbdev's mmap holds (check_var reads the count
under it too): an mmap racing FBIOPUT_VSCREENINFO from another thread
could map the old buffer.
kwtest checks both (uaccess: FUTEX_WAIT and getcpu beside another CPU's
stores, fault-in, EFAULT and a put_user across a page; kwfb: 200 mmaps
beside a thread changing the mode), and `kwtest smp` runs the kwfb
checks. Ported from VOD-Studio/unkernel@25e90b3f.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: xfy <i@rua.plus>
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>
A failed run (a script that exits non-zero, no prompt for --trace, a
--get that does not match) now prints the end of the console, and on a
guest booted with systemd (/run/systemd/system) also systemctl --failed,
its jobs and the boot's journal; the other images print nothing more.
The traced boot's prompt detector also strips OSC sequences ended by ST
(ESC \), as systemd sends them, and CSI with a ! intermediate.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: Vineel Sai <mail@vineelsai.com>
The project's Wisp server accepts only the page's own origins, so a page
built and served elsewhere had no network unless every load named a
server with ?wisp=. KW_WISP=<url>[,<url>...] sets the default list
instead (vite.config.ts defines __KW_WISP__, net.ts makes it
DEFAULT_WISP_SERVERS); a relative URL such as /wisp/ is on the page's own
origin, over ws: or wss:. ?wisp= still overrides it, the Network option's
note says whose server the default is, and without KW_WISP the page is
unchanged.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: Swaroop Patil <swarooppatil850@gmail.com>
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>
The CLI boots any count from 1 to 32, given by --cpus or taken from a
snapshot. Above os.availableParallelism() the CPU threads take turns,
and a CPU that waits for another (an IPI, a TLB shootdown) waits until
the host schedules that one. It still boots, now with a warning on
stderr. The --help text and js.md say so.
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: xfy <i@rua.plus>
* 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>
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: Pooya Parsa <pooya@pi0.io>
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>