Skip to content

fix(mm): kernel-space page fault detection + interrupt stack for guard page

StellaOS requested to merge fix/kernel-page-fault-guard into main
  • kernel_callback: detect kernel-space StorePageFault/LoadPageFault/ StoreFault (previously only LoadFault was checked), panic with stval and sepc instead of silent triple-fault or misrouted SIGSEGV
  • _interrupt_for_arch: before user-space COW/lazy-alloc, check for kernel-space faults and guard page hits -> clear panic diagnostics
  • KernelStack: expose guard_bottom/guard_top and guard position helper
  • kernelvec S->S path: replace "csrr sp, sscratch" with interrupt stack (static 8KB array in .bss, accessed via la/li/add) so that trap handler can run even when task sp has entered the guard page
  • Verified in QEMU: sp-in-guard-page store now panics with "kernel StorePageFault at 0xffffffffffffa008" + backtrace instead of silent triple-fault hang

Adds KERNEL_STACK_GUARD_SIZE, KERNEL_INTR_STACK_SIZE constants.

Merge request reports