kernel: replace todo!() in page fault handler with SIGSEGV delivery

Two todo!() calls in the user-space page fault correction path
(memory/mod.rs:1238,1240) were boot-time bombs:

  Err(PfError::Oom) => todo!("oom")
  Err(PfError::NonfatalInternalError) => todo!()

Both fire when try_correcting_page_tables fails during a
correctable page fault. The OOM case triggers under memory
pressure; the NonfatalInternalError case triggers on internal
consistency issues (the name says 'nonfatal').

The previous todo!() panicked the kernel, taking down the whole
system instead of just the faulting process. The fix delivers
SIGSEGV to the faulting process (by falling through to the
existing Err(Segv) path) and logs a warning. This matches the
behaviour of the adjacent Segv/RecursionLimitExceeded arm.

For the OOM case specifically: Linux would invoke the OOM killer
here. Red Bear does not yet have an OOM killer — SIGSEGV is
strictly better than kernel panic. A future round can add proper
OOM handling.

Part of the LG Gram Round 3 stub sweep.
This commit is contained in:
2026-07-26 18:06:57 +09:00
parent 198e59c474
commit bb4a97ec63
+14 -2
View File
@@ -1235,9 +1235,21 @@ pub fn page_fault_handler(
let mut token = unsafe { CleanLockToken::new() };
match context::memory::try_correcting_page_tables(faulting_page, mode, &mut token) {
Ok(()) => return Ok(()),
Err(PfError::Oom) => todo!("oom"),
Err(PfError::Oom) => {
// Kernel could not allocate a frame to correct the fault.
// Linux would invoke the OOM killer here; Red Bear does not
// yet have one. Deliver SIGSEGV to the faulting process
// rather than panicking the kernel (the previous todo!()
// was a boot-time bomb on memory-pressure systems).
warn!("memory: OOM during page fault correction, delivering SIGSEGV");
}
Err(PfError::Segv | PfError::RecursionLimitExceeded) => (),
Err(PfError::NonfatalInternalError) => todo!(),
Err(PfError::NonfatalInternalError) => {
// Internal consistency issue inside try_correcting_page_tables.
// The name says nonfatal — log and deliver SIGSEGV rather
// than panicking the kernel.
warn!("memory: nonfatal internal error during page fault correction, delivering SIGSEGV");
}
}
}