Expand description
arm_vcpu
OS-neutral AArch64 vCPU core
English | 中文
§Introduction
arm_vcpu provides an OS-neutral AArch64 vCPU core. It owns EL2 guest entry/exit, guest register state, trap decode, and hardware virtualization register semantics. Host OS and VMM policy is supplied through ArmHostOps; AxVM integration lives in virtualization/axvm/src/arch/aarch64.
§Quick Start
§Installation
Add this crate to your Cargo.toml:
[dependencies]
arm_vcpu = "0.5.0"§Run Check and Test
# Enter the crate directory
cd virtualization/arm_vcpu
# Format code
cargo fmt --all
# Run the workspace clippy flow
cargo xtask clippy --package arm_vcpu
# Run host-runnable contract tests
cargo test -p arm_vcpu --test dependency_contract_test
# Build documentation
cargo doc --no-deps§Integration
§Example
use arm_vcpu::{ArmHostOps, ArmVcpu, ArmVcpuCreateConfig, ArmVcpuResult};
struct MyHost;
impl ArmHostOps for MyHost {
fn inject_virtual_interrupt(_vector: u32) -> ArmVcpuResult {
Ok(())
}
fn fetch_pending_host_irq() -> Option<usize> {
None
}
fn handle_current_host_irq() {}
}
fn build_vcpu() -> ArmVcpuResult<ArmVcpu<MyHost>> {
ArmVcpu::<MyHost>::new(0, 0, ArmVcpuCreateConfig::default())
}§Documentation
Generate and view API documentation:
cargo doc --no-deps --openOnline documentation: docs.rs/arm_vcpu
§Contributing
- Fork the repository and create a branch
- Run local format and checks
- Run local tests relevant to this crate
- Submit a PR and ensure CI passes
§License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Structs§
- ArmGuest
Phys Addr - Guest physical address.
- ArmHost
IrqConfig - Host interrupt-controller interface used by the assembly-only IRQ-exit transaction.
- ArmHost
IrqGuard - Proof that host IRQ delivery is masked on the current physical CPU.
- ArmNested
Paging Config - Stage-2 page table configuration selected by the embedding VMM.
- ArmPer
Cpu - Per-CPU AArch64 virtualization state.
- ArmSys
RegAddr - AArch64 system-register address encoding used by trapped MRS/MSR exits.
- ArmTimer
Context - Canonical writable state of one vCPU timer.
- ArmTimer
Snapshot - Immutable vCPU timer state sampled after a world switch.
- ArmTimer
VmConfig - Immutable generic-timer configuration shared by every vCPU in one VM.
- ArmVcpu
- A virtual CPU within a guest.
- ArmVcpu
Create Config - Configuration for creating a new
ArmVcpu. - ArmVcpu
Setup Config - Fixed EL2 setup policy for a new
ArmVcpu. - ArmVcpu
Timer - Timer state owned by one vCPU.
Enums§
- ArmAccess
Width - Width of a trapped guest memory access.
- ArmGic
CpuInterface Register - Common GICv3 CPU-interface register trapped by the vCPU core.
- ArmTimer
Kind - One architectural generic-timer instance owned by a vCPU.
- ArmVcpu
Error - Errors produced by the OS-neutral AArch64 vCPU core.
- ArmVm
Exit - VM-exit reason returned by the AArch64 vCPU core.
Constants§
- ARM_
VCPU_ HOST_ SP_ EL0_ OFFSET - Offset of [
HostRuntimeContext::sp_el0] withinArmVcpu. - ARM_
VCPU_ HOST_ STACK_ TOP_ OFFSET - Offset of [
HostRuntimeContext::stack_top] withinArmVcpu. - ARM_
VCPU_ TRAP_ FRAME_ SIZE - Size of the guest trap frame used by the EL2 entry/exit assembly.
Traits§
- ArmHost
Ops - Host operations required by AArch64 virtualization code.
- ArmTimer
Registers - Register operations required by a generic-timer world switch.
Functions§
- has_
hardware_ support - Returns whether the current platform supports the virtualization extension.
- max_
guest_ page_ table_ levels - Returns the maximum guest page-table levels supported by the current CPU.
- pa_bits
- Returns the physical-address width reported by the current CPU.
Type Aliases§
- ArmVcpu
Result - Result type returned by the OS-neutral AArch64 vCPU core.
- Trap
Frame - Context frame saved on an AArch64 guest exception.