mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +00:00
Special treat VM Space clearing
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
fda05e9e23
commit
c34706603a
@ -92,6 +92,26 @@ impl PageTable<UserMode> {
|
||||
self.root.activate();
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear the page table.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that:
|
||||
/// 1. No other cursors are accessing the page table.
|
||||
/// 2. No other CPUs activates the page table.
|
||||
pub(in crate::mm) unsafe fn clear(&self) {
|
||||
let mut root_node = self.root.clone_shallow().lock();
|
||||
const NR_PTES_PER_NODE: usize = nr_subpage_per_huge::<PagingConsts>();
|
||||
for i in 0..NR_PTES_PER_NODE / 2 {
|
||||
let root_entry = root_node.entry(i);
|
||||
if !root_entry.is_none() {
|
||||
let old = root_entry.replace(Child::None);
|
||||
// Since no others are accessing the old child, dropping it is fine.
|
||||
drop(old);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PageTable<KernelMode> {
|
||||
|
Reference in New Issue
Block a user