Skip to main content

HwVcpu

Enum HwVcpu 

Source
pub enum HwVcpu {
    Vmx(Vcpu),
    Svm(SvmBackendVcpu),
}
Expand description

A virtual CPU of either backend.

Variants§

§

Vmx(Vcpu)

Intel VT-x.

§

Svm(SvmBackendVcpu)

AMD-V.

Implementations§

Source§

impl HwVcpu

Source

pub fn new(caps: &HwCaps, pointer: u64) -> Result<Self, VcpuError>

Creates the hardware context of a vCPU for the active backend.

pointer is the value given by WorldMemory::second_level_pointer: an EPTP on Intel, the nCR3 on AMD.

Source

pub fn entered(&self) -> bool

True once the guest has been entered at least once.

Source

pub unsafe fn load(&mut self) -> Result<(), VcpuError>

Makes the hardware context current on this CPU.

§Safety

VT-x: active on this CPU, vCPU not running.

Source

pub unsafe fn clear(&mut self) -> Result<(), VcpuError>

Releases the hardware context (VMCS VMCLEAR).

§Safety

VT-x: active on this CPU, vCPU not running.

Source

pub unsafe fn configure_host(&mut self) -> Result<(), VcpuError>

Writes the host-state fields.

§Safety

VT-x: the control block must be loaded.

Source

pub unsafe fn refresh_system_state(&mut self) -> Result<(), VcpuError>

Imports the architectural state the guest produced since the last RUN.

§Safety

VT-x: the control block must be loaded and the guest inactive.

Source

pub unsafe fn configure( &mut self, caps: &HwCaps, guest: &GuestState, ) -> Result<(), VcpuError>

Writes the guest state and the execution controls.

§Safety

VT-x: the control block must be loaded.

Source

pub unsafe fn inject_nmi(&mut self) -> Result<(), VcpuError>

Queues an NMI for the next entry.

§Safety

VT-x: the control block must be loaded and the guest inactive.

Source

pub unsafe fn inject_interrupt(&mut self, vector: u8) -> Result<(), VcpuError>

Queues an external interrupt for the next entry.

§Safety

VT-x: the control block must be loaded and the guest inactive.

Source

pub unsafe fn set_interrupt_window_exiting( &mut self, caps: &HwCaps, enabled: bool, ) -> Result<bool, VcpuError>

Arms or disarms interrupt-window exiting. Returns whether the control is armed as requested.

§Safety

VT-x: the control block must be loaded and the guest inactive.

Source

pub unsafe fn set_external_interrupt_exiting( &mut self, caps: &HwCaps, enabled: bool, ) -> Result<bool, VcpuError>

Re-arms external-interrupt exiting.

§Safety

VT-x: the control block must be loaded and the guest inactive.

Source

pub unsafe fn interruptibility(&self) -> Result<u32, VcpuError>

Interruptibility state (bit 0: STI / MOV-SS blocking).

§Safety

VT-x: the control block must be loaded.

Source

pub unsafe fn run(&mut self) -> Result<ExitInfo, VcpuError>

Enters the guest and returns on the next exit, in the VT-x shape.

§Safety

VT-x: the control block must be loaded. AMD-V: nothing beyond the activation, which is done on demand on the current CPU.

Source

pub unsafe fn sync_msr_state(&mut self) -> Result<(), VcpuError>

Pushes the MSR shadows into the hardware state.

§Safety

VT-x: the control block must be loaded and the guest inactive.

Source

pub unsafe fn guest_diagnostics(&self) -> String

Dump of the hardware state, for failure logs.

§Safety

VT-x: the control block must be loaded.

Source

pub fn as_vmx(&self) -> Option<&Vcpu>

The VT-x vCPU, if that is the active backend (DOS boot and the VT-x self-tests need VT-x specifics).

Source

pub fn flush_second_level(&mut self)

Invalidates the guest TLB after a second-level mapping change.

Trait Implementations§

Source§

impl VcpuOps for HwVcpu

Source§

fn second_level_pointer(&self) -> u64

Second-level translation root given to this vCPU (EPTP or nCR3).
Source§

fn guest(&self) -> &GuestState

Guest state as of the last exit.
Source§

fn paging_enabled(&self) -> bool

True if the guest runs with paging enabled.
Source§

fn guest_gpr(&self, register: u8) -> u64

Reads a general-purpose register (x86 encoding order).
Source§

unsafe fn set_guest_gpr(&mut self, register: u8, value: u64)

Writes a general-purpose register. Read more
Source§

unsafe fn set_guest_rip(&mut self, rip: u64)

Sets the guest instruction pointer. Read more
Source§

fn msr_mut(&mut self) -> &mut MsrModel

Per-vCPU MSR shadow model.

Auto Trait Implementations§

§

impl Forget for HwVcpu

§

impl Freeze for HwVcpu

§

impl Move for HwVcpu

§

impl RefUnwindSafe for HwVcpu

§

impl Send for HwVcpu

§

impl Sync for HwVcpu

§

impl Unpin for HwVcpu

§

impl UnsafeUnpin for HwVcpu

§

impl UnwindSafe for HwVcpu

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.