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).