Skip to content

Commit

Permalink
fix(x86_64): allocate IST from heap
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed May 2, 2024
1 parent 589e8a9 commit c338f95
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/arch/x86_64/kernel/gdt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use alloc::alloc::alloc;
use alloc::boxed::Box;
use core::alloc::Layout;
use core::sync::atomic::Ordering;

use x86_64::instructions::tables;
Expand Down Expand Up @@ -47,9 +49,11 @@ pub fn add_current_core() {
BasePageSize::SIZE as usize
};

let ist = crate::mm::allocate(sz, true);
let ist_start = ist.as_u64() + sz as u64 - TaskStacks::MARKER_SIZE as u64;
tss.interrupt_stack_table[i] = VirtAddr::new(ist_start);
let layout = Layout::from_size_align(sz, BasePageSize::SIZE as usize).unwrap();
let ist = unsafe { alloc(layout) };
assert!(!ist.is_null());
let ist_start = unsafe { ist.add(sz - TaskStacks::MARKER_SIZE) };
tss.interrupt_stack_table[i] = VirtAddr::from_ptr(ist_start);
}

CoreLocal::get().tss.set(tss);
Expand Down

0 comments on commit c338f95

Please sign in to comment.