Skip to content

Version 0.3.0

Latest

Choose a tag to compare

@jgarzik jgarzik released this 19 Oct 06:56
· 2114 commits to main since this release
2d4e80f

hk v0.3.0

v0.3.0 is a major step toward running real Linux userspace on many-core hardware. It rebuilds the memory manager on Linux's design, adds a real network stack (TCP, UDP, ICMP, raw, AF_UNIX, AF_PACKET, netlink) with virtio-net and e1000 drivers, and brings in SMP infrastructure: TLB shootdown, cross-CPU calls, per-CPU data and sleeping locks. Every test in the boot suite now also runs against a real Linux kernel on both x86-64 and aarch64, and all of it gates every commit. Busybox runs end-to-end.

363 commits, 438 files changed (+94k / -29k lines).

Build, CI and testing

  • Stable Rust: builds on the stable toolchain now; nightly is no longer needed.
  • GitHub CI: lint and build, host unit tests (x86-64 and native arm64), and QEMU boot tests for both arches. arm64 runs under KVM on arm64 hosts.
  • Linux differential testing: make check-linux / check-linux-arm run the same boot_tester as init on a real Linux kernel. Linux sets the expected behavior. Foreign-arch kernel downloads are verified (InRelease signature plus hashes), and results are cached by input hash.
  • make gate: fmt-check, clippy (both arches), unit tests, then all four boot checks in parallel. Serial logs are per tree, NO_KVM=1 forces TCG, and a failed boot's summary shows where it stopped.
  • lockdep-lite: make check LOCKDEP=1. might_sleep checks run in every build.
  • TCG boot tests use -cpu max / neoverse-n1 so SMAP, SMEP and PAN get exercised. QEMU_CPU picks the CPU model.
  • New boot test suites: timing and wakeups, fork/mm, mremap/mprotect/mlock ranges, mmap_lock and page-table locking, memory core, swap, block, netlink, AF_UNIX, AF_PACKET, TCP/UDP, sockopts, network locking stress, and busybox end-to-end (Ubuntu busybox-static in the initramfs, plus an HTTP test peer).

Memory management

  • Higher-half x86-64 kernel with a direct map of all RAM. On arm64 the kernel lives in TTBR1 with a full linear map.
  • memblock covering every firmware memory region, struct page in a vmemmap, and a buddy allocator with per-CPU page lists. Zone watermarks come from min_free_kbytes.
  • The slab allocator is now the kernel heap, with kmem caches for VMAs, dentries and inodes. The fixed heap is gone.
  • Generic page-fault path (handle_mm_fault). Out-of-memory user faults kill the process (pagefault_out_of_memory).
  • mmap_lock is a sleeping RwSem. Added page_table_lock and split PTE locks, and a single page-range walker with one PTE lock per table.
  • Refcounted address spaces. Fork copies page tables per VMA (copy_page_range). The user address space layout and process image match Linux.
  • shmem: shared anonymous memory, SysV shm on shmem, and MAP_SHARED file mappings backed by page-cache pages.
  • Anonymous reverse map, xarray, a real LRU (IRQ-safe lru_lock, per-CPU add batches), counted swap slots with a working swap cache, anonymous page reclaim (shrink_folio_list), direct reclaim, and MADV_PAGEOUT / MADV_COLD.
  • VMA splitting and range semantics follow Linux for munmap, MAP_FIXED, brk, mremap, mprotect, mlock, madvise, msync and mincore. Page tables emptied by munmap/mremap are freed.
  • vm.max_map_count, and /proc/meminfo.
  • Physically contiguous DMA buffers and kernel stacks. Exec streams the ELF image instead of copying it into the heap.

SMP, scheduling and locking

  • mm-aware TLB flush API with per-CPU TLB state and switch_mm, x86 IPI shootdown, arm64 ASIDs, and an mmu_gather-style Gather (one flush per unmap).
  • Cross-CPU function calls and the reschedule IPI. cpumask with NR_CPUS=256. PerCpu<T> and a per-CPU current().
  • Real sleep and wakeup: wait_event API, signal wakeups and syscall restart, allocation-free wakeups, and Completions.
  • Sleeping Mutex and typed RwSem with killable and try variants. i_rwsem, f_pos_lock and RTNL are now sleeping locks, and spin locks raise the preempt count.
  • Syscalls and page faults run with interrupts enabled.
  • kthreads (kthread_run, stop/park), AP schedulers, workqueue workers and ktimerd.
  • Task core redesign: Arc<Task> with atomic hot fields, struct Pid with per-namespace pidmaps and a pid hash, a reader-writer TASKLIST, thread groups on the leader's list, and per-task signal state under its own lock.
  • Time: seqlock read/write barriers that match Linux. Timekeeper writers are serialized.
  • doc/LOCKING.md is substantially expanded and kept in sync with the code.

Processes, signals and credentials

  • Thread-group exit: exit_group, fatal signals, delay_group_leader, de_thread.
  • rt_sigsuspend, synchronous fault signals delivered at fault time, and user FP/SIMD state preserved across switches, fork, exec and signals.
  • setitimer / getitimer (ITIMER_REAL), alarm, times, and close_range.
  • RLIMIT_NPROC charged per task. waitid honors WNOWAIT and fills rusage.
  • Linux discretionary access control throughout the VFS. setuid/setfsuid capability handling matches Linux.
  • ptrace attach and process_vm_* use Linux's access rules. Remote writes break COW.
  • comm and dumpability carry across fork and exec as in Linux. procfs adds /proc/<pid>/{status,stat,cmdline,environ} with ptrace access checks.
  • BSD process accounting records are written by the group's last thread.

Filesystems and VFS

  • A central mnt_want_write gate with atomic remount. Mount requires CAP_SYS_ADMIN and honors ro, nosuid, nodev and noexec.
  • O_APPEND and writes run under i_rwsem, with atomic f_pos. lock_rename follows Linux, including the directory trap.
  • renameat2 flags, linkat flags with AT_EMPTY_PATH, legacy getdents on x86-64, truncate/ftruncate/fstat on both arches, and mknod(S_IFSOCK).
  • stdin, stdout and stderr are ordinary fd-table entries. Descriptors are allocated lowest-free, and exec closes close-on-exec fds.
  • Reads and writes go through bounded kernel buffers (MAX_RW_COUNT). Atomic inode timestamps.

Block

  • bios with end_io, completions and blk-mq-lite.
  • Partitions, devtmpfs and /proc/partitions. Block device files go through bios.
  • virtio-blk on the new block layer, plus BLK* ioctls.

Networking

  • Socket core: sockfs inodes, per-family ops, and real blocking with O_NONBLOCK, timeouts, SA_RESTART and SIGPIPE semantics.
  • Softnet threads, NAPI, the netif_rx backlog, a real loopback, and per-device network namespaces.
  • TCP rewrite (RFC 9293), built on an I/O-free control block:
    • all eleven states and RFC 5961 checks
    • RFC 6298 RTO, window scaling and timestamps (PAWS)
    • Reno/NewReno behind a pluggable congestion-control interface
    • delayed ACK, Nagle, TCP_CORK, keepalive and TCP_USER_TIMEOUT
    • compact TIME_WAIT entries
  • UDP, ICMP error generation with rate limits, ping sockets, and SOCK_RAW (IP_HDRINCL, ICMP_FILTER).
  • IPv4 fragmentation with bounded reassembly and PMTU modes. Martian filtering and source-address checks.
  • A generic neighbour subsystem, with ARP built on it. FIB routing.
  • AF_UNIX (stream, datagram, seqpacket), AF_PACKET with classic BPF socket filters and transmit taps, and NETLINK_ROUTE (links, addresses, routes, neighbours, resumable dumps).
  • SIOC* interface and route ioctls.
  • /proc/net/{dev,tcp,udp} and a writable /proc/sys/net subset, including TCP sysctls and string-valued entries.

Drivers and arch

  • virtio: modern PCI transport and split virtqueues. A virtio-net driver, which is now the default NIC (NIC=e1000 keeps e1000).
  • e1000 now works: bus mastering, an RX ring, NAPI and link-state changes.
  • PCI capability list iterator.
  • aarch64: GIC SPI enable and PCI INTx via the DT interrupt-map, PAN, PXN for user pages, EL0 cache maintenance, I-cache maintenance where pages become executable, and many ABI corrections (struct layouts, syscall numbers, clone argument order).
  • x86-64: 8259 PIC interrupts delivered through the LAPIC (LINT0 ExtINT), CR0.WP, and CPUID faulting control via arch_prctl.
  • uaccess: every user copy goes through uaccess (SMAP/PAN clean), with demand-faulting and EFAULT fixups. Explicit, zeroed uapi struct padding.

Plus many bug fixes.