Skip to content

cloudlinqed/WayOS

Repository files navigation

WayOS — AI-Native Multi-Architecture Microkernel OS

New to WayOS? Start with QUICK_START.md.

A custom operating system built from scratch with a microkernel architecture, higher-half kernel mapping, SMP support, and an integrated AI subsystem with kernel-managed tensors.

Overview

WayOS is an educational/research OS featuring:

  • Multi-architecture kernel (x86_64 + aarch64) with shared core subsystems
  • Direct physical map at 0xFFFF800000000000 for zero-copy kernel access
  • User-mode servers (console, AI daemon, network daemon) communicating via IPC ports
  • AI subsystem with kernel tensors, compute graphs, model loading, and inference scheduling
  • SMP support with per-CPU data (GS on x86_64, TPIDR_EL1 on aarch64)
  • Security via capabilities, syscall filtering, and SMEP

Subsystems

Subsystem Description
PMM Buddy allocator with per-tier allocation (DDR4 + VRAM-sim)
VMM VMA-based virtual memory with demand paging and Copy-on-Write
Scheduler 6-priority multi-queue scheduler (RT inference to idle)
IPC Port-based message passing with RPC call/reply pattern
tmpfs Writable in-memory filesystem (512 inodes, 1MB/file max)
Security Process capabilities, syscall filter bitmask, SMEP
Unified Memory 2-tier memory with placement hints and migration daemon
AI Kernel tensors, compute graphs, model files (.waymodel), inference queue
Networking VirtIO-net legacy driver, user-mode netd (ARP/ICMP/UDP)
SMP ACPI MADT parsing, LAPIC timer, IOAPIC routing, AP boot

Architecture Status

Architecture Status Notes
x86_64 Primary / fully tested ISO boot flow, full userland test suite
aarch64 Functional Boots to shell, core userland/process lifecycle functional, raw-kernel boot flow

Building

Prerequisites

  • GCC (x86_64 cross-compilation capable)
  • gcc-aarch64-linux-gnu (for ARCH=aarch64)
  • NASM
  • GNU LD
  • GRUB (grub-mkrescue)
  • xorriso
  • QEMU (qemu-system-x86_64, qemu-system-aarch64)

Build

make                         # Build x86_64 (default)
make ARCH=x86_64             # Build x86_64
make ARCH=aarch64            # Build aarch64
make clean ARCH=x86_64       # Clean x86_64 build artifacts
make clean ARCH=aarch64      # Clean aarch64 build artifacts

Run

make run ARCH=x86_64         # Boot x86_64 in QEMU
make run ARCH=aarch64        # Boot aarch64 in QEMU
make debug                   # Boot x86_64 with GDB stub
make test ARCH=x86_64        # Run x86_64 automated test suite
make test ARCH=aarch64       # Run aarch64 automated test suite
./scripts/test_all_arches.sh # Run both architectures

Testing

Automated

make test ARCH=x86_64
make test ARCH=aarch64

Runs all test suites in QEMU and reports pass/fail counts.

Manual Test Commands

Run these from the WayOS shell:

Command Tests Expected
hardtest Hardening + trust-boundary validation 21/21 pass
sectest Security + capability/filter matrix 16/16 pass
fstest Filesystem operations 13/13 pass
vmtest Virtual memory & CoW 7/7 pass
smptest SMP & multi-CPU 7/7 pass
ainfer all AI inference (Phase 3) all pass
ainfer4 all AI real compute (Phase 4) all pass
ainfer5 all AI hardening/lifecycle/ownership all pass
umemtest Unified memory integration all pass

Shell Commands

System

ps, uname, clear, uptime, smpinfo, kstats, lspci, memtier

Files

ls, cat, touch, write, rm, mkdir, cp, mv

Text

grep, wc, head, tail, echo, yes

Network

ping, netstat, nettest, fetch

AI

ainfer, ainfer4, mkmodel

Testing

hardtest, sectest, fstest, vmtest, smptest, shelltest, nettest

Diagnostics

klog, diagdump, version

Drivers (stubs)

virtio_blk, virtio_gpu

Directory Layout

wayos/
├── kernel/
│   ├── arch/x86_64/       # x86_64 architecture code
│   │   ├── boot/          # Multiboot2 header, boot.S, linker script
│   │   ├── cpu/           # GDT, IDT, TSS, ACPI, LAPIC, IOAPIC, SMP, per-CPU
│   │   ├── io/            # Serial, VGA, keyboard, PCI
│   │   ├── mm/            # Paging, early map
│   │   └── syscall/       # SYSCALL entry (assembly)
│   ├── arch/aarch64/      # aarch64 architecture code
│   │   ├── boot/          # EL2->EL1 setup, linker script
│   │   ├── cpu/           # Exceptions, GIC, timer, SMP, per-CPU
│   │   ├── io/            # UART, PCI stubs
│   │   ├── mm/            # Paging, early map
│   │   └── syscall/       # SVC entry (assembly)
│   ├── core/              # PMM, VMM, process, thread, scheduler, IPC, tmpfs, syscall
│   ├── lib/               # String, printf, panic, bitmap, rbtree
│   ├── mm/                # Unified memory (topology, placement, migration)
│   ├── net/               # VirtIO-net driver
│   └── ai/                # Tensor, accelerator, compute graph, model, inference
├── userland/
│   ├── init/              # Init process
│   ├── waysh/             # Shell
│   ├── servers/           # Console, AI daemon, netd
│   ├── libc/              # Minimal C library (stdio, stdlib, string, malloc)
│   └── coreutils/         # User commands
├── drivers/
│   ├── storage/           # VirtIO block (stub)
│   └── gpu/               # VirtIO GPU (stub)
├── tools/                 # Host tools (mkramfs)
├── scripts/               # QEMU run/debug/test scripts
└── iso/                   # GRUB config

Phase History

  1. Phase 1: Kernel foundation — boot, PMM, VMM, process/thread, scheduler, IPC, ramfs, ELF loading, shell, fork/exec, signals
  2. Phase 2: Unified memory — topology discovery, per-tier PMM, placement policy, page migration daemon, 2-tier simulation
  3. Phase 3: AI foundation — kernel tensors, simulated accelerators, compute graphs, model registry, inference scheduler, AI daemon, IPC-based inference
  4. Phase 4: Writable FS + networking — tmpfs (create/write/delete), CoW fork, MAP_SHARED, PCI enumeration, VirtIO-net driver, user-mode netd
  5. Phase AI-4: Real compute — tensor math (matmul/relu/softmax), graph execution, .waymodel file format, kernel inference queue, daemon scheduler
  6. Phase 5: User experience — FD rework, pipes, dup2, shell pipes & redirection, env vars, libc (malloc, FILE, snprintf), expanded coreutils
  7. Phase 6: SMP — ACPI/LAPIC/IOAPIC, per-CPU data, AP startup, SMP-safe kernel, spinlocks, schedule_finish pattern
  8. Phase 7: Security — capabilities, syscall filter, IPC access control, SMEP, user pointer validation
  9. Phase 7b: Hardening — 10 bug fixes from code review (buffer overflows, locks, page table teardown, scheduler cleanup)
  10. Phase 7c: Correctness — VMM overlap/partial unmap, parent-child wait, ELF/fork cleanup, TLB shootdown, copy_from/to_user, tensor overflow checks
  11. Phase 7d: Quality — .gitignore, MAX_CPUS warning, VirtIO stubs in build, kernel metrics (kstats), test infrastructure, documentation

QEMU Testing

qemu-system-x86_64 \
    -cdrom build/x86_64/wayos.iso \
    -m 256M \
    -serial stdio \
    -display none \
    -no-reboot \
    -smp 2 \
    -netdev user,id=net0 \
    -device virtio-net-pci,netdev=net0

# Recommended for AArch64 (includes DTB handoff setup for current ELF boot mode):
./scripts/qemu-run.sh aarch64

# Equivalent manual AArch64 flow:
qemu-system-aarch64 -M virt,dumpdtb=build/aarch64/qemu-virt.dtb -cpu cortex-a72 -m 256M -display none -S
qemu-system-aarch64 \
    -M virt \
    -cpu cortex-a72 \
    -m 256M \
    -serial stdio \
    -display none \
    -no-reboot \
    -smp 2 \
    -kernel build/aarch64/wayos.kernel \
    -device loader,file=build/aarch64/qemu-virt.dtb,addr=0x48000000,force-raw=on

About

AI-native OS kernel written from scratch in C and x86_64/aarch64 assembly — kernel-level tensor compute, capability-based security, SMP, TCP/IP, and 95 userland programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors