Fix CR3 handling in interrupt/syscall paths using per-CPU data #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
kernel_cr3andsaved_process_cr3fields to PerCpuData structRoot Cause
The kernel was triple faulting because:
per_cpu::init()stored the bootloader's CR3 (0x101000) as kernel_cr3build_master_kernel_pml4()created a new master PML4 at 0x552000Test plan
cargo run -p xtask -- boot-stagespasses 36/40 stages🤖 Generated with Claude Code
Note
Use per-CPU
kernel_cr3/saved_process_cr3for CR3 switching/restoration in interrupts/syscalls, updatekernel_cr3after master PML4, fixSyscallFramelayout, and clearnext_cr3before CR3 switch.gs:[80]; read kernel CR3 fromgs:[72](removes hardcoded0x101000).next_cr3atgs:[64]before switching CR3; if no context switch, restore saved process CR3; ensure properswapgssequencing.kernel/src/per_cpu.rs):PerCpuDatawithkernel_cr3(offset 72) andsaved_process_cr3(offset 80) plus constants; update size/asserts.kernel_cr3from current CR3 ininit(); addget_kernel_cr3/set_kernel_cr3accessors.kernel/src/memory/mod.rs):kernel_cr3.kernel/src/syscall/handler.rs):SyscallFramefields to match push order (r15atRSP+0…raxatRSP+112).Written by Cursor Bugbot for commit 3962add. This will update automatically on new commits. Configure here.