Optimize the page table implementation using the frame metadata

This PR also refactored the page table cursor, distinguishing `Cursor` from `CursorMut`, and split
a lot of functions to reduce dynamic condition checking.

There are also other sanitizations performed, including refactoring PTE's `is_huge` API to `is_last`,
hardening tracked mapping checks, and making `VmFrame` any size.
This commit is contained in:
Zhang Junyang
2024-05-16 16:42:36 +00:00
committed by Tate, Hongliang Tian
parent 69d464fc6b
commit 141fbeaf0c
15 changed files with 1148 additions and 839 deletions

View File

@ -138,7 +138,7 @@ impl RootTable {
if bus_entry.is_present() {
warn!("IOMMU: Overwritting the existing device page table");
}
let address = page_table.root_paddr();
let address = unsafe { page_table.root_paddr() };
context_table.page_tables.insert(address, page_table);
let entry = ContextEntry(address as u128 | 1 | 0x1_0000_0000_0000_0000);
context_table
@ -262,7 +262,7 @@ impl ContextTable {
if !bus_entry.is_present() {
let table = PageTable::<DeviceMode, PageTableEntry, PagingConsts>::empty();
let address = table.root_paddr();
let address = unsafe { table.root_paddr() };
self.page_tables.insert(address, table);
let entry = ContextEntry(address as u128 | 3 | 0x1_0000_0000_0000_0000);
self.entries_frame