pub struct AxPerCpu<A: AxArchPerCpu> { /* private fields */ }Expand description
Host per-CPU states to run the guest.
Recommended usage:
-
Define a per-CPU state in hypervisor:
ⓘ#[percpu::def_percpu] pub static AXVM_PER_CPU: AxPerCpu<MyArchPerCpuImpl> = AxPerCpu::new_uninit(); -
Then initialize and enable virtualization on each CPU in the hypervisor initialization code:
ⓘlet percpu = unsafe { AXVM_PER_CPU.current_ref_mut_raw() }; percpu.init(0).expect("Failed to initialize percpu state"); percpu.hardware_enable().expect("Failed to enable virtualization");
Implementations§
Source§impl<A: AxArchPerCpu> AxPerCpu<A>
impl<A: AxArchPerCpu> AxPerCpu<A>
Sourcepub const fn new_uninit() -> Self
pub const fn new_uninit() -> Self
Create a new, uninitialized per-CPU state.
Sourcepub fn arch_checked(&self) -> &A
pub fn arch_checked(&self) -> &A
Return the architecture-specific per-CPU state. Panics if the per-CPU state is not initialized.
Sourcepub fn arch_checked_mut(&mut self) -> &mut A
pub fn arch_checked_mut(&mut self) -> &mut A
Return the mutable architecture-specific per-CPU state. Panics if the per-CPU state is not initialized.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether the current CPU has hardware virtualization enabled.
Sourcepub fn hardware_enable(&mut self) -> AxResult
pub fn hardware_enable(&mut self) -> AxResult
Enable hardware virtualization on the current CPU.
Sourcepub fn hardware_disable(&mut self) -> AxResult
pub fn hardware_disable(&mut self) -> AxResult
Disable hardware virtualization on the current CPU.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for AxPerCpu<A>where
A: Freeze,
impl<A> RefUnwindSafe for AxPerCpu<A>where
A: RefUnwindSafe,
impl<A> Send for AxPerCpu<A>where
A: Send,
impl<A> Sync for AxPerCpu<A>where
A: Sync,
impl<A> Unpin for AxPerCpu<A>where
A: Unpin,
impl<A> UnsafeUnpin for AxPerCpu<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for AxPerCpu<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more