From 15d75a0a3273b4e9a155f71293f6d7b04c04654b Mon Sep 17 00:00:00 2001 From: aarkegz Date: Thu, 15 Jan 2026 15:21:41 +0000 Subject: [PATCH 1/9] update axaddrspace to 0.2.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b21e2f6..a90b61a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,4 +26,4 @@ axvisor_api_proc = { path = "axvisor_api_proc", version = "0.2.0"} crate_interface = "0.2" memory_addr = "0.4" -axaddrspace = "0.1.0" +axaddrspace = "0.2.0" From 8e0610b1703e4de65012bd1f49621fa2c9190e85 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Fri, 16 Jan 2026 08:36:51 +0000 Subject: [PATCH 2/9] make `memory::PhysFrame` `Debug` --- src/memory.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/memory.rs b/src/memory.rs index cc19682..ca31c92 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -22,6 +22,7 @@ pub trait MemoryIf { /// [`AxMmHal`](axaddrspace::AxMmHal) implementation by axvisor_api. #[doc(hidden)] +#[derive(Debug)] pub struct AxMmHalApiImpl; impl axaddrspace::AxMmHal for AxMmHalApiImpl { From 5f364f8f816c46aec09914a7b799d17ad9fe7da9 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Sat, 17 Jan 2026 17:28:08 +0800 Subject: [PATCH 3/9] add `arch::fetch_irq` for aarch64 --- src/arch.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arch.rs b/src/arch.rs index c11b030..bd1a816 100644 --- a/src/arch.rs +++ b/src/arch.rs @@ -22,4 +22,8 @@ pub trait ArchIf { /// Get the base address of the GIC redistributor in the host system. #[cfg(target_arch = "aarch64")] fn get_host_gicr_base() -> PhysAddr; + + /// Retrieve the current pending interrupt for the CPU from the physical hardware. + #[cfg(target_arch = "aarch64")] + fn fetch_irq() -> u64; } From ecff6c4901962e43f3f94111b61095f1894d9d78 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Sat, 17 Jan 2026 17:38:46 +0800 Subject: [PATCH 4/9] add `arch::handle_irq` --- src/arch.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/arch.rs b/src/arch.rs index bd1a816..2d943c1 100644 --- a/src/arch.rs +++ b/src/arch.rs @@ -26,4 +26,12 @@ pub trait ArchIf { /// Retrieve the current pending interrupt for the CPU from the physical hardware. #[cfg(target_arch = "aarch64")] fn fetch_irq() -> u64; + /// Calls the IRQ handler of the underlying OS to handle a pending interrupt. + /// + /// TODO: Determine if this function should be exposed in other architectures (and moved to + /// `host` module) or remain architecture-specific. + /// + /// TODO: Consider whether this function should replace `AxVCpuExitReason::ExternalInterrupt`. + #[cfg(target_arch = "aarch64")] + fn handle_irq(); } From a2d62452fd6ccc3a8f733cab12c0d15ff721b5dc Mon Sep 17 00:00:00 2001 From: aarkegz Date: Sat, 17 Jan 2026 18:03:09 +0800 Subject: [PATCH 5/9] formatted --- src/arch.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arch.rs b/src/arch.rs index 2d943c1..a9d299c 100644 --- a/src/arch.rs +++ b/src/arch.rs @@ -27,10 +27,10 @@ pub trait ArchIf { #[cfg(target_arch = "aarch64")] fn fetch_irq() -> u64; /// Calls the IRQ handler of the underlying OS to handle a pending interrupt. - /// + /// /// TODO: Determine if this function should be exposed in other architectures (and moved to /// `host` module) or remain architecture-specific. - /// + /// /// TODO: Consider whether this function should replace `AxVCpuExitReason::ExternalInterrupt`. #[cfg(target_arch = "aarch64")] fn handle_irq(); From 39f4b5a89bf34322a517bb3b6834b11ee69e97eb Mon Sep 17 00:00:00 2001 From: aarkegz Date: Wed, 21 Jan 2026 20:35:35 +0800 Subject: [PATCH 6/9] update comment in the `vmm` mod --- src/vmm.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vmm.rs b/src/vmm.rs index 5d3ee25..512807e 100644 --- a/src/vmm.rs +++ b/src/vmm.rs @@ -10,9 +10,11 @@ pub type InterruptVector = u8; /// The API trait for virtual machine management functionalities. #[crate::api_def] pub trait VmmIf { - /// Get the ID of the current virtual machine. + /// Get the ID of the virtual machine executing on the current physical CPU. + /// It MAY differ from the ID of the virtual machine calling this function. fn current_vm_id() -> VMId; - /// Get the ID of the current virtual CPU. + /// Get the ID of the virtual CPU executing on the current physical CPU. + /// It MAY differ from the ID of the virtual CPU calling this function. fn current_vcpu_id() -> VCpuId; /// Get the number of virtual CPUs in a virtual machine. fn vcpu_num(vm_id: VMId) -> Option; @@ -26,12 +28,14 @@ pub trait VmmIf { fn notify_vcpu_timer_expired(vm_id: VMId, vcpu_id: VCpuId); } -/// Get the number of virtual CPUs in the current virtual machine. +/// Get the number of virtual CPUs in the virtual machine executing on the +/// current physical CPU. pub fn current_vm_vcpu_num() -> usize { vcpu_num(current_vm_id()).unwrap() } -/// Get the mask of active virtual CPUs in the current virtual machine. +/// Get the mask of active virtual CPUs in the virtual machine executing on the +/// current physical CPU. pub fn current_vm_active_vcpus() -> usize { active_vcpus(current_vm_id()).unwrap() } From 657ef629e46738f8b32987cf1de7a5950c1ba904 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Wed, 21 Jan 2026 20:45:58 +0800 Subject: [PATCH 7/9] add `vmm::inject_interrupt_to_cpus` --- Cargo.toml | 1 + src/vmm.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a90b61a..a40dc9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,4 @@ axvisor_api_proc = { path = "axvisor_api_proc", version = "0.2.0"} crate_interface = "0.2" memory_addr = "0.4" axaddrspace = "0.2.0" +cpumask = "0.1.0" diff --git a/src/vmm.rs b/src/vmm.rs index 512807e..284c616 100644 --- a/src/vmm.rs +++ b/src/vmm.rs @@ -7,6 +7,11 @@ pub type VCpuId = usize; /// Interrupt vector. pub type InterruptVector = u8; +/// The maximum number of virtual CPUs supported in a virtual machine. +pub const MAX_VCPU_NUM: usize = 64; + +pub type VCpuSet = cpumask::CpuMask; + /// The API trait for virtual machine management functionalities. #[crate::api_def] pub trait VmmIf { @@ -22,6 +27,8 @@ pub trait VmmIf { fn active_vcpus(vm_id: VMId) -> Option; /// Inject an interrupt to a virtual CPU. fn inject_interrupt(vm_id: VMId, vcpu_id: VCpuId, vector: InterruptVector); + /// Inject an interrupt to a set of virtual CPUs. + fn inject_interrupt_to_cpus(vm_id: VMId, vcpu_set: VCpuSet, vector: InterruptVector); /// Notify that a virtual CPU timer has expired. /// /// TODO: determine whether we can skip this function. From 5611cc645f51559e11f54dd3e157930a27b59946 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Thu, 5 Mar 2026 20:07:46 +0800 Subject: [PATCH 8/9] bump versions for `axvisor_api`, `axvisor_api_proc`, `crate_interface`, and `axaddrspace` to 0.3.0 in Cargo.toml --- Cargo.toml | 8 ++++---- axvisor_api_proc/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a40dc9e..4370638 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/arceos-hypervisor/axvisor_api" [package] name = "axvisor_api" description = "Basic API for components of the Hypervisor on ArceOS" -version = "0.2.0" +version = "0.3.0" keywords = ["axvisor", "api", "embedded"] categories = ["embedded", "no-std"] authors.workspace = true @@ -22,9 +22,9 @@ license.workspace = true repository.workspace = true [dependencies] -axvisor_api_proc = { path = "axvisor_api_proc", version = "0.2.0"} +axvisor_api_proc = { path = "axvisor_api_proc", version = "0.3.0"} -crate_interface = "0.2" +crate_interface = "0.3" memory_addr = "0.4" -axaddrspace = "0.2.0" +axaddrspace = "0.3.0" cpumask = "0.1.0" diff --git a/axvisor_api_proc/Cargo.toml b/axvisor_api_proc/Cargo.toml index f080e76..b87264a 100644 --- a/axvisor_api_proc/Cargo.toml +++ b/axvisor_api_proc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "axvisor_api_proc" -version = "0.2.0" +version = "0.3.0" description = "Procedural macros for the `axvisor_api` crate" keywords = ["axvisor", "api", "embedded", "macros"] categories = ["development-tools::procedural-macro-helpers"] From dc66e19f5ddfa3f166fbd5e39ed7a6e4313e4f51 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Thu, 5 Mar 2026 20:16:15 +0800 Subject: [PATCH 9/9] docs: add comment for VCpuSet type in vmm.rs --- src/vmm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vmm.rs b/src/vmm.rs index 85ad7af..8de149c 100644 --- a/src/vmm.rs +++ b/src/vmm.rs @@ -74,6 +74,7 @@ pub type InterruptVector = u8; /// The maximum number of virtual CPUs supported in a virtual machine. pub const MAX_VCPU_NUM: usize = 64; +/// A set of virtual CPUs. pub type VCpuSet = cpumask::CpuMask; /// The API trait for virtual machine management functionalities.