mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-05 18:09:29 +08:00
* 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>
262 lines
9.4 KiB
Diff
262 lines
9.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Pooya Parsa <pooya@pi0.io>
|
|
Date: Sun, 15 Nov 2026 10:16:10 +0000
|
|
Subject: [PATCH] wasm: add kw_defconfig
|
|
|
|
kw_defconfig, the configuration unkernel builds, and kw_smp.config, the
|
|
fragment merged over it for the SMP kernel (make kw_defconfig
|
|
kw_smp.config: SMP, NR_CPUS 16).
|
|
|
|
kw_defconfig is a hand-written list of explicit choices, never
|
|
savedefconfig output: Kconfig drops options whose dependencies are not
|
|
met without a word, so check .config after a change. Its comments say
|
|
why each group is there: no modules, the hvc console, the host devices
|
|
(kwblk, kwnet, kwfb, kwinput, kwsnd, kwvsock, kwshm, kwvirtio with
|
|
virtio-gpu), what systemd and container tools probe for (cgroup2,
|
|
namespaces, seccomp filters, fanotify, autofs), the file systems of the
|
|
root (ext4, erofs with zstd, overlayfs, 9p over a file descriptor, FUSE),
|
|
Docker's IPv4 bridge (BRIDGE, and nf_tables with the xtables
|
|
compatibility layer for iptables-nft's filter, conntrack and NAT rules;
|
|
the netdev hooks, SCTP tracking and IGMP snooping that come with them by
|
|
default stay off, and the conntrack hash table has a fixed 1024 buckets
|
|
instead of a size from RAM), and what DRM would bring along for hardware
|
|
displays, which stays off.
|
|
|
|
FRAME_WARN=3072: snmp_seq_show() (net/ipv4/proc.c) has a 2304-byte
|
|
frame. On wasm, clang passes variadic arguments in a buffer on the
|
|
shadow stack and gives each call site its own 16-byte slot, which stack
|
|
colouring never merges; snmp_seq_show() unrolls into 129 seq_printf()
|
|
calls.
|
|
|
|
Signed-off-by: Pooya Parsa <pooya@pi0.io>
|
|
---
|
|
arch/wasm/configs/kw_defconfig | 209 ++++++++++++++++++++++++++++++++
|
|
arch/wasm/configs/kw_smp.config | 4 +
|
|
2 files changed, 213 insertions(+)
|
|
create mode 100644 arch/wasm/configs/kw_defconfig
|
|
create mode 100644 arch/wasm/configs/kw_smp.config
|
|
|
|
diff --git a/arch/wasm/configs/kw_defconfig b/arch/wasm/configs/kw_defconfig
|
|
new file mode 100644
|
|
--- /dev/null
|
|
+++ b/arch/wasm/configs/kw_defconfig
|
|
@@ -0,0 +1,209 @@
|
|
+# unkernel: wasm64 kernel, emulated arm64 user mode (kwemu)
|
|
+# CONFIG_LOCALVERSION_AUTO is not set
|
|
+CONFIG_DEFAULT_HOSTNAME="unkernel"
|
|
+CONFIG_SYSVIPC=y
|
|
+CONFIG_POSIX_MQUEUE=y
|
|
+CONFIG_NO_HZ_IDLE=y
|
|
+CONFIG_HIGH_RES_TIMERS=y
|
|
+# systemd: cgroup2, namespaces, kcmp, fanotify, autofs
|
|
+CONFIG_CGROUPS=y
|
|
+CONFIG_CGROUP_PIDS=y
|
|
+CONFIG_NAMESPACES=y
|
|
+# unshare -r, bubblewrap, rootless tools, the Chromium sandbox
|
|
+CONFIG_USER_NS=y
|
|
+# /proc/PID/task/TID/children, map_files; CRIU
|
|
+CONFIG_CHECKPOINT_RESTORE=y
|
|
+# /proc/pressure (systemd-oomd), /proc/PID/io (iotop, htop)
|
|
+CONFIG_PSI=y
|
|
+CONFIG_TASKSTATS=y
|
|
+CONFIG_TASK_XACCT=y
|
|
+CONFIG_TASK_IO_ACCOUNTING=y
|
|
+# /proc/PID/mem writable without being a ptracer: programs that patch
|
|
+# their own code through /proc/self/mem
|
|
+CONFIG_PROC_MEM_ALWAYS_FORCE=y
|
|
+# time namespaces (unshare -T); the offsets apply in the syscalls (no vDSO)
|
|
+CONFIG_TIME_NS=y
|
|
+CONFIG_BLK_DEV_INITRD=y
|
|
+# CONFIG_RD_BZIP2 is not set
|
|
+# CONFIG_RD_LZMA is not set
|
|
+# CONFIG_RD_XZ is not set
|
|
+# CONFIG_RD_LZO is not set
|
|
+# CONFIG_RD_LZ4 is not set
|
|
+# CONFIG_RD_ZSTD is not set
|
|
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
|
|
+CONFIG_EXPERT=y
|
|
+CONFIG_KCMP=y
|
|
+CONFIG_USERFAULTFD=y
|
|
+# CONFIG_KALLSYMS is not set
|
|
+# CONFIG_IO_URING is not set
|
|
+# CONFIG_BPF_SYSCALL is not set
|
|
+# ELF core dumps, their notes from the ptrace regsets (gdb prog core)
|
|
+CONFIG_COREDUMP=y
|
|
+# CONFIG_SWAP is not set
|
|
+# CONFIG_COMPAT_BRK is not set
|
|
+# CONFIG_MODULES is not set
|
|
+CONFIG_SECCOMP=y
|
|
+CONFIG_SECCOMP_FILTER=y
|
|
+CONFIG_BINFMT_ELF=y
|
|
+CONFIG_BINFMT_SCRIPT=y
|
|
+CONFIG_BINFMT_MISC=y
|
|
+CONFIG_NET=y
|
|
+CONFIG_PACKET=y
|
|
+CONFIG_UNIX=y
|
|
+CONFIG_INET=y
|
|
+CONFIG_IP_MULTICAST=y
|
|
+# IPv4 Docker bridge and Debian's iptables-nft rules
|
|
+CONFIG_BRIDGE=y
|
|
+CONFIG_NETFILTER=y
|
|
+CONFIG_NF_CONNTRACK=y
|
|
+CONFIG_NF_CT_NETLINK=y
|
|
+CONFIG_NF_TABLES=y
|
|
+CONFIG_NF_TABLES_IPV4=y
|
|
+CONFIG_NFT_NAT=y
|
|
+CONFIG_NETFILTER_XTABLES=y
|
|
+CONFIG_NFT_COMPAT=y
|
|
+CONFIG_NETFILTER_XT_NAT=y
|
|
+CONFIG_NETFILTER_XT_TARGET_MASQUERADE=y
|
|
+CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
|
|
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
|
|
+# defaults Docker does not use: netdev hooks, SCTP tracking, IGMP snooping
|
|
+# CONFIG_NETFILTER_INGRESS is not set
|
|
+# CONFIG_NETFILTER_EGRESS is not set
|
|
+# CONFIG_NF_CT_PROTO_SCTP is not set
|
|
+# CONFIG_BRIDGE_IGMP_SNOOPING is not set
|
|
+# conntrack and NAT hash tables of 8 KiB each instead of 1/16384 of RAM
|
|
+# per table (512 KiB each above 1 GiB); nf_conntrack_max 8192
|
|
+CONFIG_NF_CONNTRACK_HASHSIZE=1024
|
|
+# policy routing (ip rule, more than one table): tailscale's table 52,
|
|
+# source-based routes
|
|
+CONFIG_IP_ADVANCED_ROUTER=y
|
|
+CONFIG_IP_MULTIPLE_TABLES=y
|
|
+# ss(8) for unix, packet and netlink sockets (INET_DIAG is on by default)
|
|
+CONFIG_UNIX_DIAG=y
|
|
+CONFIG_PACKET_DIAG=y
|
|
+CONFIG_NETLINK_DIAG=y
|
|
+# AF_VSOCK to the host (kwvsock, when the host offers it); ss --vsock
|
|
+CONFIG_VSOCKETS=y
|
|
+CONFIG_VSOCKETS_DIAG=y
|
|
+# CONFIG_VSOCKETS_LOOPBACK is not set
|
|
+CONFIG_KWVSOCK=y
|
|
+# CONFIG_IPV6 is not set
|
|
+# CONFIG_WIRELESS is not set
|
|
+# CONFIG_ETHTOOL_NETLINK is not set
|
|
+CONFIG_DEVTMPFS=y
|
|
+CONFIG_DEVTMPFS_MOUNT=y
|
|
+# CONFIG_FW_LOADER is not set
|
|
+# CONFIG_ALLOW_DEV_COREDUMP is not set
|
|
+# loop devices on demand through /dev/loop-control (8 up front cost 760 KiB)
|
|
+CONFIG_BLK_DEV_LOOP=y
|
|
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=0
|
|
+CONFIG_BLK_DEV_KWBLK=y
|
|
+CONFIG_NETDEVICES=y
|
|
+# a throwaway interface (ip link add type dummy)
|
|
+CONFIG_DUMMY=y
|
|
+# /dev/net/tun: openvpn, wireguard-go, tailscale
|
|
+CONFIG_TUN=y
|
|
+# a link into a network namespace (containers, ip netns)
|
|
+CONFIG_VETH=y
|
|
+# CONFIG_ETHERNET is not set
|
|
+# CONFIG_WLAN is not set
|
|
+CONFIG_KWNET=y
|
|
+# kwinput: keyboard and mouse as evdev devices when the host has a display
|
|
+CONFIG_INPUT=y
|
|
+# CONFIG_INPUT_MOUSEDEV is not set
|
|
+CONFIG_INPUT_EVDEV=y
|
|
+CONFIG_INPUT_KWINPUT=y
|
|
+# CONFIG_INPUT_KEYBOARD is not set
|
|
+# CONFIG_INPUT_MOUSE is not set
|
|
+# CONFIG_HID_SUPPORT is not set
|
|
+# CONFIG_SERIO is not set
|
|
+# CONFIG_VT is not set
|
|
+CONFIG_UNIX98_PTYS=y
|
|
+# CONFIG_LEGACY_PTYS is not set
|
|
+CONFIG_HVC_WASM=y
|
|
+# CONFIG_HW_RANDOM is not set
|
|
+# CONFIG_HWMON is not set
|
|
+# kwfb: /dev/fb0 when the host has a display, no fbcon (no VT)
|
|
+CONFIG_FB=y
|
|
+CONFIG_FB_KWFB=y
|
|
+# kwshm: the host reads and writes shmem files in place, /dev/kwshm
|
|
+CONFIG_KWSHM=y
|
|
+# /dev/udmabuf: dma-bufs from memfds (lavapipe exports its images so)
|
|
+CONFIG_UDMABUF=y
|
|
+# kwsnd: ALSA playback when the host has audio, plus OSS /dev/dsp for SDL 1.2
|
|
+CONFIG_SOUND=y
|
|
+CONFIG_SND=y
|
|
+CONFIG_SND_OSSEMUL=y
|
|
+# CONFIG_SND_MIXER_OSS is not set
|
|
+CONFIG_SND_PCM_OSS=y
|
|
+# CONFIG_SND_PCM_OSS_PLUGINS is not set
|
|
+# CONFIG_SND_PCM_TIMER is not set
|
|
+# CONFIG_SND_PROC_FS is not set
|
|
+# CONFIG_SND_CTL_FAST_LOOKUP is not set
|
|
+CONFIG_SND_KWSND=y
|
|
+# CONFIG_USB_SUPPORT is not set
|
|
+# kwvirtio: virtio devices of the host (only virtio-gpu so far), when it
|
|
+# offers them; no other virtio transport or device driver
|
|
+CONFIG_VIRTIO_MENU=y
|
|
+CONFIG_KWVIRTIO=y
|
|
+# CONFIG_VIRTIO_BALLOON is not set
|
|
+# CONFIG_VIRTIO_INPUT is not set
|
|
+# CONFIG_VIRTIO_MMIO is not set
|
|
+# /dev/dri/card0 (virtio_gpu, KMS and GEM shmem objects) when the host
|
|
+# offers virtio-gpu; no fbdev emulation (kwfb is /dev/fb0), no panic screen
|
|
+CONFIG_DRM=y
|
|
+# CONFIG_DRM_FBDEV_EMULATION is not set
|
|
+# CONFIG_DRM_PANIC is not set
|
|
+CONFIG_DRM_VIRTIO_GPU=y
|
|
+CONFIG_DRM_VIRTIO_GPU_KMS=y
|
|
+# what DRM would bring along for hardware displays: I2C (DDC), the HDMI
|
|
+# infoframe library, panels and the panel bridge, and devmem TCP (dma-buf)
|
|
+# CONFIG_DRM_DDC is not set
|
|
+# CONFIG_DRM_HDMI_INFOFRAMES is not set
|
|
+# CONFIG_DRM_PANEL_BRIDGE is not set
|
|
+# CONFIG_NET_DEVMEM is not set
|
|
+# CONFIG_VHOST_MENU is not set
|
|
+CONFIG_EXT4_FS=y
|
|
+CONFIG_EXT4_FS_POSIX_ACL=y
|
|
+CONFIG_EXT4_FS_SECURITY=y
|
|
+CONFIG_FANOTIFY=y
|
|
+CONFIG_AUTOFS_FS=y
|
|
+CONFIG_OVERLAY_FS=y
|
|
+# /dev/fuse for user space file systems (sshfs, rclone mount); built in,
|
|
+# since there are no modules
|
|
+CONFIG_FUSE_FS=y
|
|
+CONFIG_PROC_FS=y
|
|
+CONFIG_SYSFS=y
|
|
+CONFIG_TMPFS=y
|
|
+CONFIG_TMPFS_POSIX_ACL=y
|
|
+# erofs: a distro's read-only root image on kwblk, compressed with zstd;
|
|
+# xattrs with ACLs and security.* (file capabilities). lz4, which
|
|
+# EROFS_FS_ZIP always brings, fails here: it maps scattered pages with
|
|
+# vmap/vm_map_ram, which VMALLOC_FLAT cannot (ENOMEM). microLZMA is off.
|
|
+CONFIG_MISC_FILESYSTEMS=y
|
|
+CONFIG_EROFS_FS=y
|
|
+CONFIG_EROFS_FS_XATTR=y
|
|
+CONFIG_EROFS_FS_POSIX_ACL=y
|
|
+CONFIG_EROFS_FS_SECURITY=y
|
|
+CONFIG_EROFS_FS_BACKED_BY_FILE=y
|
|
+CONFIG_EROFS_FS_ZIP=y
|
|
+# CONFIG_EROFS_FS_ZIP_LZMA is not set
|
|
+CONFIG_EROFS_FS_ZIP_ZSTD=y
|
|
+# 9p over a file descriptor (trans=fd), such as an AF_VSOCK socket to a file
|
|
+# server on the host; the network file systems menu holds 9P_FS, and nothing
|
|
+# else in it is on
|
|
+CONFIG_NETWORK_FILESYSTEMS=y
|
|
+CONFIG_NET_9P=y
|
|
+CONFIG_NET_9P_FD=y
|
|
+CONFIG_9P_FS=y
|
|
+CONFIG_PRINTK_TIME=y
|
|
+# clang's wasm backend gives every variadic call its own 16-byte stack slot
|
|
+# for the argument buffer and never shares them, so a function with many
|
|
+# printf calls (snmp_seq_show: 129 after unrolling, 2304 bytes) passes the
|
|
+# 64-bit default of 2048. No other function here reaches 1024.
|
|
+CONFIG_FRAME_WARN=3072
|
|
+# /proc/sysrq-trigger, e.g. 'w' to list blocked tasks when the guest hangs
|
|
+CONFIG_MAGIC_SYSRQ=y
|
|
+# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
|
|
+# CONFIG_RUNTIME_TESTING_MENU is not set
|
|
+# CONFIG_DEBUG_MISC is not set
|
|
diff --git a/arch/wasm/configs/kw_smp.config b/arch/wasm/configs/kw_smp.config
|
|
new file mode 100644
|
|
--- /dev/null
|
|
+++ b/arch/wasm/configs/kw_smp.config
|
|
@@ -0,0 +1,4 @@
|
|
+# unkernel SMP build: merged over kw_defconfig (make kw_defconfig kw_smp.config).
|
|
+# One wasm instance per CPU on a shared memory; see arch/wasm/Kconfig, SMP.
|
|
+CONFIG_SMP=y
|
|
+CONFIG_NR_CPUS=16
|