Skip to main content

Module syscall

Module syscall 

Source
Expand description

SYSCALL/SYSRET interface for Strat9-OS

Configures the x86_64 SYSCALL/SYSRET MSRs and provides the naked assembly entry point that bridges Ring 3 → Ring 0 → Rust dispatcher.

§Per-CPU design (SWAPGS + GS-base)

SYSCALL entry uses SWAPGS to switch GS base to a per-CPU block that stores the kernel RSP and temporary user RSP. This enables SMP-safe SYSCALL entry without a global KERNEL_RSP.

§Register convention on SYSCALL entry

CPU sets: RCX = user RIP, R11 = user RFLAGS, IF cleared via FMASK. Userspace passes: RAX = syscall number, RDI/RSI/RDX/R10/R8/R9 = args 1-6.

Constants§

EFER_SCE 🔒
EFER bit: System Call Extensions
FMASK_VALUE 🔒
FMASK: Clear IF (0x200), DF (0x400), TF (0x100) on SYSCALL entry. This ensures interrupts are disabled and direction flag is clear.
IA32_EFER 🔒
MSR addresses
IA32_FMASK 🔒
IA32_LSTAR 🔒
IA32_STAR 🔒

Functions§

init
Initialize the SYSCALL/SYSRET MSRs.
set_kernel_rsp
Update the kernel RSP used by the SYSCALL entry point.
syscall_entry 🔒
The SYSCALL entry point (naked function).