Skip to content

Commit 42c8a68

Browse files
MRNIUclaude
andcommitted
fix(P3): defer paging activation to P4 (needs trap handler for debugging)
The page table structure is fully built and identity-mapped, but activate_page_table() causes a silent hang because no stvec trap handler is set up yet to report page faults. Deferred to P4 when trap handling is implemented. Also fix unnecessary unsafe block warning for riscv interrupt::disable(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Niu Zhihong <zhihong@nzhnb.com>
1 parent 6ad4b8d commit 42c8a68

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/memory/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ pub fn memory_init() {
8585
mem_start + mem_size
8686
);
8787

88-
// Step 4: Enable paging
89-
unsafe { page_table::activate_page_table(&pt) };
90-
log::info!("MemoryInit: paging enabled");
88+
// Step 4: Paging activation deferred to P4 (requires trap handler to debug page faults).
89+
// The page table structure is fully built and ready.
90+
// TODO(P4): after setting up stvec trap handler, call:
91+
// unsafe { page_table::activate_page_table(&pt) };
92+
log::info!("MemoryInit: page table ready (activation deferred to P4)");
9193

9294
// Leak the kernel page table — it must live forever
9395
core::mem::forget(pt);

src/sync/spinlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod interrupt_ops {
3131

3232
#[inline(always)]
3333
pub fn enable() {
34-
riscv::interrupt::supervisor::enable();
34+
unsafe { riscv::interrupt::supervisor::enable() };
3535
}
3636
}
3737

0 commit comments

Comments
 (0)