Skip to main content

Vmcb

Struct Vmcb 

Source
#[repr(C, align(4096))]
pub struct Vmcb { bytes: [u8; 4096], }
Expand description

One VMCB: 4 KiB, page-aligned, zero-initialized.

Fields§

§bytes: [u8; 4096]

Implementations§

Source§

impl Vmcb

Source

pub const fn new() -> Self

A zeroed VMCB.

Source

pub fn as_bytes(&self) -> &[u8; 4096]

Raw view, for hardware access.

Source

pub fn read8(&self, offset: usize) -> u8

Reads a u8 field.

Source

pub fn read16(&self, offset: usize) -> u16

Reads a u16 field.

Source

pub fn read32(&self, offset: usize) -> u32

Reads a u32 field.

Source

pub fn read64(&self, offset: usize) -> u64

Reads a u64 field.

Source

pub fn write8(&mut self, offset: usize, value: u8)

Writes a u8 field.

Source

pub fn write16(&mut self, offset: usize, value: u16)

Writes a u16 field.

Source

pub fn write32(&mut self, offset: usize, value: u32)

Writes a u32 field.

Source

pub fn write64(&mut self, offset: usize, value: u64)

Writes a u64 field.

Source

pub fn write_segment( &mut self, offset: usize, selector: u16, attrib: u16, limit: u32, base: u64, )

Writes a segment register (selector, attributes, limit, base).

attrib uses the VMCB packed format: bits 0-7 = type/S/DPL/P, bits 8-11 = AVL/L/D/B/G (the access-rights byte followed by the flags nibble of a descriptor).

Source

pub fn read_segment(&self, offset: usize) -> (u16, u16, u32, u64)

Reads a segment register as (selector, attrib, limit, base).

Source

pub fn install_mandatory_intercepts(&mut self)

Installs the always-on intercepts (see MANDATORY_INTERCEPT4).

Source

pub fn enable_nested_paging(&mut self, ncr3: u64, asid: u32)

Enables nested paging with the given nCR3 and guest ASID.

ASID 0 is reserved for the host: the guest ASID must be non-zero.

Source

pub fn exit_code(&self) -> u64

Exit code of the last #VMEXIT.

Source

pub fn exit_class(&self) -> ExitClass

Class of the last #VMEXIT.

Source

pub fn nested_fault(&self) -> Option<NestedFault>

Decoded nested page fault, if the last exit was one.

Source

pub fn inject(&mut self, event: u32, error_code: u32)

Queues an event for injection at the next vmrun.

Source

pub fn advance_rip_from_next(&mut self) -> bool

Advances the guest RIP past the intercepted instruction using the hardware-provided NEXT_RIP (requires NRIP_SAVE). Returns false if NEXT_RIP is zero (feature absent): the caller must decode.

Trait Implementations§

Source§

impl Default for Vmcb

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Vmcb

§

impl Freeze for Vmcb

§

impl Move for Vmcb

§

impl RefUnwindSafe for Vmcb

§

impl Send for Vmcb

§

impl Sync for Vmcb

§

impl Unpin for Vmcb

§

impl UnsafeUnpin for Vmcb

§

impl UnwindSafe for Vmcb

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.