Struct ProcessorRunner

Source
pub struct ProcessorRunner<'a, T: Backing<'a>> { /* private fields */ }
Expand description

Object used to run and to access state for a specific VP.

Implementations§

Source§

impl ProcessorRunner<'_, MshvArm64>

Source

pub fn cpu_context(&self) -> &hcl_cpu_context_aarch64

Returns a reference to the current VTL’s CPU context.

Source

pub fn cpu_context_mut(&mut self) -> &mut hcl_cpu_context_aarch64

Returns a mutable reference to the current VTL’s CPU context.

Source§

impl<'a> ProcessorRunner<'a, Snp<'a>>

Source

pub fn vmsa(&self, vtl: GuestVtl) -> VmsaWrapper<'_, &SevVmsa>

Gets a reference to the VMSA and backing state of a VTL

Source

pub fn vmsa_mut(&mut self, vtl: GuestVtl) -> VmsaWrapper<'_, &mut SevVmsa>

Gets a mutable reference to the VMSA and backing state of a VTL.

Source

pub fn vmsas_mut(&mut self) -> [VmsaWrapper<'_, &mut SevVmsa>; 2]

Returns the VMSAs for [VTL0, VTL1].

Source§

impl<'a> ProcessorRunner<'a, Tdx<'a>>

Source

pub fn tdx_enter_guest_gps(&self) -> &[u64; 16]

Gets a reference to the TDX enter guest state’s GP list.

Source

pub fn tdx_enter_guest_gps_mut(&mut self) -> &mut [u64; 16]

Gets a mutable reference to the TDX enter guest state’s GP list.

Source

pub fn tdx_vp_enter_exit_info(&self) -> &tdx_tdg_vp_enter_exit_info

Gets a reference to the tdx exit info from a VP.ENTER call.

Source

pub fn tdx_apic_page(&self, vtl: GuestVtl) -> &ApicPage

Gets a reference to the tdx APIC page for the given VTL.

Source

pub fn tdx_apic_page_mut(&mut self, vtl: GuestVtl) -> &mut ApicPage

Gets a mutable reference to the tdx APIC page for the given VTL.

Source

pub fn cr2(&self) -> u64

Gets the value of CR2 from the shared kernel state.

Source

pub fn set_cr2(&mut self, value: u64)

Gets the value of CR2 from the shared kernel state.

Source

pub fn tdx_vp_state_flags_mut(&mut self) -> &mut tdx_vp_state_flags

Gets a mutable reference to TDX specific VP flags.

Source

pub fn read_private_regs(&self, regs: &mut TdxPrivateRegs)

Reads the private registers from the kernel’s shared run page into the given TdxPrivateRegs.

Source

pub fn write_private_regs(&mut self, regs: &TdxPrivateRegs)

Writes the private registers from the given TdxPrivateRegs to the kernel’s shared run page.

Source

pub fn write_vmcs64( &mut self, vtl: GuestVtl, field: VmcsField, mask: u64, value: u64, ) -> u64

Write a 64-bit VMCS field.

Only updates the bits that are set in mask. Returns the old value of the field.

Panics if the field is not a 64-bit field, or if there is an error in the TDX module when writing the field.

Source

pub fn read_vmcs64(&self, vtl: GuestVtl, field: VmcsField) -> u64

Reads a 64-bit VMCS field.

Panics if the field is not a 64-bit field, or if there is an error in the TDX module when reading the field.

Source

pub fn write_vmcs32( &mut self, vtl: GuestVtl, field: VmcsField, mask: u32, value: u32, ) -> u32

Write a 32-bit VMCS field.

Only updates the bits that are set in mask. Returns the old value of the field.

Panics if the field is not a 32-bit field, or if there is an error in the TDX module when writing the field.

Source

pub fn read_vmcs32(&self, vtl: GuestVtl, field: VmcsField) -> u32

Reads a 32-bit VMCS field.

Panics if the field is not a 32-bit field, or if there is an error in the TDX module when reading the field.

Source

pub fn write_vmcs16( &mut self, vtl: GuestVtl, field: VmcsField, mask: u16, value: u16, ) -> u16

Write a 16-bit VMCS field.

Only updates the bits that are set in mask. Returns the old value of the field.

Panics if the field is not a 16-bit field, or if there is an error in the TDX module when writing the field.

Source

pub fn read_vmcs16(&self, vtl: GuestVtl, field: VmcsField) -> u16

Reads a 16-bit VMCS field.

Panics if the field is not a 16-bit field, or if there is an error in the TDX module when reading the field.

Source

pub fn write_msr_bitmap( &self, vtl: GuestVtl, i: u32, mask: u64, word: u64, ) -> u64

Writes 64-bit word with index i of the MSR bitmap.

Only updates the bits that are set in mask. Returns the old value of the word.

Panics if there is an error in the TDX module when writing the word.

Source

pub fn set_l2_ctls( &self, vtl: GuestVtl, value: TdxL2Ctls, ) -> Result<TdxL2Ctls, TdCallResult>

Sets the L2_CTLS field of the VP.

Returns the old value of the field.

Source

pub fn invgla( &self, gla_flags: TdGlaVmAndFlags, gla_info: TdxGlaListInfo, ) -> Result<(), TdCallResult>

Issues an INVGLA instruction for the VP.

Source

pub fn fx_state(&self) -> &Fxsave

Gets the FPU state for the VP.

Source

pub fn fx_state_mut(&mut self) -> &mut Fxsave

Sets the FPU state for the VP.

Source§

impl<'a> ProcessorRunner<'a, MshvX64<'a>>

Source

pub fn reg_page_vtl(&self) -> Result<GuestVtl, RegisterPageVtlError>

Returns the last VTL according to the register page.

Source

pub fn cpu_context(&self) -> &hcl_cpu_context_x64

Returns a reference to the current VTL’s CPU context.

Source

pub fn cpu_context_mut(&mut self) -> &mut hcl_cpu_context_x64

Returns a mutable reference to the current VTL’s CPU context.

Source

pub fn translate_gva_to_gpa( &mut self, gva: u64, control_flags: TranslateGvaControlFlagsX64, ) -> Result<Result<TranslateResult, TranslateErrorX64>, TranslateGvaToGpaError>

Translate the following gva to a gpa page in the context of the current VP.

The caller must ensure control_flags.input_vtl() is set to a specific VTL.

Source§

impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>

Source

pub fn flush_deferred_state(&mut self)

Flushes any deferred state. Must be called if preparing the partition for save/restore (servicing).

Source§

impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>

Source

pub fn clear_cancel(&mut self)

Clears the cancel flag so that the VP can be run again.

Source

pub fn set_halted(&mut self, halted: bool)

Set the halted state of the VP. If true, then run() will not actually run the VP but will just wait for a cancel request or signal.

Source

pub fn proxy_irr_vtl0(&mut self) -> Option<[u32; 8]>

Gets the proxied interrupt request bitmap for VTL 0 from the hypervisor.

Source

pub fn update_proxy_irr_filter_vtl0(&mut self, irr_filter: &[u32; 8])

Update the proxy_irr_blocked for VTL 0 in the run page

Source

pub fn proxy_irr_exit_mut_vtl0(&mut self) -> &mut [u32; 8]

Gets the proxy_irr_exit bitmask for VTL 0. This mask ensures that the masked interrupts always exit to user-space, and cannot be injected in the kernel. Interrupts matching this condition will be left on the proxy_irr field.

Source

pub fn offload_flags_mut(&mut self) -> &mut hcl_intr_offload_flags

Gets the current offload_flags from the run page.

Source

pub fn run_sidecar(&mut self) -> Result<SidecarRun<'_, 'a>, Error>

Runs the VP via the sidecar kernel.

Source

pub fn run(&mut self) -> Result<bool, Error>

Run the following VP until an exit, error, or interrupt (cancel or signal) occurs.

Returns Ok(true) if there is an exit to process, Ok(false) if there was a signal or cancel request.

Source

pub fn enter_mode(&mut self) -> Option<&mut EnterModes>

Gets a reference to enter mode value, used by the kernel to specify the mode used when entering a lower VTL.

Source

pub fn exit_message(&self) -> &HvMessage

Returns a reference to the exit message from the last exit.

Source

pub fn is_sidecar(&self) -> bool

Returns whether this is a sidecar VP.

Source§

impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>

Source

pub fn get_vp_register( &mut self, vtl: GuestVtl, name: HvX64RegisterName, ) -> Result<HvRegisterValue, Error>

Get the following register on the current VP.

This will fail for registers that are in the mmapped CPU context, i.e. registers that are shared between VTL0 and VTL2.

Source

pub fn get_vp_registers( &mut self, vtl: GuestVtl, names: &[HvX64RegisterName], values: &mut [HvRegisterValue], ) -> Result<(), Error>

Get the following VP registers on the current VP.

§Panics

Panics if names.len() != values.len().

Source

pub fn set_vp_register( &mut self, vtl: GuestVtl, name: HvX64RegisterName, value: HvRegisterValue, ) -> Result<(), Error>

Set the following register on the current VP.

This will fail for registers that are in the mmapped CPU context, i.e. registers that are shared between VTL0 and VTL2.

Source

pub fn set_vp_registers<I>( &mut self, vtl: GuestVtl, values: I, ) -> Result<(), Error>

Sets a set of VP registers.

Source

pub fn set_vp_registers_hvcall<I>( &mut self, vtl: Vtl, values: I, ) -> Result<(), HvError>

Sets the following registers on the current VP and given VTL using a direct hypercall.

This should not be used on the fast path. Therefore only a select set of registers are supported, and others will cause a panic.

This function can be used with VTL2 as a target.

Source

pub fn set_exit_vtl(&mut self, vtl: GuestVtl)

Sets the VTL that should be returned to when underhill exits

Trait Implementations§

Source§

impl<'a, T: Backing<'a>> Drop for ProcessorRunner<'a, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for ProcessorRunner<'a, T>
where T: Freeze,

§

impl<'a, T> !RefUnwindSafe for ProcessorRunner<'a, T>

§

impl<'a, T> !Send for ProcessorRunner<'a, T>

§

impl<'a, T> !Sync for ProcessorRunner<'a, T>

§

impl<'a, T> Unpin for ProcessorRunner<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for ProcessorRunner<'a, T>

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

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more