Skip to main content

AxPerCpu

Struct AxPerCpu 

Source
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>

Source

pub const fn new_uninit() -> Self

Create a new, uninitialized per-CPU state.

Source

pub fn init(&mut self, cpu_id: usize) -> AxResult

Initialize the per-CPU state.

Source

pub fn arch_checked(&self) -> &A

Return the architecture-specific per-CPU state. Panics if the per-CPU state is not initialized.

Source

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.

Source

pub fn is_enabled(&self) -> bool

Whether the current CPU has hardware virtualization enabled.

Source

pub fn hardware_enable(&mut self) -> AxResult

Enable hardware virtualization on the current CPU.

Source

pub fn hardware_disable(&mut self) -> AxResult

Disable hardware virtualization on the current CPU.

Trait Implementations§

Source§

impl<A: AxArchPerCpu> Drop for AxPerCpu<A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.