Add unsafe with caller-upheld comments

This commit is contained in:
Ruihan Li
2025-05-07 23:47:32 +08:00
committed by Junyang Zhang
parent 31dbae5330
commit 619814e652
6 changed files with 31 additions and 12 deletions

View File

@ -109,7 +109,8 @@ impl<E: PageTableEntryTrait, C: PagingConstsTrait> PageTableNode<E, C> {
return;
}
activate_page_table(self.clone().into_raw(), CachePolicy::Writeback);
// SAFETY: The safety is upheld by the caller.
unsafe { activate_page_table(self.clone().into_raw(), CachePolicy::Writeback) };
// Restore and drop the last activated page table.
// SAFETY: The physical address is valid and points to a forgotten page table node.
@ -123,7 +124,8 @@ impl<E: PageTableEntryTrait, C: PagingConstsTrait> PageTableNode<E, C> {
pub(super) unsafe fn first_activate(&self) {
use crate::{arch::mm::activate_page_table, mm::CachePolicy};
activate_page_table(self.clone().into_raw(), CachePolicy::Writeback);
// SAFETY: The safety is upheld by the caller.
unsafe { activate_page_table(self.clone().into_raw(), CachePolicy::Writeback) };
}
}