mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-07 05:07:33 +08:00
326 lines
12 KiB
Diff
326 lines
12 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),
|
|
read-only images (squashfs with all its compressors, erofs with
|
|
microLZMA), other systems' disk images (FAT, exFAT, iso9660 with Joliet
|
|
and zisofs),
|
|
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 | 270 ++++++++++++++++++++++++++++++++
|
|
arch/wasm/configs/kw_smp.config | 4 +
|
|
2 files changed, 274 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,270 @@
|
|
+# 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
|
|
+# Bluetooth: hci0 while the host has a controller attached (kwbt); the
|
|
+# core with LE and BR/EDR, no RFCOMM, BNEP, HIDP or vendor drivers
|
|
+CONFIG_BT=y
|
|
+CONFIG_BT_KWBT=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
|
|
+# no dummy0 at boot: only the ones asked for (the host's tailscale0)
|
|
+CONFIG_DUMMY_NUMDUMMIES=0
|
|
+# /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
|
|
+# kwserial: /dev/ttyACM* when the host has serial ports (serial_core, no 8250)
|
|
+CONFIG_SERIAL_KWSERIAL=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
|
|
+# kwcam: /dev/video0, V4L2 capture when the host has a camera. It selects
|
|
+# the V4L2 core and videobuf2-dma-contig; every media category of the
|
|
+# filter is off, so nothing else of the media tree is built: no media
|
|
+# controller, no TV, radio, SDR, platform or test drivers, no ancillary
|
|
+# (tuner, sensor) drivers, whose autoselection would bring in I2C
|
|
+CONFIG_MEDIA_SUPPORT=y
|
|
+CONFIG_MEDIA_SUPPORT_FILTER=y
|
|
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
|
|
+# CONFIG_MEDIA_CAMERA_SUPPORT is not set
|
|
+# CONFIG_MEDIA_PLATFORM_SUPPORT is not set
|
|
+CONFIG_VIDEO_KWCAM=y
|
|
+# kwusb: the host's USB devices (WebUSB in a browser) on a virtual host
|
|
+# controller, for usbfs programs (libusb: adb, fastboot, dfu-util,
|
|
+# openocd, rtl-sdr) and USB serial adapters (/dev/ttyUSB*: FTDI, CP210x,
|
|
+# CH34x, PL2303). No class drivers for what WebUSB cannot claim (HID,
|
|
+# storage, audio, video), and no cdc_acm: kwserial's ports are ttyACM
|
|
+CONFIG_USB_SUPPORT=y
|
|
+CONFIG_USB=y
|
|
+CONFIG_USB_KWUSB_HCD=y
|
|
+CONFIG_USB_SERIAL=y
|
|
+CONFIG_USB_SERIAL_FTDI_SIO=y
|
|
+CONFIG_USB_SERIAL_CP210X=y
|
|
+CONFIG_USB_SERIAL_CH341=y
|
|
+CONFIG_USB_SERIAL_PL2303=y
|
|
+# menus with nothing on in them
|
|
+# CONFIG_USB_NET_DRIVERS is not set
|
|
+# CONFIG_SND_USB 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
|
|
+# (or microLZMA); 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).
|
|
+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=y
|
|
+CONFIG_EROFS_FS_ZIP_ZSTD=y
|
|
+# squashfs images (AppImage, snap, live images) with xattrs and every
|
|
+# compressor the kernel has (zlib, lz4, lzo, xz, zstd; xz and zstd reuse the
|
|
+# decompressors microLZMA and zstd above bring).
|
|
+CONFIG_SQUASHFS=y
|
|
+CONFIG_SQUASHFS_XATTR=y
|
|
+CONFIG_SQUASHFS_ZLIB=y
|
|
+CONFIG_SQUASHFS_LZ4=y
|
|
+CONFIG_SQUASHFS_LZO=y
|
|
+CONFIG_SQUASHFS_XZ=y
|
|
+CONFIG_SQUASHFS_ZSTD=y
|
|
+# Images of other systems' disks: FAT (vfat, msdos: SD-card and EFI boot
|
|
+# partitions, floppy images; UTF-8 file names by default), exFAT, and
|
|
+# iso9660 with Joliet and zisofs. With MBR and GPT partition tables (the
|
|
+# defaults) on kwblk and loop devices. The NLS tables are FAT's default
|
|
+# codepage and iocharset and UTF-8, the default for the others (Joliet's
|
|
+# names, exFAT).
|
|
+CONFIG_MSDOS_FS=y
|
|
+CONFIG_VFAT_FS=y
|
|
+CONFIG_FAT_DEFAULT_UTF8=y
|
|
+CONFIG_EXFAT_FS=y
|
|
+CONFIG_ISO9660_FS=y
|
|
+CONFIG_JOLIET=y
|
|
+CONFIG_ZISOFS=y
|
|
+CONFIG_NLS_CODEPAGE_437=y
|
|
+CONFIG_NLS_ISO8859_1=y
|
|
+CONFIG_NLS_UTF8=y
|
|
+CONFIG_NLS_DEFAULT="utf8"
|
|
+# 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
|