SexOS ยท Core Design

Architecture

๐Ÿ› Kernel Core

Sex is a microkernel, meaning it implements only the most fundamental primitives required to build a complete operating system. The goal is to keep the privileged code within a Tiny Trusted Computing Base (TCB) of roughly 5โ€“8 kLOC.

๐ŸŒŸ Design Principles

๐Ÿ”’ Memory & Protection Domains

๐ŸŒ Global Single Virtual Address Space (SAS)

In Sex, all data is mapped into a single 64-bit address space. This removes the need for page table switching (and the resulting TLB flushes) when moving between protection domains. Addresses are globally unique across the entire system.

๐Ÿ›ก Protection Domains (PDs)

Isolation is enforced by Protection Domains (PDs). Each domain represents a logical set of permissions (Read, Write, Execute) over specific address ranges.

Protection Key Model
PKEYPurpose
PKEY 0Kernel + default (no restriction)
PKEY 1sexdisplay / framebuffer (trusted display domain)
PKEY 2+Future userland PDs

โšก IPC Primitives: PDX & Ring Buffers

๐Ÿš€ Protected Procedure Calls (PDX)

The core IPC mechanism is a synchronous Protected Procedure Call (PDX).

  1. Safe PDX: Validates a capability before performing a hardware-accelerated domain switch.
  2. Fused PDX: Bypasses capability checks for high-frequency hot-paths between "fused" domains.

๐Ÿ“ฆ Asynchronous Ring Buffers

For interrupts and high-volume data transfer, Sex uses lockless, SPSC (Single Producer, Single Consumer) ring buffers. These are cache-line aligned to prevent false sharing on 128-core systems.

๐Ÿ— Capability System

Sex uses a Sparse Capability system. A capability is an unforgeable token that proves its holder has the right to access a specific resource.

๐Ÿ›  Capability Types

๐Ÿ–ฅ User-space Servers

All traditional OS services run in isolated user-space Protection Domains.

ServerResponsibility
sextManages the global VAS and handles asynchronous page faults via large pages.
Capability ServerCentral authority for capability policy, distributed for local core scaling.
sexfilesUnified file system interface (Phase 3).
sexnetUser-space TCP/IP stack (Phase 3).
sexinputIsolated hardware management (Mouse, Keyboard, etc.).

๐Ÿ—บ Architecture Roadmap

PhaseStatusDescription
0: BootstrapComplete โœ…Bootable kernel skeleton, basic HAL, VGA/serial console, UEFI.
1: Core PrimitivesStable ๐Ÿš€Physical memory manager, sexting, Protection Domains, PDX, SMP boot.
2: Capabilities & ServersStable ๐Ÿš€Capability engine, user-space sext, SMP 128-core, interrupt management.
3: Services & sexfilesStable ๐Ÿš€Standalone sexfiles, real block I/O, ramfs, POSIX syscall bridge.
4: DistributionComplete โœ…Standalone sexnet, remote PDX routing, zero-copy packet transfer.
5: Hardware & sexdriveComplete โœ…ARM64 design, DDE-Sex shim, NVIDIA 3070 GPU, sexdrive server.
6: Signal TrampolineComplete โœ…Background trampoline threads, POSIX sigaction ABI, lock-free signals.
7: Memory SubsystemComplete โœ…Lock-free buddy allocator, PKU domain management, async #PF forwarding.
8: ELF Loader + PD SpawnComplete โœ…ELF segment parsing, PD creation, sys_spawn_pd.
9: Driver EnablementComplete โœ…NVMe/AHCI driver, zero-copy DMA, MSI-X, input stack.
10: Graphical PlumbingComplete โœ…sexdisplay server, HID routing, zero-copy graphics, Mesa bootstrap.
11: GNU PipelineComplete โœ…POSIX pipes, fork/exec, coreutils, signal delivery, Lin-Sex compatibility.
12: Dynamic TranslatorsComplete โœ…sexnode translator, on-the-fly ELFโ†’Sex binary translation.
13: Self-HostingComplete โœ…sex-gemini agent, sexstore packages, full in-Sex build loop.
14: Formal VerificationComplete โœ…Refined allocator, hardened PKU init, CHERI prep, verification hooks.
15: Linux Driver TranslationComplete โœ…DDE-style wrappers, on-the-fly Linux driver translation, hot-plug.
16: Userspace MaturityComplete โœ…Operational sexnode, GitHub fetch, Linux benchmarks, FLSCHED verification.
19: sexfiles OverhaulComplete โœ…100% lock-free VFS, zero-copy PKU handover, lock-free LRU cache.
20: Graphical Sex-StoreIn Progress ๐Ÿ—๏ธOne-click sexting, binary caching, app store GUI.
๐Ÿ† The Vision Realized

The Sex Microkernel project has successfully evolved from a single-core bootloader into a high-performance, distributed Single Address Space Operating System. By leveraging Intel PKU for zero-cost isolation and a global 64-bit VAS, we have created a platform that treats a sexnode of machines as one unified, secure, and lightning-fast computer.