]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: FPU/SSE context save/restore for correct floating-point across context switches
authorTulio A M Mendes <[email protected]>
Mon, 16 Feb 2026 00:45:17 +0000 (21:45 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 16 Feb 2026 00:45:17 +0000 (21:45 -0300)
commitcf204443c15487936b43da28f25986492dcf05e3
treedfca52c9f6e3751e74381824b9e490592c78e30d
parentc01718d9b59a3d07ed01a71b20fcc91fbdb126d7
feat: FPU/SSE context save/restore for correct floating-point across context switches

- arch_fpu_init(): initialize x87 FPU (CR0.NE, clear EM/TS), enable OSFXSR if FXSR supported
- arch_fpu_save/restore: FXSAVE/FXRSTOR (or FSAVE/FRSTOR fallback) per process
- FPU state (512B) added to struct process, initialized for new processes
- fork/clone inherit parent FPU state; kernel threads get clean state
- schedule() saves prev FPU state before context_switch, restores next after
- Heap header padded 8->16 bytes for 16-byte aligned kmalloc (FXSAVE requirement)
- Added -mno-sse -mno-mmx to kernel ARCH_CFLAGS (prevent SSE in kernel code)
- Weak stubs in src/kernel/fpu.c for non-x86 architectures
Makefile
include/arch_fpu.h [new file with mode: 0644]
include/process.h
src/arch/x86/fpu.c [new file with mode: 0644]
src/kernel/fpu.c [new file with mode: 0644]
src/kernel/main.c
src/kernel/scheduler.c
src/mm/heap.c