Skip to main content

FpuSwitch

Struct FpuSwitch 

Source
pub struct FpuSwitch {
    host: FpuArea,
    guest: FpuArea,
    uses_xsave: bool,
    supported_xcr0: u64,
    guest_xcr0: u64,
}
Expand description

Host and guest FPU/SIMD state of one vCPU.

Fields§

§host: FpuArea§guest: FpuArea§uses_xsave: bool§supported_xcr0: u64

XCR0 bits the host supports (upper bound for the guest).

§guest_xcr0: u64

XCR0 the guest believes it has; 0 = follow the host’s XCR0.

Implementations§

Source§

impl FpuSwitch

Source

pub fn new() -> Result<Self, FpuError>

Allocates the two save areas.

Source

pub fn guest_xcr0(&self) -> Option<u64>

XCR0 as seen by the guest (None while it follows the host’s).

Source

pub fn set_guest_xcr0(&mut self, value: u64) -> bool

Sets the guest XCR0 after an xsetbv. Returns false, changing nothing, when the value is architecturally invalid or unsupported.

Source

fn hardware_guest_xcr0(&self, host_xcr0: u64) -> u64

XCR0 programmed while the guest runs.

SSE is always included: the XMM registers must be switched even when the guest never enabled them in XCR0, otherwise the host’s XMM contents would be visible to (and clobbered by) the guest.

Source

pub unsafe fn enter(&mut self) -> HostFpu

Saves the host state, then loads the guest’s (and its XCR0).

§Safety

Local interrupts must be disabled from this call until the matching Self::leave: a context switch in between would save the guest state into the interrupted task’s area.

Source

pub unsafe fn leave(&mut self, token: HostFpu)

Saves the guest state, then restores the host’s (and its XCR0).

§Safety

Same as Self::enter; token must come from the matching enter.

Auto Trait Implementations§

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.