Use alloc_zeroed when allocating FX.
This commit is contained in:
@@ -80,13 +80,11 @@ impl ContextList {
|
||||
{
|
||||
let mut context = context_lock.write();
|
||||
let mut fx = unsafe {
|
||||
let ptr = crate::ALLOCATOR.alloc(Layout::from_size_align_unchecked(1024, 16)) as *mut [u8; 1024];
|
||||
// TODO: Alignment must match, the following can be UB. Use AlignedBox.
|
||||
let ptr = crate::ALLOCATOR.alloc_zeroed(Layout::from_size_align_unchecked(1024, 16)) as *mut [u8; 1024];
|
||||
if ptr.is_null() { return Err(Error::new(ENOMEM)); }
|
||||
Box::from_raw(ptr)
|
||||
};
|
||||
for b in fx.iter_mut() {
|
||||
*b = 0;
|
||||
}
|
||||
let mut stack = vec![0; 65_536].into_boxed_slice();
|
||||
let offset = stack.len() - mem::size_of::<usize>();
|
||||
|
||||
|
||||
@@ -57,10 +57,12 @@ pub fn init() {
|
||||
let mut contexts = contexts_mut();
|
||||
let context_lock = contexts.new_context().expect("could not initialize first context");
|
||||
let mut context = context_lock.write();
|
||||
let mut fx = unsafe { Box::from_raw(crate::ALLOCATOR.alloc(Layout::from_size_align_unchecked(1024, 16)) as *mut [u8; 1024]) };
|
||||
for b in fx.iter_mut() {
|
||||
*b = 0;
|
||||
}
|
||||
let fx = unsafe {
|
||||
// TODO: Alignment must match, the following can be UB. Use AlignedBox.
|
||||
let ptr = crate::ALLOCATOR.alloc_zeroed(Layout::from_size_align_unchecked(1024, 16)) as *mut [u8; 1024];
|
||||
assert!(!ptr.is_null(), "failed to allocate FX to kmain!");
|
||||
Box::from_raw(ptr)
|
||||
};
|
||||
|
||||
context.arch.set_fx(fx.as_ptr() as usize);
|
||||
context.kfx = Some(fx);
|
||||
|
||||
Reference in New Issue
Block a user