aarch64-paging

aarch64-pagingクレートは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でProtected VM Firmwareのために利用されています。
  • この例は本物のハードウェアかQEMUを必要とするので、簡単には実行できません。