Skip to content

Commit fb9ee87

Browse files
ryanbreenRyan Breenclaude
committed
fix(page-fault): remove redundant CR2 read that panics on error
The page fault handler was reading CR2 twice: 1. Line 894: Cr2::read().unwrap_or(...) - handles errors gracefully 2. Line 923: Cr2::read().expect(...) - panics on error The second read is redundant and uses .expect() which causes panics when CR2::read() returns Err. This was causing CI failures at [80/138] SIGTERM kill test with KERNEL PANIC at interrupts.rs:923:37. Fix: Reuse the cr2 value already read safely on line 894 by converting it back to a VirtAddr instead of reading CR2 again. Co-Authored-By: Ryan Breen <ryanbreen@gmail.com> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5a9bc74 commit fb9ee87

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/src/interrupts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,8 @@ extern "x86-interrupt" fn page_fault_handler(
920920
// Increment preempt count on exception entry FIRST to avoid recursion
921921
crate::per_cpu::preempt_disable();
922922

923-
let accessed_addr = Cr2::read().expect("Failed to read accessed address from CR2");
923+
// Use the cr2 value we already read safely above (line 894)
924+
let accessed_addr = x86_64::VirtAddr::new(cr2);
924925

925926
// Skip raw serial output for potential CoW faults
926927
if !is_potential_cow {

0 commit comments

Comments
 (0)