SchOS/kernel/fs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz 0e39e711f1 fpu: save each process's x87/SSE registers; keep the kernel off them
Nothing ever saved the FPU and SSE registers on a context switch.
musl's memcpy, the compiler's struct copies and any arithmetic on
doubles keep live values in %xmm, so two processes sharing a CPU wrote
over each other's: two shells counting in a loop on one processor took
a NULL+8 page fault within seconds, at a different rip every time. It
reproduces on kernels from before this week too -- it had always been
there, and every crash nobody could explain was a candidate.

sched() now fxsaves the process leaving the CPU and scheduler()
fxrstors the one arriving. A new process starts from the ABI's state
(FCW 0x37F, MXCSR 0x1F80), fork copies the parent's live registers,
exec resets them, and a signal handler's are put back by rt_sigreturn
so the interrupted code finds what it had.

The kernel was free to use %xmm too -- GCC vectorised struct copies
and memset into 153 instructions of it -- so an interrupt could
clobber the registers of the program it interrupted with no switch at
all. Kernel, lwIP and uACPI objects are built -mgeneral-regs-only now
and the image has none; cmd/ keeps SSE.

Checked under QEMU: three concurrent loops three times over, on 1 CPU
and on 4, no faults; before, every run faulted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
2026-10-23 15:02:01 +02:00
..
fat vfs: names up to 255 bytes and paths up to 4096, like Linux 2026-10-23 11:17:28 +02:00
schfs schfs: commit every 5 s, survive a full disk, mount up to 64 TiB 2026-10-23 12:20:05 +02:00
devfs.c fat: FAT12, FAT16 and FAT32 with long names, read and write 2026-10-23 09:33:35 +02:00
exec.c fpu: save each process's x87/SSE registers; keep the kernel off them 2026-10-23 15:02:01 +02:00
file.c fs: inode and open-file tables that grow, with a hash for iget 2026-10-23 13:39:14 +02:00
fs.c fs: inode and open-file tables that grow, with a hash for iget 2026-10-23 13:39:14 +02:00
log.c Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
pipe.c kmem: a slab allocator, and what the fixed tables actually cost 2026-09-22 09:32:06 +02:00
procfs.c sched: fair share by virtual runtime, with nice 2026-10-23 15:01:27 +02:00
sysfs.c hwreport: describe a machine onto a USB stick, from a Linux-style /sys 2026-10-23 12:54:11 +02:00