From 0f532c362d565e1719ea2eb64f5b2cd2bfd07bc2 Mon Sep 17 00:00:00 2001 From: Josen-B <65878371+Josen-B@users.noreply.github.com> Date: Mon, 9 Feb 2026 15:42:23 +0800 Subject: [PATCH 1/3] feat: add gpt level api and publish version 0.2.1 (#45) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add gpt level api * fix: update axaddrspace dependency version to 0.1.4 * release: publish crate version 0.2.1 * fix: update axaddrspace dependency specification --------- Co-authored-by: 周睿 --- Cargo.toml | 4 ++-- src/percpu.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef81e59..22edc44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "axvcpu" authors = ["aarkegz "] -version = "0.2.0" +version = "0.2.1" edition = "2024" categories = ["virtualization", "no-std"] description = "Virtual CPU abstraction for ArceOS hypervisor" @@ -13,5 +13,5 @@ license = "Apache-2.0" axerrno = "0.1.0" memory_addr = "0.4" percpu = "0.2.0" -axaddrspace = "0.1" +axaddrspace = "0.1.4" axvisor_api = "0.1" diff --git a/src/percpu.rs b/src/percpu.rs index b0e9ffb..cddb5f1 100644 --- a/src/percpu.rs +++ b/src/percpu.rs @@ -30,6 +30,10 @@ pub trait AxArchPerCpu: Sized { fn hardware_enable(&mut self) -> AxResult; /// Disable hardware virtualization on the current CPU. fn hardware_disable(&mut self) -> AxResult; + /// Return max guest page table levels used by the architecture. + fn max_guest_page_table_levels(&self) -> usize { + 4 + } } /// Host per-CPU states to run the guest. From e0883721aa7a03d157eab1d678ae47272ed37759 Mon Sep 17 00:00:00 2001 From: YanLien Date: Fri, 6 Mar 2026 15:24:57 +0800 Subject: [PATCH 2/3] fix: update percpu dependency version and add static mutable reference allowances --- Cargo.toml | 2 +- src/vcpu.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 22edc44..3264d0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,6 @@ license = "Apache-2.0" [dependencies] axerrno = "0.1.0" memory_addr = "0.4" -percpu = "0.2.0" +percpu = "0.2.3-preview.1" axaddrspace = "0.1.4" axvisor_api = "0.1" diff --git a/src/vcpu.rs b/src/vcpu.rs index 621ff8c..cc9ace4 100644 --- a/src/vcpu.rs +++ b/src/vcpu.rs @@ -314,6 +314,7 @@ static mut CURRENT_VCPU: Option<*mut u8> = None; /// /// It's guaranteed that each time before a method of [`AxArchVCpu`] is called, the current VCpu is set to the corresponding [`AxVCpu`]. /// So methods of [`AxArchVCpu`] can always get the [`AxVCpu`] containing itself by calling this method. +#[allow(static_mut_refs)] pub fn get_current_vcpu<'a, A: AxArchVCpu>() -> Option<&'a AxVCpu> { unsafe { CURRENT_VCPU @@ -327,6 +328,7 @@ pub fn get_current_vcpu<'a, A: AxArchVCpu>() -> Option<&'a AxVCpu> { /// Get a mutable reference to the current VCpu on the current physical CPU. /// /// See [`get_current_vcpu`] for more details. +#[allow(static_mut_refs)] pub fn get_current_vcpu_mut<'a, A: AxArchVCpu>() -> Option<&'a mut AxVCpu> { unsafe { CURRENT_VCPU @@ -342,6 +344,7 @@ pub fn get_current_vcpu_mut<'a, A: AxArchVCpu>() -> Option<&'a mut AxVCpu> { /// # Safety /// This method is marked as unsafe because it may result in unexpected behavior if not used properly. /// Do not call this method unless you know what you are doing. +#[allow(static_mut_refs)] pub unsafe fn set_current_vcpu(vcpu: &AxVCpu) { unsafe { CURRENT_VCPU @@ -354,7 +357,8 @@ pub unsafe fn set_current_vcpu(vcpu: &AxVCpu) { /// /// # Safety /// This method is marked as unsafe because it may result in unexpected behavior if not used properly. -/// Do not call this method unless you know what you are doing. +/// Do not call this method unless you know what you are doing. +#[allow(static_mut_refs)] pub unsafe fn clear_current_vcpu() { unsafe { CURRENT_VCPU.current_ref_mut_raw().take(); From d652b14cd5c6b7b1fb4de7c6f807988c09f257ed Mon Sep 17 00:00:00 2001 From: YanLien Date: Fri, 6 Mar 2026 16:56:19 +0800 Subject: [PATCH 3/3] chore: bump version to 0.2.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3264d0c..ecc5038 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "axvcpu" authors = ["aarkegz "] -version = "0.2.1" +version = "0.2.2" edition = "2024" categories = ["virtualization", "no-std"] description = "Virtual CPU abstraction for ArceOS hypervisor"