aarch64-paging
aarch64-paging Crate 可用來根據 AArch64 虛擬記憶體系統架構,建立分頁表。
use aarch64_paging::{
idmap::IdMap,
paging::{Attributes, MemoryRegion},
};
const ASID: usize = 1;
const ROOT_LEVEL: usize = 1;
// Create a new page table with identity mapping.
let mut idmap = IdMap::new(ASID, ROOT_LEVEL);
// Map a 2 MiB region of memory as read-only.
idmap.map_range(
&MemoryRegion::new(0x80200000, 0x80400000),
Attributes::NORMAL | Attributes::NON_GLOBAL | Attributes::READ_ONLY,
).unwrap();
// Set `TTBR0_EL1` to activate the page table.
idmap.activate();
- 目前僅支援 EL1,但應該很容易新增其他例外狀況層級的支援功能。
- 這是用於 Android 中的受保護 VM 韌體。
- 執行這個範例並不容易,因為需要在實際硬體上執行,或是使用 QEMU。