|
1 | 1 | # arm_vcpu |
2 | 2 |
|
3 | 3 | [](https://github.com/arceos-hypervisor/arm_vcpu/actions/workflows/ci.yml) |
| 4 | +[](https://crates.io/crates/arm_vcpu) |
| 5 | +[] |
| 6 | + |
| 7 | +AArch64 virtual CPU (vCPU) implementation for hypervisors. This crate provides the core vCPU structure and virtualization-related interface support specifically designed for the AArch64 architecture. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- 🔧 **Complete vCPU Implementation**: Full virtual CPU structure for AArch64 guests |
| 12 | +- 🚀 **Exception Handling**: Comprehensive trap and exception handling for virtualized environments |
| 13 | +- 🎯 **Hardware Virtualization**: Support for ARMv8 virtualization extensions (EL2) |
| 14 | +- 🔒 **Security**: SMC (Secure Monitor Call) handling and secure virtualization |
| 15 | +- 📊 **Per-CPU Support**: Efficient per-CPU data structures and management |
| 16 | +- 🛠️ **No-std Compatible**: Works in bare-metal and embedded environments |
| 17 | + |
| 18 | +## Architecture Overview |
| 19 | + |
| 20 | +This crate implements the following key components: |
| 21 | + |
| 22 | +- **`Aarch64VCpu`**: The main virtual CPU structure that manages guest execution state |
| 23 | +- **`TrapFrame`**: Context frame for handling traps and exceptions from guest VMs |
| 24 | +- **Exception Handlers**: Support for synchronous and asynchronous exception handling |
| 25 | +- **System Register Emulation**: Virtualized access to AArch64 system registers |
| 26 | +- **SMC Interface**: Secure Monitor Call handling for trusted execution |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +Add this to your `Cargo.toml`: |
| 31 | + |
| 32 | +```toml |
| 33 | +[dependencies] |
| 34 | +arm_vcpu = "0.1" |
| 35 | +``` |
| 36 | + |
| 37 | +### Basic Example |
| 38 | + |
| 39 | +```rust |
| 40 | +use arm_vcpu::{Aarch64VCpu, Aarch64VCpuCreateConfig, has_hardware_support}; |
| 41 | + |
| 42 | +// Check if hardware virtualization is supported |
| 43 | +if has_hardware_support() { |
| 44 | + // Create vCPU configuration |
| 45 | + let config = Aarch64VCpuCreateConfig::default(); |
| 46 | + |
| 47 | + // Create and configure the virtual CPU |
| 48 | + let vcpu = Aarch64VCpu::new(config)?; |
| 49 | + |
| 50 | + // Run the virtual CPU |
| 51 | + vcpu.run()?; |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +## Requirements |
| 56 | + |
| 57 | +- **Architecture**: AArch64 (ARMv8-A or later) |
| 58 | +- **Privilege Level**: EL2 (Hypervisor mode) required for full functionality |
| 59 | + |
| 60 | +## License |
| 61 | + |
| 62 | +This project is dual-licensed under either: |
| 63 | + |
| 64 | +- MIT License ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>) |
| 65 | +- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>) |
| 66 | + |
| 67 | +at your option. |
4 | 68 |
|
5 | | -Definition of the vCPU structure and virtualization-related interface support for the AArch64 architecture. |
|
0 commit comments