Skip to content

feat(ipc): bring up minimal Wayland compositor and wl_shm client on /dev/fb0 and evdev - #278

Merged
marcobuschini merged 2 commits into
mainfrom
264-issue-bring-up-minimal-wayland-compositor-and-wl_shm-client-on-devfb0-and-evdev
Dec 4, 2026
Merged

marcobuschini merged 2 commits into
mainfrom
264-issue-bring-up-minimal-wayland-compositor-and-wl_shm-client-on-devfb0-and-evdev

Conversation

@marcobuschini

Copy link
Copy Markdown
Member

Summary

Implements all 5 milestones of #264 to bring up a minimal Wayland compositor and threaded wl_shm client running on Milo OS over /dev/fb0 (virtio-gpu) and /dev/input/event* (virtio-input):

  1. SCM_RIGHTS FD Passing over AF_UNIX
    • Added UnixRightsBatch framing on AF_UNIX SOCK_STREAM rings (preserving message boundaries across rights batches) and SOCK_DGRAM queues, with automatic vfs_close cleanup of unreceived FDs.
    • Added SOL_SOCKET/SCM_RIGHTS, MSG_CMSG_CLOEXEC, and MSG_CTRUNC handling to sys_sendmsg / sys_recvmsg.
  2. Cross-Process MAP_SHARED on tmpfs & memfd_create
    • Added InodeOperations::get_page and tmpfs_get_page (zero-copy physical frame sharing across processes) and expanded tmpfs files up to 4 MiB via inline direct + lazy indirect page tables.
    • Implemented sys_memfd_create (AArch64 syscall 279) and mounted tmpfs at /dev/shm.
  3. epoll, eventfd, and timerfd Event Loop Primitives
    • Implemented EventFd, TimerFd, and EpollInstance in kernel/ipc/EventLoop.{hpp,cpp} and syscalls eventfd2 (19), epoll_create1 (20), epoll_ctl (21), epoll_pwait (22), timerfd_create (85), timerfd_settime (86), and timerfd_gettime (87) with LP64 AArch64 UAPI structs (kernel/uapi/event.hpp).
  4. Userspace Threads (CLONE_THREAD) & sys_futex
    • Refactored Process to share AddressSpace, FdTable, SignalTable, brk, and mmap arena through refcounted SharedProcessState.
    • Added CLONE_THREAD support in sys_clone, split exit (93) vs exit_group (94), added gettid (178), tkill (130), tgkill (131), and physical-address-keyed sys_futex (98, FUTEX_WAIT/FUTEX_WAKE).
  5. Minimal Wayland Compositor & wl_shm Client
    • Added user/wl_proto.h, user/wl_compositor.c, and user/wl_client.c, packaged into all initrds (busybox.cpio, bash.cpio, debian-bash.cpio).
    • Compositor listens on /tmp/wayland-0, runs an epoll + eventfd + timerfd + evdev event loop, maps received wl_shm pools via SCM_RIGHTS + MAP_SHARED, composites client ARGB8888 surfaces to /dev/fb0 (FBIO_FLUSH), and forwards /dev/input/event0/event1 events as wl_keyboard/wl_pointer protocol events.
    • Client allocates a 320×240 wl_shm buffer via memfd_create, transfers it over SCM_RIGHTS, renders animated frames on a pthread (CLONE_THREAD) + futex worker thread, and synchronizes commits with wl_surface.frame callbacks.

Verification

  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality: passed (0 formatting violations, 0 license violations, 0 clang-tidy issues, 89/89 host tests / 464,648 assertions under ASan/UBSan).
  • QEMU milo> test wayland -v: passed=11 failed=0 (verifies /dev/shm, compositor + client exit 0, rendered /dev/fb0 pixels, evdev drain, and zero PCB/thread/heap/PFA leaks).
  • QEMU milo> test all: passed=270 failed=0.
  • Live QEMU bash + HMP monitor verification: injected virtio-keyboard (KEY_A) and virtio-tablet (BTN_LEFT) events received by wl_client (ptr_ev=2, key_ev=2) and verified 1280×800 virtio-gpu screendump (3,070,570/3,072,000 non-zero RGB bytes).

Closes #264

Implement the kernel ABI primitives and userspace binaries required to run
a minimal Wayland compositor and wl_shm client on /dev/fb0 and evdev:

- SCM_RIGHTS FD passing over AF_UNIX (sendmsg/recvmsg, MSG_CMSG_CLOEXEC,
  MSG_CTRUNC, stream boundary framing, refcounted File* transfer)
- Cross-process MAP_SHARED on tmpfs (get_page hook, up to 4 MiB files),
  sys_memfd_create (279), and /dev/shm tmpfs mount
- epoll (epoll_create1/epoll_ctl/epoll_pwait), eventfd2, and timerfd
  (timerfd_create/settime/gettime) event loop primitives
- Userspace threads (clone CLONE_THREAD with refcounted SharedProcessState,
  exit vs exit_group, gettid, tkill/tgkill) and sys_futex (WAIT/WAKE)
- Minimal Wayland compositor (user/wl_compositor.c) and threaded wl_shm
  client (user/wl_client.c) speaking Wayland wire protocol over
  /tmp/wayland-0, compositing to /dev/fb0, and forwarding /dev/input/event*
- Host ASan/UBSan tests (tests/host/wayland_abi_test.cpp) and QEMU shell
  verification suite (kernel/shell/tests/test_wayland.cpp)

Closes #264
…e run-vnc

- Send SIGHUP (or SIGKILL if ignored/blocked) to remaining session
  members when a root session leader exits without PID 1 init, and reap
  zombie session children during Process::destroy() so interactive shells
  return immediately to milo> with zero leaked PCBs or PFA frames
- Handle SIGHUP cleanly in user/wl_compositor.c to unlink /tmp/wayland-0
  and unmap /dev/fb0 on shutdown
- Add make run-vnc target using -vnc 0.0.0.0:0 -serial mon:stdio so
  Ctrl-A X exits QEMU cleanly while viewing /dev/fb0 over VNC
- Add host test covering root session-leader zombie reaping
@marcobuschini marcobuschini self-assigned this Dec 4, 2026
@marcobuschini
marcobuschini merged commit c55717a into main Dec 4, 2026
5 checks passed
@marcobuschini
marcobuschini deleted the 264-issue-bring-up-minimal-wayland-compositor-and-wl_shm-client-on-devfb0-and-evdev branch December 4, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE] Bring Up Minimal Wayland Compositor and wl_shm Client on /dev/fb0 and evdev

1 participant