FABRIC.md item 4.5d Finding 4: lidt()'s inline asm used a register-only
("r") constraint on the idtr pointer, never telling GCC the asm
dereferences the pointee. At -O2 this let the compiler treat the
256-entry idt[] population loop and idtr_desc's field writes as dead
stores and eliminate them entirely, loading IDTR from uninitialized
stack instead of the real table -- a #GP on the first APIC timer tick
that happened to land on garbage. Same bug class as the earlier
muldiv64 fix (b43e51a): an inline-asm constraint too weak for what the
asm actually touches, invisible at -O0, live at -O2.
Fixed by switching to a memory operand ("m"(*idtr_desc)), matching how
Linux's own load_idt() is written. aarch64/riscv64 checked for the same
pattern -- neither has it, both install their vector/trap tables
entirely in hand-written .S.
Verified: all three architectures boot clean to ok>, POST Failed: 0,
identical dict-hashes across all three under -O2, zero new warnings
vs an -O0 baseline (amd64 3040/3040, aarch64 3041/3041 serial,
riscv64 3037/3037). -O2/-U_FORTIFY_SOURCE landed permanently in
COMMON_CFLAGS.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
src/starkernel/
LithosAnanke — the bare-metal UEFI kernel that boots StarForth directly on
hardware (amd64/aarch64/riscv64). Built only via Makefile.starkernel; the
only valid acceptance test is the three-arch QEMU boot (see
.claude/CLAUDE.md), never make test.
kernel_main.c— kernel entry point, driving the boot milestones (console init, PMM, VMM, interrupts, timers, kmalloc heap, VM bootstrap).repl.c— kernel REPL.doe_log.c— kernel-side DoE (Design of Experiments) metrics logging.
Subdirectories:
arch/{amd64,aarch64,riscv64}/— per-architecture support (APIC/GIC/ PLIC interrupt controller, timers, boot/ISR assembly).boot/— UEFI loader, ELF loading, kernel command-line parsing.capsule/— capsule birth/run/load/validate pipeline.hal/— hardware-abstraction-layer implementation (console, framebuffer, VT100, memory, host services).hash/— XXHash64 content-addressing implementation.math/— kernel-build Q48.16 fixed-point arithmetic.memory/— physical/virtual memory managers and the kernel heap.pci/— PCI bus enumeration.virtio/— VirtIO block device driver.vm/— kernel VM subsystem (bootstrap, core interpreter, parity logging, capsule arena).
See include/starkernel/README.md for the corresponding headers.