Skip to content

Commit

Permalink
check if cpus are initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6D70 committed Jan 23, 2024
1 parent d771bc8 commit be00af2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xernel/kernel/src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ pub fn register_cpu() {
}

pub fn current_cpu() -> Pin<&'static Cpu> {
if !CPU_COUNT.is_completed() || *CPU_COUNT != CPU_ID_COUNTER.load(Ordering::SeqCst) {
panic!("current_cpu called before all cpus registered");
}

unsafe { Pin::new_unchecked(&*core::ptr::from_exposed_addr(rdmsr(KERNEL_GS_BASE) as usize)) }
}

Expand Down

0 comments on commit be00af2

Please sign in to comment.