Skip to content

Conversation

@ZR233
Copy link
Contributor

@ZR233 ZR233 commented Dec 22, 2025

This pull request introduces significant refactoring and modernization to the arm_vcpu crate, focusing on improved modularity, architectural clarity, and compatibility with the axvm_types workspace. The most important changes include a redesign of per-CPU and vCPU abstractions to remove generic parameters, the addition of a new AxVCpuExitReason enum for VM exit handling, a new HAL (Hardware Abstraction Layer) interface for CPU operations, updates to dependencies and metadata, and adjustments to build and CI configurations for the aarch64-unknown-none-softfloat target.

Architectural Refactoring and HAL Abstraction

  • Removed generic parameters (AxVCpuHal) from Aarch64PerCpu and Aarch64VCpu, simplifying their usage and initialization. Introduced a new trait CpuHal and related initialization logic in lib.rs for hardware abstraction, along with default NOP implementations and safe singleton initialization. ([[1]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-cfbd13fb57529c6ffb629101fb244d55a2746c59484e7a9978342c34995c3b8eL1-R32), [[2]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-cfbd13fb57529c6ffb629101fb244d55a2746c59484e7a9978342c34995c3b8eL78-R70), [[3]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-c81313374d24e5697ee5c347b11fc7b156830230764577b85c5180a3ef7f1ecdL1-R14), [[4]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-c81313374d24e5697ee5c347b11fc7b156830230764577b85c5180a3ef7f1ecdL40-R52), [[5]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R13-R24), [[6]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R39-R82))
  • Refactored IRQ handling to use the new HAL (handle_irq), eliminating the need for per-CPU function pointers or OnceCell. ([[1]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-1b3d9f91d532261d2032e8f484185b3c4bc5377fb42b19e780b751e936dd33e1L284-R285), [[2]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-1b3d9f91d532261d2032e8f484185b3c4bc5377fb42b19e780b751e936dd33e1R9-R19))

VM Exit Reason Standardization

  • Added a comprehensive and well-documented AxVCpuExitReason enum to src/exit.rs, capturing all major categories of VM exits (I/O, system events, power management, multiprocessing, errors, etc.) in a forward-compatible, extensible manner. ([src/exit.rsR1-R191](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-df574c6f1903e886ddf07734496e1891b71f4507e4988e334d907b74dcb2b006R1-R191))
  • Updated exception and vCPU modules to use the new AxVCpuExitReason and types from axvm_types. ([[1]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-1b3d9f91d532261d2032e8f484185b3c4bc5377fb42b19e780b751e936dd33e1R9-R19), [[2]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-c81313374d24e5697ee5c347b11fc7b156830230764577b85c5180a3ef7f1ecdL1-R14))

Dependency and Metadata Updates

  • Migrated from axaddrspace and related crates to axvm_types for address and device types, updating all usages accordingly. ([[1]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-1b3d9f91d532261d2032e8f484185b3c4bc5377fb42b19e780b751e936dd33e1R9-R19), [[2]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-799cbab61f90a6e923db567539632f95c9b72c073f817328c18a6b196220e929L1-R3), [[3]](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-c81313374d24e5697ee5c347b11fc7b156830230764577b85c5180a3ef7f1ecdL1-R14))
  • Updated Cargo.toml to add categories and keywords, adjust dependencies (e.g., update aarch64-cpu to 11.0), and reorganize metadata for clarity and workspace compatibility. ([Cargo.tomlL2-L35](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542L2-L35))

Build and CI Improvements

  • Added .cargo/config.toml to set the default build target to aarch64-unknown-none-softfloat. ([.cargo/config.tomlR1-R2](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-9a4f3e4537ebb7474452d131b0d969d89a51286f4269aac5ef268e712be17268R1-R2))
  • Updated GitHub Actions workflow to use a newer nightly toolchain and to build and deploy documentation for the correct target directory. ([.github/workflows/ci.ymlL47-R59](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fL47-R59))

Exception and Debug Logging Enhancements

  • Improved synchronous exception logging to include additional register values (FAR_EL2, HPFAR_EL2, SPSR_EL2) for better debugging. ([src/exception.rsR294-R303](https://github.com/arceos-hypervisor/arm_vcpu/pull/46/files#diff-1b3d9f91d532261d2032e8f484185b3c4bc5377fb42b19e780b751e936dd33e1R294-R303))

These changes collectively modernize the codebase, improve maintainability, and prepare the crate for further development and integration in the arceos-hypervisor ecosystem.

ZR233 added 30 commits September 8, 2025 15:41
refactor: add page level detect and remove feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adapt axvm refactor 重构axvcpu与arch-vcpu接口架构

2 participants