Skip to content

Commit

Permalink
fix(entry): only set boot info globals on first CPU core
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Oct 20, 2024
1 parent 86e6121 commit 460202d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/arch/aarch64/kernel/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ pub unsafe extern "C" fn _start(boot_info: &'static RawBootInfo, cpu_id: u32) ->
#[inline(never)]
#[no_mangle]
unsafe extern "C" fn pre_init(boot_info: &'static RawBootInfo, cpu_id: u32) -> ! {
unsafe {
RAW_BOOT_INFO = Some(boot_info);
BOOT_INFO = Some(BootInfo::from(*boot_info));
}

// set exception table
unsafe {
asm!(
Expand All @@ -66,6 +61,10 @@ unsafe extern "C" fn pre_init(boot_info: &'static RawBootInfo, cpu_id: u32) -> !
}

if cpu_id == 0 {
unsafe {
RAW_BOOT_INFO = Some(boot_info);
BOOT_INFO = Some(BootInfo::from(*boot_info));
}
crate::boot_processor_main()
} else {
#[cfg(not(feature = "smp"))]
Expand Down
10 changes: 5 additions & 5 deletions src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ unsafe extern "C" fn pre_init(boot_info: &'static RawBootInfo, cpu_id: u32) -> !
cr0_write(cr0);
}

unsafe {
RAW_BOOT_INFO = Some(boot_info);
BOOT_INFO = Some(BootInfo::from(*boot_info));
}

if cpu_id == 0 {
unsafe {
RAW_BOOT_INFO = Some(boot_info);
BOOT_INFO = Some(BootInfo::from(*boot_info));
}

crate::boot_processor_main()
} else {
#[cfg(not(feature = "smp"))]
Expand Down

0 comments on commit 460202d

Please sign in to comment.