Skip to content

Userspace

kazah-png edited this page Jul 6, 2026 · 10 revisions

Userspace

Ring-3 ELF64 loading with full address-space isolation.

See also: Syscalls, Process Management, Security, Architecture

ELF loader (elf.c)

Validates ELF64 magic, parses PT_LOAD segments, maps code/data at p_vaddr, allocates stack at 0xD0000000.

Process isolation

  • Private PML4 per process (no identity mapping in user tables)
  • NX bit on user stack and data pages
  • SMEP (optional): kernel can't execute user pages
  • Kernel entry at PML4[511] cloned from master kernel PML4

libc (user/libc.c)

Minimal C library: printf, snprintf, malloc, free, file I/O wrappers via Syscalls.

Nyx C runtime (user/nyxrt.h, user/nyxrt.c)

Nyx C is a Go/Zig-inspired typed subset of C that transpiles to C and links against the nyxrt runtime. The runtime provides:

  • Types: nyx_str, nyx_slice, nyx_result, fixed-width ints
  • Syscall ABI: __nyx_syscall6 for all ring-3 syscalls
  • String interpolation: __nyx_fmt_begin/_str/_i64 for "{var}" syntax

crt0 (user/crt0.asm)

Assembly entry that extracts argc/argv from stack, calls main(), then exit().

Available programs

Binary Description
hello.elf Minimal "Hello World" in assembly
init.elf Syscall regression test (getpid, malloc, file I/O)
spin.elf Spin loop for multitasking testing
fdleak.elf Tests fd cleanup on process exit
hello_nyx.elf Primer programa Nyx C — write + getpid + string interpolation

Clone this wiki locally