From 386ade6e5aa067ff08d16f40c57fc6dc1e25eaae Mon Sep 17 00:00:00 2001 From: aarkegz Date: Fri, 16 Jan 2026 22:09:04 +0800 Subject: [PATCH 1/4] update dependencies --- Cargo.toml | 17 +++++++++++------ src/vcpu.rs | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f53bb7c..5238220 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4" cfg-if = "1.0" bitflags = "2.2" bit_field = "0.10" -crate_interface = "0.1" +crate_interface = "0.2" riscv = { version = "0.14.0", features = ["s-mode"] } riscv-h = "0.1" @@ -32,13 +32,18 @@ riscv-decode = "0.2.3" rustsbi = { version = "0.4.0", features = ["forward"] } sbi-rt = { version = "0.0.3", features = ["integer-impls"] } sbi-spec = { version = "0.0.7", features = ["legacy"] } -tock-registers = "0.9" +tock-registers = "0.10" memoffset = { version = ">=0.6.5", features = ["unstable_const"] } -axerrno = "0.1.0" +axerrno = "0.2" page_table_entry = "0.5" memory_addr = "0.4" -axaddrspace = "0.1" -axvcpu = "0.1" -axvisor_api = "0.1" +axaddrspace = "0.2" +axvcpu = "0.1.2" +axvisor_api = "0.2" + +[patch.crates-io] +axvcpu = { git = "https://github.com/arceos-hypervisor/axvcpu", branch = "aar-master" } +axvisor_api = { git = "https://github.com/arceos-hypervisor/axvisor_api", branch = "aar-master" } +axaddrspace = { git = "https://github.com/arceos-hypervisor/axaddrspace", branch = "aar-master" } diff --git a/src/vcpu.rs b/src/vcpu.rs index 0ced72c..a8ef823 100644 --- a/src/vcpu.rs +++ b/src/vcpu.rs @@ -22,7 +22,7 @@ use crate::{ }; use axaddrspace::{GuestPhysAddr, GuestVirtAddr, HostPhysAddr, MappingFlags, device::AccessWidth}; -use axerrno::{AxError::InvalidData, AxResult}; +use axerrno::{AxErrorKind::InvalidData, AxResult}; use axvcpu::{AxVCpuExitReason, AxVCpuHal}; unsafe extern "C" { From 4cad20373c85d150e509821c3551fefb16084a7a Mon Sep 17 00:00:00 2001 From: aarkegz Date: Fri, 16 Jan 2026 22:22:41 +0800 Subject: [PATCH 2/4] remove type parameters --- src/percpu.rs | 14 ++++---------- src/vcpu.rs | 12 +++++------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/percpu.rs b/src/percpu.rs index e6a0f31..8a6799c 100644 --- a/src/percpu.rs +++ b/src/percpu.rs @@ -1,7 +1,5 @@ -use core::marker::PhantomData; - use axerrno::{AxError, AxResult}; -use axvcpu::{AxArchPerCpu, AxVCpuHal}; +use axvcpu::AxArchPerCpu; use riscv::register::sie; use riscv_h::register::{hedeleg, hideleg, hvip}; @@ -10,19 +8,15 @@ use crate::consts::traps; use crate::has_hardware_support; /// Risc-V per-CPU state. -pub struct RISCVPerCpu { - _marker: PhantomData, -} +pub struct RISCVPerCpu; -impl AxArchPerCpu for RISCVPerCpu { +impl AxArchPerCpu for RISCVPerCpu { fn new(_cpu_id: usize) -> AxResult { unsafe { setup_csrs(); } - Ok(Self { - _marker: PhantomData, - }) + Ok(Self) } fn is_enabled(&self) -> bool { diff --git a/src/vcpu.rs b/src/vcpu.rs index a8ef823..99a13e0 100644 --- a/src/vcpu.rs +++ b/src/vcpu.rs @@ -23,7 +23,7 @@ use crate::{ use axaddrspace::{GuestPhysAddr, GuestVirtAddr, HostPhysAddr, MappingFlags, device::AccessWidth}; use axerrno::{AxErrorKind::InvalidData, AxResult}; -use axvcpu::{AxVCpuExitReason, AxVCpuHal}; +use axvcpu::AxVCpuExitReason; unsafe extern "C" { fn _run_guest(state: *mut VmCpuRegisters); @@ -43,10 +43,9 @@ pub struct VCpuConfig {} #[derive(Default)] /// A virtual CPU within a guest -pub struct RISCVVCpu { +pub struct RISCVVCpu { regs: VmCpuRegisters, sbi: RISCVVCpuSbi, - _marker: core::marker::PhantomData, } #[derive(RustSBI)] @@ -62,7 +61,7 @@ impl Default for RISCVVCpuSbi { } } -impl axvcpu::AxArchVCpu for RISCVVCpu { +impl axvcpu::AxArchVCpu for RISCVVCpu { type CreateConfig = RISCVVCpuCreateConfig; type SetupConfig = (); @@ -78,7 +77,6 @@ impl axvcpu::AxArchVCpu for RISCVVCpu { Ok(Self { regs, sbi: RISCVVCpuSbi::default(), - _marker: core::marker::PhantomData, }) } @@ -220,7 +218,7 @@ impl axvcpu::AxArchVCpu for RISCVVCpu { } } -impl RISCVVCpu { +impl RISCVVCpu { /// Gets one of the vCPU's general purpose registers. pub fn get_gpr(&self, index: GprIndex) -> usize { self.regs.guest_regs.gprs.reg(index) @@ -242,7 +240,7 @@ impl RISCVVCpu { } } -impl RISCVVCpu { +impl RISCVVCpu { fn vmexit_handler(&mut self) -> AxResult { self.regs.trap_csrs.load_from_hw(); From d76259fe0f5d2d7000b3204becc9620f8aa9014c Mon Sep 17 00:00:00 2001 From: aarkegz Date: Fri, 6 Mar 2026 01:12:10 +0800 Subject: [PATCH 3/4] bump version to v0.3.0 --- Cargo.toml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6b22c27..6ffefc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "riscv_vcpu" -version = "0.2.2" +version = "0.3.0" edition = "2024" authors = [ "KeYang Hu ", @@ -42,8 +42,3 @@ memory_addr = "0.4" axaddrspace = "0.3" axvcpu = "0.3" axvisor_api = "0.3" - -[patch.crates-io] -axvcpu = { git = "https://github.com/arceos-hypervisor/axvcpu", branch = "aar-master" } -axvisor_api = { git = "https://github.com/arceos-hypervisor/axvisor_api", branch = "aar-master" } -axaddrspace = { git = "https://github.com/arceos-hypervisor/axaddrspace", branch = "aar-master" } From 6f7a8853728db686ddfaf15273216849f91ab015 Mon Sep 17 00:00:00 2001 From: aarkegz Date: Fri, 6 Mar 2026 11:19:12 +0800 Subject: [PATCH 4/4] remove unused import --- src/percpu.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/percpu.rs b/src/percpu.rs index f233e66..00d94f8 100644 --- a/src/percpu.rs +++ b/src/percpu.rs @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use core::marker::PhantomData; - use axerrno::{AxError, AxResult}; use axvcpu::AxArchPerCpu;