diff --git a/Cargo.toml b/Cargo.toml index ef81e59..ecc5038 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "axvcpu" authors = ["aarkegz "] -version = "0.2.0" +version = "0.2.2" edition = "2024" categories = ["virtualization", "no-std"] description = "Virtual CPU abstraction for ArceOS hypervisor" @@ -12,6 +12,6 @@ license = "Apache-2.0" [dependencies] axerrno = "0.1.0" memory_addr = "0.4" -percpu = "0.2.0" -axaddrspace = "0.1" +percpu = "0.2.3-preview.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. 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();