A Virtual Generic Interrupt Controller (VGIC) implementation for ARM architecture, designed for the ArceOS hypervisor ecosystem.
This crate provides a comprehensive implementation of ARM's Virtual Generic Interrupt Controller (VGIC), enabling virtualized interrupt management for guest operating systems running under a hypervisor. The VGIC emulates the behavior of ARM's Generic Interrupt Controller (GIC) hardware, allowing multiple virtual machines to share the underlying interrupt controller while maintaining isolation.
- GICv2 Support: Complete implementation of GIC version 2 virtualization
- GICv3 Support: Optional GIC version 3 support (enabled with
vgicv3feature) - Interrupt Types: Support for all ARM interrupt types:
- Software Generated Interrupts (SGI) - IDs 0-15
- Private Peripheral Interrupts (PPI) - IDs 16-31
- Shared Peripheral Interrupts (SPI) - IDs 32-511
- Virtual Timer: Virtualized timer implementation with system register emulation
- Memory-Mapped I/O: Complete MMIO interface emulation for guest access
- Multi-VCPU Support: Proper interrupt routing and distribution across virtual CPUs
The crate is organized into several key components:
- VGIC (
vgic.rs): Main VGIC controller implementation - VGICD (
vgicd.rs): Virtual GIC Distributor for interrupt routing - Interrupts (
interrupt.rs): Interrupt state management and operations - Registers (
registers.rs): GIC register definitions and access - List Registers (
list_register.rs): Hardware list register management
use arm_vgic::Vgic;
// Create a new VGIC instance
let vgic = Vgic::new();
// The VGIC implements BaseDeviceOps for MMIO handling
// Register it with your hypervisor's device management systemEnable GICv3 support:
[dependencies]
arm_vgic = { version = "*", features = ["vgicv3"] }This crate is designed to integrate seamlessly with the ArceOS hypervisor ecosystem:
- Uses
axdevice_basefor device abstraction - Integrates with
axaddrspacefor memory management - Leverages
axvisor_apifor hypervisor operations
The VGIC exposes the following memory-mapped regions to guest VMs:
- GIC Distributor (GICD):
0x0800_0000-0x0800_FFFF(64KB) - GIC CPU Interface (GICC):
0x0801_0000-0x0801_FFFF(64KB) - GICv3 Redistributor (GICR):
0x0802_0000+(128KB per CPU)
GICD_CTLR- Distributor Control RegisterGICD_TYPER- Interrupt Controller Type RegisterGICD_IIDR- Distributor Implementer Identification RegisterGICD_IGROUPR- Interrupt Group RegistersGICD_ISENABLER- Interrupt Set-Enable RegistersGICD_ICENABLER- Interrupt Clear-Enable RegistersGICD_ISPENDR- Interrupt Set-Pending RegistersGICD_ICPENDR- Interrupt Clear-Pending RegistersGICD_ISACTIVER- Interrupt Set-Active RegistersGICD_ICACTIVER- Interrupt Clear-Active RegistersGICD_IPRIORITYR- Interrupt Priority RegistersGICD_ITARGETSR- Interrupt Processor Targets RegistersGICD_ICFGR- Interrupt Configuration RegistersGICD_SGIR- Software Generated Interrupt Register
GICC_CTLR- CPU Interface Control RegisterGICC_PMR- Interrupt Priority Mask RegisterGICC_BPR- Binary Point RegisterGICC_IAR- Interrupt Acknowledge RegisterGICC_EOIR- End Of Interrupt RegisterGICC_RPR- Running Priority RegisterGICC_HPPIR- Highest Priority Pending Interrupt Register
axdevice_base: Device abstraction layeraxaddrspace: Address space managementaxvisor_api: Hypervisor API and operations
- Primary:
aarch64-unknown-none-softfloat - Architecture: ARM64/AArch64 only
- Hypervisor: ArceOS hypervisor
// Interrupt injection is handled through the ArceOS VMM API
use axvisor_api::vmm::InterruptVector;
// Hardware interrupt injection (handled by hypervisor)
let vector = InterruptVector::new(42); // IRQ 42
// The VGIC will handle the virtualization automaticallyuse arm_vgic::vtimer::get_sysreg_device;
// Get virtual timer system register devices
let timer_devices = get_sysreg_device();
// Register with your system register handler
for device in timer_devices {
// Register device with hypervisor's system register emulation
}# Run tests
cargo test
# Run tests with all features
cargo test --all-featuresThis project is part of the ArceOS hypervisor ecosystem. Contributions should follow the ArceOS project guidelines and maintain compatibility with the broader ecosystem.
- axdevice_crates - Device abstraction layer
- axvisor_api - Hypervisor API definitions
- axaddrspace - Address space management