Skip to content

Commit

Permalink
fix(arch): unused_unsafe
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 Oct 22, 2024
1 parent b4d2f5a commit c2763c0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const PT_MEM_CD: u64 = 0x70F;
const PT_SELF: u64 = 1 << 55;

pub unsafe fn get_memory(_memory_size: u64) -> u64 {
(unsafe { ptr::addr_of!(loader_end) }.addr() as u64).align_up(LargePageSize::SIZE as u64)
(ptr::addr_of!(loader_end).addr() as u64).align_up(LargePageSize::SIZE as u64)
}

pub fn find_kernel() -> &'static [u8] {
Expand Down Expand Up @@ -124,21 +124,21 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
for i in pgt_slice.iter_mut() {
*i = 0;
}
pgt_slice[0] = unsafe { ptr::addr_of!(l1_pgtable) }.addr() as u64 + PT_PT;
pgt_slice[511] = unsafe { ptr::addr_of!(l0_pgtable) }.addr() as u64 + PT_PT + PT_SELF;
pgt_slice[0] = ptr::addr_of!(l1_pgtable).addr() as u64 + PT_PT;
pgt_slice[511] = ptr::addr_of!(l0_pgtable).addr() as u64 + PT_PT + PT_SELF;

let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l1_pgtable), 512) };
for i in pgt_slice.iter_mut() {
*i = 0;
}
pgt_slice[0] = unsafe { ptr::addr_of!(l2_pgtable) }.addr() as u64 + PT_PT;
pgt_slice[1] = unsafe { ptr::addr_of!(l2k_pgtable) }.addr() as u64 + PT_PT;
pgt_slice[0] = ptr::addr_of!(l2_pgtable).addr() as u64 + PT_PT;
pgt_slice[1] = ptr::addr_of!(l2k_pgtable).addr() as u64 + PT_PT;

let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l2_pgtable), 512) };
for i in pgt_slice.iter_mut() {
*i = 0;
}
pgt_slice[0] = unsafe { ptr::addr_of!(l3_pgtable) }.addr() as u64 + PT_PT;
pgt_slice[0] = ptr::addr_of!(l3_pgtable).addr() as u64 + PT_PT;

let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l3_pgtable), 512) };
for i in pgt_slice.iter_mut() {
Expand All @@ -152,7 +152,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
*i = 0;
}
for (i, pgt_slice) in pgt_slice.iter_mut().enumerate().take(10) {
*pgt_slice = unsafe { ptr::addr_of!(L0mib_pgtable) }.addr() as u64
*pgt_slice = ptr::addr_of!(L0mib_pgtable).addr() as u64
+ (i * BasePageSize::SIZE) as u64
+ PT_PT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/riscv64/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn get_fdt() -> Fdt<'static> {

pub fn get_stack_ptr() -> *mut u8 {
// SAFETY: We only create a pointer here
let stack_top = unsafe { ptr::addr_of_mut!(STACK) };
let stack_top = ptr::addr_of_mut!(STACK);
// SAFETY: Pointing directly past the object is allowed
let stack_bottom = unsafe { stack_top.add(1) };
stack_bottom.cast::<u8>()
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/firecracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn find_kernel() -> &'static [u8] {
let elf_start = ramdisk_address as usize;
let elf_len = ramdisk_size as usize;

let free_memory_address = unsafe { ptr::addr_of!(loader_end) }
let free_memory_address = ptr::addr_of!(loader_end)
.addr()
.align_up(Size2MiB::SIZE as usize);
// TODO: Workaround for https://github.com/hermitcore/loader/issues/96
Expand Down Expand Up @@ -123,7 +123,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {

// determine boot stack address
let new_stack =
(unsafe { ptr::addr_of!(loader_end) }.addr() + 0x1000).align_up(Size4KiB::SIZE as usize);
(ptr::addr_of!(loader_end).addr() + 0x1000).align_up(Size4KiB::SIZE as usize);

let cmdline_ptr = unsafe {
*(sptr::from_exposed_addr(boot_params + LINUX_SETUP_HEADER_OFFSET + CMD_LINE_PTR_OFFSET))
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/multiboot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() };

// determine boot stack address
let mut new_stack = unsafe { ptr::addr_of!(loader_end) }
let mut new_stack = ptr::addr_of!(loader_end)
.addr()
.align_up(Size4KiB::SIZE as usize);

Expand Down

0 comments on commit c2763c0

Please sign in to comment.