| Crates.io | axaddrspace |
| lib.rs | axaddrspace |
| version | 0.1.2 |
| created_at | 2025-07-29 02:33:39.731246+00 |
| updated_at | 2025-09-16 14:54:17.85699+00 |
| description | ArceOS-Hypervisor guest address space management module |
| homepage | |
| repository | https://github.com/arceos-hypervisor/axaddrspace |
| max_upload_size | |
| id | 1771804 |
| size | 102,132 |
ArceOS-Hypervisor guest VM address space management module
axaddrspace is a core component of the ArceOS-Hypervisor project that provides guest virtual machine address space management capabilities. The crate implements nested page tables and address translation for hypervisor environments, supporting multiple architectures including x86_64, AArch64, and RISC-V.
hfence.vvma)The AddrSpace struct provides:
Two types of mapping backends are supported:
Architecture-specific nested page table implementations:
ExtendedPageTable with EPT entriesAdd this to your Cargo.toml:
[dependencies]
axaddrspace = "0.1.0"
use axaddrspace::{AddrSpace, MappingFlags, GuestPhysAddr};
use page_table_multiarch::PagingHandler;
// Create a new address space
let mut addr_space = AddrSpace::<YourPagingHandler>::new_empty(
GuestPhysAddr::from(0x1000_0000),
0x1000_0000, // 256MB
)?;
// Create a linear mapping
addr_space.map_linear(
GuestPhysAddr::from(0x1000_0000), // Guest virtual address
PhysAddr::from(0x8000_0000), // Host physical address
0x10_0000, // 1MB
MappingFlags::READ | MappingFlags::WRITE,
)?;
// Handle a nested page fault
let fault_handled = addr_space.handle_page_fault(
GuestPhysAddr::from(0x1000_1000),
MappingFlags::READ,
);
Implement the AxMmHal trait for your platform:
use axaddrspace::{AxMmHal, HostPhysAddr, HostVirtAddr};
struct MyHal;
impl AxMmHal for MyHal {
fn alloc_frame() -> Option<HostPhysAddr> {
// Your frame allocation implementation
}
fn dealloc_frame(paddr: HostPhysAddr) {
// Your frame deallocation implementation
}
fn phys_to_virt(paddr: HostPhysAddr) -> HostVirtAddr {
// Your physical to virtual address conversion
}
fn virt_to_phys(vaddr: HostVirtAddr) -> HostPhysAddr {
// Your virtual to physical address conversion
}
}
arm-el2: Enable AArch64 EL2 support (default)default: Includes arm-el2 featureContributions are welcome! Please feel free to submit a Pull Request.