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>
impl ProcessorRunner<'_, MshvArm64>
Sourcepub fn cpu_context(&self) -> &hcl_cpu_context_aarch64
pub fn cpu_context(&self) -> &hcl_cpu_context_aarch64
Returns a reference to the current VTL’s CPU context.
Sourcepub fn cpu_context_mut(&mut self) -> &mut hcl_cpu_context_aarch64
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>>
impl<'a> ProcessorRunner<'a, Snp<'a>>
Sourcepub fn vmsa(&self, vtl: GuestVtl) -> VmsaWrapper<'_, &SevVmsa>
pub fn vmsa(&self, vtl: GuestVtl) -> VmsaWrapper<'_, &SevVmsa>
Gets a reference to the VMSA and backing state of a VTL
Sourcepub fn vmsa_mut(&mut self, vtl: GuestVtl) -> VmsaWrapper<'_, &mut SevVmsa>
pub fn vmsa_mut(&mut self, vtl: GuestVtl) -> VmsaWrapper<'_, &mut SevVmsa>
Gets a mutable reference to the VMSA and backing state of a VTL.
Sourcepub fn vmsas_mut(&mut self) -> [VmsaWrapper<'_, &mut SevVmsa>; 2]
pub fn vmsas_mut(&mut self) -> [VmsaWrapper<'_, &mut SevVmsa>; 2]
Returns the VMSAs for [VTL0, VTL1].
Source§impl<'a> ProcessorRunner<'a, Tdx<'a>>
impl<'a> ProcessorRunner<'a, Tdx<'a>>
Sourcepub fn tdx_enter_guest_gps(&self) -> &[u64; 16]
pub fn tdx_enter_guest_gps(&self) -> &[u64; 16]
Gets a reference to the TDX enter guest state’s GP list.
Sourcepub fn tdx_enter_guest_gps_mut(&mut self) -> &mut [u64; 16]
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.
Sourcepub fn tdx_vp_enter_exit_info(&self) -> &tdx_tdg_vp_enter_exit_info
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.
Sourcepub fn tdx_apic_page(&self, vtl: GuestVtl) -> &ApicPage
pub fn tdx_apic_page(&self, vtl: GuestVtl) -> &ApicPage
Gets a reference to the tdx APIC page for the given VTL.
Sourcepub fn tdx_apic_page_mut(&mut self, vtl: GuestVtl) -> &mut ApicPage
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.
Sourcepub fn tdx_vp_state_flags_mut(&mut self) -> &mut tdx_vp_state_flags
pub fn tdx_vp_state_flags_mut(&mut self) -> &mut tdx_vp_state_flags
Gets a mutable reference to TDX specific VP flags.
Sourcepub fn read_private_regs(&self, regs: &mut TdxPrivateRegs)
pub fn read_private_regs(&self, regs: &mut TdxPrivateRegs)
Reads the private registers from the kernel’s shared run page into
the given TdxPrivateRegs
.
Sourcepub fn write_private_regs(&mut self, regs: &TdxPrivateRegs)
pub fn write_private_regs(&mut self, regs: &TdxPrivateRegs)
Writes the private registers from the given TdxPrivateRegs
to the
kernel’s shared run page.
Sourcepub fn write_vmcs64(
&mut self,
vtl: GuestVtl,
field: VmcsField,
mask: u64,
value: u64,
) -> u64
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.
Sourcepub fn read_vmcs64(&self, vtl: GuestVtl, field: VmcsField) -> u64
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.
Sourcepub fn write_vmcs32(
&mut self,
vtl: GuestVtl,
field: VmcsField,
mask: u32,
value: u32,
) -> u32
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.
Sourcepub fn read_vmcs32(&self, vtl: GuestVtl, field: VmcsField) -> u32
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.
Sourcepub fn write_vmcs16(
&mut self,
vtl: GuestVtl,
field: VmcsField,
mask: u16,
value: u16,
) -> u16
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.
Sourcepub fn read_vmcs16(&self, vtl: GuestVtl, field: VmcsField) -> u16
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.
Sourcepub fn write_msr_bitmap(
&self,
vtl: GuestVtl,
i: u32,
mask: u64,
word: u64,
) -> u64
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.
Sourcepub fn set_l2_ctls(
&self,
vtl: GuestVtl,
value: TdxL2Ctls,
) -> Result<TdxL2Ctls, TdCallResult>
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.
Sourcepub fn invgla(
&self,
gla_flags: TdGlaVmAndFlags,
gla_info: TdxGlaListInfo,
) -> Result<(), TdCallResult>
pub fn invgla( &self, gla_flags: TdGlaVmAndFlags, gla_info: TdxGlaListInfo, ) -> Result<(), TdCallResult>
Issues an INVGLA instruction for the VP.
Sourcepub fn fx_state_mut(&mut self) -> &mut Fxsave
pub fn fx_state_mut(&mut self) -> &mut Fxsave
Sets the FPU state for the VP.
Source§impl<'a> ProcessorRunner<'a, MshvX64<'a>>
impl<'a> ProcessorRunner<'a, MshvX64<'a>>
Sourcepub fn reg_page_vtl(&self) -> Result<GuestVtl, RegisterPageVtlError>
pub fn reg_page_vtl(&self) -> Result<GuestVtl, RegisterPageVtlError>
Returns the last VTL according to the register page.
Sourcepub fn cpu_context(&self) -> &hcl_cpu_context_x64
pub fn cpu_context(&self) -> &hcl_cpu_context_x64
Returns a reference to the current VTL’s CPU context.
Sourcepub fn cpu_context_mut(&mut self) -> &mut hcl_cpu_context_x64
pub fn cpu_context_mut(&mut self) -> &mut hcl_cpu_context_x64
Returns a mutable reference to the current VTL’s CPU context.
Sourcepub fn translate_gva_to_gpa(
&mut self,
gva: u64,
control_flags: TranslateGvaControlFlagsX64,
) -> Result<Result<TranslateResult, TranslateErrorX64>, TranslateGvaToGpaError>
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>
impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>
Sourcepub fn flush_deferred_state(&mut self)
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>
impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>
Sourcepub fn clear_cancel(&mut self)
pub fn clear_cancel(&mut self)
Clears the cancel flag so that the VP can be run again.
Sourcepub fn set_halted(&mut self, halted: bool)
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.
Sourcepub fn proxy_irr_vtl0(&mut self) -> Option<[u32; 8]>
pub fn proxy_irr_vtl0(&mut self) -> Option<[u32; 8]>
Gets the proxied interrupt request bitmap for VTL 0 from the hypervisor.
Sourcepub fn update_proxy_irr_filter_vtl0(&mut self, irr_filter: &[u32; 8])
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
Sourcepub fn proxy_irr_exit_mut_vtl0(&mut self) -> &mut [u32; 8]
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.
Sourcepub fn offload_flags_mut(&mut self) -> &mut hcl_intr_offload_flags
pub fn offload_flags_mut(&mut self) -> &mut hcl_intr_offload_flags
Gets the current offload_flags from the run page.
Sourcepub fn run_sidecar(&mut self) -> Result<SidecarRun<'_, 'a>, Error>
pub fn run_sidecar(&mut self) -> Result<SidecarRun<'_, 'a>, Error>
Runs the VP via the sidecar kernel.
Sourcepub fn run(&mut self) -> Result<bool, Error>
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.
Sourcepub fn enter_mode(&mut self) -> Option<&mut EnterModes>
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.
Sourcepub fn exit_message(&self) -> &HvMessage
pub fn exit_message(&self) -> &HvMessage
Returns a reference to the exit message from the last exit.
Sourcepub fn is_sidecar(&self) -> bool
pub fn is_sidecar(&self) -> bool
Returns whether this is a sidecar VP.
Source§impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>
impl<'a, T: Backing<'a>> ProcessorRunner<'a, T>
Sourcepub fn get_vp_register(
&mut self,
vtl: GuestVtl,
name: HvX64RegisterName,
) -> Result<HvRegisterValue, Error>
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.
Sourcepub fn get_vp_registers(
&mut self,
vtl: GuestVtl,
names: &[HvX64RegisterName],
values: &mut [HvRegisterValue],
) -> Result<(), Error>
pub fn get_vp_registers( &mut self, vtl: GuestVtl, names: &[HvX64RegisterName], values: &mut [HvRegisterValue], ) -> Result<(), Error>
Sourcepub fn set_vp_register(
&mut self,
vtl: GuestVtl,
name: HvX64RegisterName,
value: HvRegisterValue,
) -> Result<(), Error>
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.
Sourcepub fn set_vp_registers<I>(
&mut self,
vtl: GuestVtl,
values: I,
) -> Result<(), Error>
pub fn set_vp_registers<I>( &mut self, vtl: GuestVtl, values: I, ) -> Result<(), Error>
Sets a set of VP registers.
Sourcepub fn set_vp_registers_hvcall<I>(
&mut self,
vtl: Vtl,
values: I,
) -> Result<(), HvError>
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.
Sourcepub fn set_exit_vtl(&mut self, vtl: GuestVtl)
pub fn set_exit_vtl(&mut self, vtl: GuestVtl)
Sets the VTL that should be returned to when underhill exits
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
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) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
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
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.