Skip to content

Commit

Permalink
Merge pull request #708 from hermit-os/clippy-missing_transmute_annot…
Browse files Browse the repository at this point in the history
…ations

fix(aarch64): clippy::missing_transmute_annotations
  • Loading branch information
mkroening authored Jun 13, 2024
2 parents 9ba3c9d + 5705181 commit 0ef8580
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,23 @@ pub fn virt_to_phys(
// - the memory location of the pagetable is not altered by hermit.
// - Our indices can't be larger than 512, so we stay in the borders of the page.
// - We are page_aligned, and thus also PageTableEntry aligned.
let mut pagetable: &[PageTableEntry] =
unsafe { std::mem::transmute(mem.slice_at(pagetable_l0, PAGE_SIZE).unwrap()) };
let mut pagetable: &[PageTableEntry] = unsafe {
std::mem::transmute::<&[u8], &[PageTableEntry]>(
mem.slice_at(pagetable_l0, PAGE_SIZE).unwrap(),
)
};
// TODO: Depending on the virtual address length and granule (defined in TCR register by TG and TxSZ), we could reduce the number of pagetable walks. Hermit doesn't do this at the moment.
for level in 0..3 {
let table_index =
(addr.as_u64() >> PAGE_BITS >> ((3 - level) * PAGE_MAP_BITS) & PAGE_MAP_MASK) as usize;
let pte = PageTableEntry::from(pagetable[table_index]);
// TODO: We could stop here if we have a "Block Entry" (ARM equivalent to huge page). Currently not supported.

pagetable = unsafe { std::mem::transmute(mem.slice_at(pte.address(), PAGE_SIZE).unwrap()) };
pagetable = unsafe {
std::mem::transmute::<&[u8], &[PageTableEntry]>(
mem.slice_at(pte.address(), PAGE_SIZE).unwrap(),
)
};
}
let table_index = (addr.as_u64() >> PAGE_BITS & PAGE_MAP_MASK) as usize;
let pte = PageTableEntry::from(pagetable[table_index]);
Expand Down

0 comments on commit 0ef8580

Please sign in to comment.