2020-06-03 19:23:56 +00:00
|
|
|
// Copyright © 2019 Intel Corporation
|
|
|
|
//
|
2020-06-26 00:06:14 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
|
2020-06-03 19:23:56 +00:00
|
|
|
//
|
2020-06-28 16:32:56 +00:00
|
|
|
// Copyright © 2020, Microsoft Corporation
|
2020-06-03 19:23:56 +00:00
|
|
|
//
|
|
|
|
// Copyright 2018-2019 CrowdStrike, Inc.
|
|
|
|
//
|
2020-06-26 00:06:14 +00:00
|
|
|
//
|
2020-06-03 19:23:56 +00:00
|
|
|
|
|
|
|
#[cfg(target_arch = "aarch64")]
|
2022-07-28 03:35:21 +00:00
|
|
|
use crate::aarch64::{RegList, StandardRegisters, VcpuInit};
|
2022-07-14 20:59:27 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2022-07-19 21:41:00 +00:00
|
|
|
use crate::arch::x86::{
|
|
|
|
CpuIdEntry, FpuState, LapicState, MsrEntry, SpecialRegisters, StandardRegisters,
|
|
|
|
};
|
2022-05-11 16:21:25 +00:00
|
|
|
#[cfg(feature = "tdx")]
|
|
|
|
use crate::kvm::{TdxExitDetails, TdxExitStatus};
|
2020-12-03 23:24:57 +00:00
|
|
|
use crate::CpuState;
|
|
|
|
use crate::MpState;
|
2020-06-03 19:23:56 +00:00
|
|
|
use thiserror::Error;
|
2022-02-20 02:49:25 +00:00
|
|
|
use vm_memory::GuestAddress;
|
2020-06-03 19:23:56 +00:00
|
|
|
|
2023-05-30 12:39:57 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
#[derive(Copy, Clone, Default)]
|
|
|
|
pub enum CpuVendor {
|
|
|
|
#[default]
|
|
|
|
Unknown,
|
|
|
|
Intel,
|
|
|
|
AMD,
|
|
|
|
}
|
|
|
|
|
2020-06-03 19:23:56 +00:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
///
|
|
|
|
/// Enum for CPU error
|
|
|
|
pub enum HypervisorCpuError {
|
|
|
|
///
|
|
|
|
/// Setting standard registers error
|
|
|
|
///
|
|
|
|
#[error("Failed to set standard register: {0}")]
|
|
|
|
SetStandardRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting standard registers error
|
|
|
|
///
|
|
|
|
#[error("Failed to get standard registers: {0}")]
|
|
|
|
GetStandardRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting special register error
|
|
|
|
///
|
|
|
|
#[error("Failed to set special registers: {0}")]
|
|
|
|
SetSpecialRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting standard register error
|
|
|
|
///
|
|
|
|
#[error("Failed to get special registers: {0}")]
|
|
|
|
GetSpecialRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting floating point registers error
|
|
|
|
///
|
2022-10-16 08:29:03 +00:00
|
|
|
#[error("Failed to set floating point registers: {0}")]
|
2020-06-03 19:23:56 +00:00
|
|
|
SetFloatingPointRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting floating point register error
|
|
|
|
///
|
2022-10-16 08:29:03 +00:00
|
|
|
#[error("Failed to get floating points registers: {0}")]
|
2020-06-03 19:23:56 +00:00
|
|
|
GetFloatingPointRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting Cpuid error
|
|
|
|
///
|
|
|
|
#[error("Failed to set Cpuid: {0}")]
|
|
|
|
SetCpuid(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Cpuid error
|
|
|
|
///
|
|
|
|
#[error("Failed to get Cpuid: {0}")]
|
|
|
|
GetCpuid(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting lapic state error
|
|
|
|
///
|
|
|
|
#[error("Failed to set Lapic state: {0}")]
|
|
|
|
SetLapicState(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Lapic state error
|
|
|
|
///
|
|
|
|
#[error("Failed to get Lapic state: {0}")]
|
|
|
|
GetlapicState(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting MSR entries error
|
|
|
|
///
|
|
|
|
#[error("Failed to set Msr entries: {0}")]
|
|
|
|
SetMsrEntries(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Msr entries error
|
|
|
|
///
|
|
|
|
#[error("Failed to get Msr entries: {0}")]
|
|
|
|
GetMsrEntries(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting MSR entries error
|
|
|
|
///
|
|
|
|
#[error("Failed to set MP state: {0}")]
|
|
|
|
SetMpState(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Msr entries error
|
|
|
|
///
|
|
|
|
#[error("Failed to get MP state: {0}")]
|
|
|
|
GetMpState(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting Saved Processor Extended States error
|
|
|
|
///
|
|
|
|
#[error("Failed to set Saved Processor Extended States: {0}")]
|
|
|
|
SetXsaveState(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Saved Processor Extended States error
|
|
|
|
///
|
|
|
|
#[error("Failed to get Saved Processor Extended States: {0}")]
|
|
|
|
GetXsaveState(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting Extended Control Registers error
|
|
|
|
///
|
|
|
|
#[error("Failed to set Extended Control Registers: {0}")]
|
|
|
|
SetXcsr(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Extended Control Registers error
|
|
|
|
///
|
|
|
|
#[error("Failed to get Extended Control Registers: {0}")]
|
|
|
|
GetXcsr(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Running Vcpu error
|
|
|
|
///
|
|
|
|
#[error("Failed to run vcpu: {0}")]
|
|
|
|
RunVcpu(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting Vcpu events error
|
|
|
|
///
|
|
|
|
#[error("Failed to get Vcpu events: {0}")]
|
|
|
|
GetVcpuEvents(#[source] anyhow::Error),
|
|
|
|
///
|
2020-06-24 14:52:41 +00:00
|
|
|
/// Setting Vcpu events error
|
|
|
|
///
|
|
|
|
#[error("Failed to set Vcpu events: {0}")]
|
|
|
|
SetVcpuEvents(#[source] anyhow::Error),
|
|
|
|
///
|
2020-06-03 19:23:56 +00:00
|
|
|
/// Vcpu Init error
|
|
|
|
///
|
|
|
|
#[error("Failed to init vcpu: {0}")]
|
|
|
|
VcpuInit(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting one reg error
|
|
|
|
///
|
|
|
|
#[error("Failed to init vcpu: {0}")]
|
2020-10-07 14:45:25 +00:00
|
|
|
SetRegister(#[source] anyhow::Error),
|
2020-06-03 19:23:56 +00:00
|
|
|
///
|
|
|
|
/// Getting one reg error
|
|
|
|
///
|
|
|
|
#[error("Failed to init vcpu: {0}")]
|
2020-10-07 14:45:25 +00:00
|
|
|
GetRegister(#[source] anyhow::Error),
|
2020-06-23 14:42:00 +00:00
|
|
|
///
|
|
|
|
/// Getting guest clock paused error
|
|
|
|
///
|
|
|
|
#[error("Failed to notify guest its clock was paused: {0}")]
|
|
|
|
NotifyGuestClockPaused(#[source] anyhow::Error),
|
2020-09-15 15:15:50 +00:00
|
|
|
///
|
2020-12-03 23:24:57 +00:00
|
|
|
/// Setting debug register error
|
|
|
|
///
|
|
|
|
#[error("Failed to set debug registers: {0}")]
|
|
|
|
SetDebugRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting debug register error
|
|
|
|
///
|
|
|
|
#[error("Failed to get debug registers: {0}")]
|
|
|
|
GetDebugRegs(#[source] anyhow::Error),
|
|
|
|
///
|
2021-09-30 19:41:32 +00:00
|
|
|
/// Setting misc register error
|
|
|
|
///
|
|
|
|
#[error("Failed to set misc registers: {0}")]
|
|
|
|
SetMiscRegs(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting misc register error
|
|
|
|
///
|
|
|
|
#[error("Failed to get misc registers: {0}")]
|
|
|
|
GetMiscRegs(#[source] anyhow::Error),
|
|
|
|
///
|
2020-12-03 23:24:57 +00:00
|
|
|
/// Write to Guest Mem
|
|
|
|
///
|
|
|
|
#[error("Failed to write to Guest Mem at: {0}")]
|
|
|
|
GuestMemWrite(#[source] anyhow::Error),
|
2020-09-15 15:15:50 +00:00
|
|
|
/// Enabling HyperV SynIC error
|
|
|
|
///
|
|
|
|
#[error("Failed to enable HyperV SynIC")]
|
2021-03-25 17:01:21 +00:00
|
|
|
EnableHyperVSyncIc(#[source] anyhow::Error),
|
2020-08-28 09:06:54 +00:00
|
|
|
///
|
2020-08-30 08:44:39 +00:00
|
|
|
/// Getting AArch64 core register error
|
|
|
|
///
|
|
|
|
#[error("Failed to get core register: {0}")]
|
|
|
|
GetCoreRegister(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Setting AArch64 core register error
|
|
|
|
///
|
|
|
|
#[error("Failed to set core register: {0}")]
|
|
|
|
SetCoreRegister(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Getting AArch64 registers list error
|
|
|
|
///
|
|
|
|
#[error("Failed to retrieve list of registers: {0}")]
|
|
|
|
GetRegList(#[source] anyhow::Error),
|
|
|
|
///
|
2020-08-28 09:06:54 +00:00
|
|
|
/// Getting AArch64 system register error
|
|
|
|
///
|
|
|
|
#[error("Failed to get system register: {0}")]
|
|
|
|
GetSysRegister(#[source] anyhow::Error),
|
2020-08-30 08:44:39 +00:00
|
|
|
///
|
|
|
|
/// Setting AArch64 system register error
|
|
|
|
///
|
|
|
|
#[error("Failed to set system register: {0}")]
|
|
|
|
SetSysRegister(#[source] anyhow::Error),
|
2021-03-01 18:07:02 +00:00
|
|
|
///
|
|
|
|
/// GVA translation error
|
|
|
|
///
|
|
|
|
#[error("Failed to translate GVA: {0}")]
|
2021-03-25 17:01:21 +00:00
|
|
|
TranslateVirtualAddress(#[source] anyhow::Error),
|
2021-02-12 15:17:18 +00:00
|
|
|
///
|
2022-01-11 06:39:42 +00:00
|
|
|
/// Set cpu attribute error
|
|
|
|
///
|
|
|
|
#[error("Failed to set vcpu attribute: {0}")]
|
|
|
|
SetVcpuAttribute(#[source] anyhow::Error),
|
|
|
|
///
|
|
|
|
/// Check if cpu has a certain attribute error
|
|
|
|
///
|
|
|
|
#[error("Failed to check if vcpu has attribute: {0}")]
|
|
|
|
HasVcpuAttribute(#[source] anyhow::Error),
|
|
|
|
///
|
2021-02-12 15:17:18 +00:00
|
|
|
/// Failed to initialize TDX on CPU
|
|
|
|
///
|
|
|
|
#[cfg(feature = "tdx")]
|
|
|
|
#[error("Failed to initialize TDX: {0}")]
|
|
|
|
InitializeTdx(#[source] std::io::Error),
|
2022-02-16 14:39:54 +00:00
|
|
|
///
|
|
|
|
/// Unknown TDX VM call
|
|
|
|
///
|
|
|
|
#[cfg(feature = "tdx")]
|
|
|
|
#[error("Unknown TDX VM call")]
|
|
|
|
UnknownTdxVmCall,
|
2022-07-20 11:42:24 +00:00
|
|
|
#[cfg(target_arch = "aarch64")]
|
|
|
|
///
|
2023-08-31 13:00:19 +00:00
|
|
|
/// Failed to initialize PMU
|
2022-07-20 11:42:24 +00:00
|
|
|
///
|
|
|
|
#[error("Failed to initialize PMU")]
|
|
|
|
InitializePmu,
|
2023-02-08 19:06:15 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Error getting TSC frequency
|
|
|
|
///
|
|
|
|
#[error("Failed to get TSC frequency: {0}")]
|
|
|
|
GetTscKhz(#[source] anyhow::Error),
|
2020-06-03 19:23:56 +00:00
|
|
|
}
|
|
|
|
|
2020-07-03 14:27:53 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum VmExit<'a> {
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
IoOut(u16 /* port */, &'a [u8] /* data */),
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
IoIn(u16 /* port */, &'a mut [u8] /* data */),
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
IoapicEoi(u8 /* vector */),
|
|
|
|
MmioRead(u64 /* address */, &'a mut [u8]),
|
|
|
|
MmioWrite(u64 /* address */, &'a [u8]),
|
|
|
|
Ignore,
|
|
|
|
Reset,
|
2020-10-30 13:34:16 +00:00
|
|
|
Shutdown,
|
2020-09-15 15:17:23 +00:00
|
|
|
Hyperv,
|
2022-02-16 14:39:54 +00:00
|
|
|
#[cfg(feature = "tdx")]
|
|
|
|
Tdx,
|
2022-01-30 10:26:32 +00:00
|
|
|
#[cfg(feature = "kvm")]
|
|
|
|
Debug,
|
2020-07-03 14:27:53 +00:00
|
|
|
}
|
|
|
|
|
2020-06-03 19:23:56 +00:00
|
|
|
///
|
|
|
|
/// Result type for returning from a function
|
|
|
|
///
|
|
|
|
pub type Result<T> = anyhow::Result<T, HypervisorCpuError>;
|
|
|
|
///
|
|
|
|
/// Trait to represent a generic Vcpu
|
|
|
|
///
|
|
|
|
pub trait Vcpu: Send + Sync {
|
|
|
|
///
|
|
|
|
/// Returns the vCPU general purpose registers.
|
|
|
|
///
|
|
|
|
fn get_regs(&self) -> Result<StandardRegisters>;
|
|
|
|
///
|
|
|
|
/// Sets the vCPU general purpose registers.
|
|
|
|
///
|
|
|
|
fn set_regs(&self, regs: &StandardRegisters) -> Result<()>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Returns the vCPU special registers.
|
|
|
|
///
|
|
|
|
fn get_sregs(&self) -> Result<SpecialRegisters>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Sets the vCPU special registers
|
|
|
|
///
|
|
|
|
fn set_sregs(&self, sregs: &SpecialRegisters) -> Result<()>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Returns the floating point state (FPU) from the vCPU.
|
|
|
|
///
|
|
|
|
fn get_fpu(&self) -> Result<FpuState>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Set the floating point state (FPU) of a vCPU
|
|
|
|
///
|
|
|
|
fn set_fpu(&self, fpu: &FpuState) -> Result<()>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// X86 specific call to setup the CPUID registers.
|
|
|
|
///
|
2022-07-15 10:20:07 +00:00
|
|
|
fn set_cpuid2(&self, cpuid: &[CpuIdEntry]) -> Result<()>;
|
2020-06-03 19:23:56 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
2020-09-15 15:15:50 +00:00
|
|
|
/// X86 specific call to enable HyperV SynIC
|
|
|
|
///
|
|
|
|
fn enable_hyperv_synic(&self) -> Result<()>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
2020-06-03 19:23:56 +00:00
|
|
|
/// X86 specific call to retrieve the CPUID registers.
|
|
|
|
///
|
2022-07-15 10:20:07 +00:00
|
|
|
fn get_cpuid2(&self, num_entries: usize) -> Result<Vec<CpuIdEntry>>;
|
2020-06-03 19:23:56 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Returns the state of the LAPIC (Local Advanced Programmable Interrupt Controller).
|
|
|
|
///
|
|
|
|
fn get_lapic(&self) -> Result<LapicState>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Sets the state of the LAPIC (Local Advanced Programmable Interrupt Controller).
|
|
|
|
///
|
|
|
|
fn set_lapic(&self, lapic: &LapicState) -> Result<()>;
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Returns the model-specific registers (MSR) for this vCPU.
|
|
|
|
///
|
2022-07-19 09:51:18 +00:00
|
|
|
fn get_msrs(&self, msrs: &mut Vec<MsrEntry>) -> Result<usize>;
|
2020-06-03 19:23:56 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Setup the model-specific registers (MSR) for this vCPU.
|
|
|
|
///
|
2022-07-19 09:51:18 +00:00
|
|
|
fn set_msrs(&self, msrs: &[MsrEntry]) -> Result<usize>;
|
2020-06-03 19:23:56 +00:00
|
|
|
///
|
|
|
|
/// Returns the vcpu's current "multiprocessing state".
|
|
|
|
///
|
|
|
|
fn get_mp_state(&self) -> Result<MpState>;
|
|
|
|
///
|
|
|
|
/// Sets the vcpu's current "multiprocessing state".
|
|
|
|
///
|
|
|
|
fn set_mp_state(&self, mp_state: MpState) -> Result<()>;
|
2022-07-20 22:02:43 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2020-06-24 14:52:41 +00:00
|
|
|
///
|
2020-06-23 14:42:00 +00:00
|
|
|
/// Let the guest know that it has been paused, which prevents from
|
|
|
|
/// potential soft lockups when being resumed.
|
|
|
|
///
|
2022-07-20 22:02:43 +00:00
|
|
|
fn notify_guest_clock_paused(&self) -> Result<()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-02-20 02:49:25 +00:00
|
|
|
///
|
|
|
|
/// Sets debug registers to set hardware breakpoints and/or enable single step.
|
|
|
|
///
|
2022-07-20 22:02:43 +00:00
|
|
|
fn set_guest_debug(&self, _addrs: &[GuestAddress], _singlestep: bool) -> Result<()> {
|
|
|
|
Err(HypervisorCpuError::SetDebugRegs(anyhow!("unimplemented")))
|
|
|
|
}
|
2020-06-03 19:23:56 +00:00
|
|
|
///
|
|
|
|
/// Sets the type of CPU to be exposed to the guest and optional features.
|
|
|
|
///
|
2022-06-21 03:39:54 +00:00
|
|
|
#[cfg(target_arch = "aarch64")]
|
2020-06-03 19:23:56 +00:00
|
|
|
fn vcpu_init(&self, kvi: &VcpuInit) -> Result<()>;
|
|
|
|
///
|
2020-08-30 08:44:39 +00:00
|
|
|
/// Gets a list of the guest registers that are supported for the
|
|
|
|
/// KVM_GET_ONE_REG/KVM_SET_ONE_REG calls.
|
|
|
|
///
|
2022-06-21 03:39:54 +00:00
|
|
|
#[cfg(target_arch = "aarch64")]
|
2020-08-30 08:44:39 +00:00
|
|
|
fn get_reg_list(&self, reg_list: &mut RegList) -> Result<()>;
|
|
|
|
///
|
2022-07-28 06:52:34 +00:00
|
|
|
/// Gets the value of a system register
|
|
|
|
///
|
|
|
|
#[cfg(target_arch = "aarch64")]
|
|
|
|
fn get_sys_reg(&self, sys_reg: u32) -> Result<u64>;
|
|
|
|
///
|
2022-06-06 07:17:59 +00:00
|
|
|
/// Configure core registers for a given CPU.
|
|
|
|
///
|
2022-06-21 03:39:54 +00:00
|
|
|
#[cfg(target_arch = "aarch64")]
|
2022-06-06 07:17:59 +00:00
|
|
|
fn setup_regs(&self, cpu_id: u8, boot_ip: u64, fdt_start: u64) -> Result<()>;
|
|
|
|
///
|
2022-07-20 11:42:24 +00:00
|
|
|
/// Check if the CPU supports PMU
|
|
|
|
///
|
|
|
|
#[cfg(target_arch = "aarch64")]
|
|
|
|
fn has_pmu_support(&self) -> bool;
|
|
|
|
///
|
|
|
|
/// Initialize PMU
|
|
|
|
///
|
|
|
|
#[cfg(target_arch = "aarch64")]
|
|
|
|
fn init_pmu(&self, irq: u32) -> Result<()>;
|
|
|
|
///
|
2020-07-03 08:54:36 +00:00
|
|
|
/// Retrieve the vCPU state.
|
|
|
|
/// This function is necessary to snapshot the VM
|
2020-06-03 19:23:56 +00:00
|
|
|
///
|
2020-07-03 08:54:36 +00:00
|
|
|
fn state(&self) -> Result<CpuState>;
|
2020-06-03 19:23:56 +00:00
|
|
|
///
|
2020-07-03 08:54:36 +00:00
|
|
|
/// Set the vCPU state.
|
2020-06-03 19:23:56 +00:00
|
|
|
/// This function is required when restoring the VM
|
|
|
|
///
|
2020-07-03 08:54:36 +00:00
|
|
|
fn set_state(&self, state: &CpuState) -> Result<()>;
|
2020-07-03 14:27:53 +00:00
|
|
|
///
|
|
|
|
/// Triggers the running of the current virtual CPU returning an exit reason.
|
|
|
|
///
|
|
|
|
fn run(&self) -> std::result::Result<VmExit, HypervisorCpuError>;
|
2022-02-20 02:44:25 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2021-03-01 18:07:02 +00:00
|
|
|
///
|
|
|
|
/// Translate guest virtual address to guest physical address
|
|
|
|
///
|
2022-02-19 05:52:48 +00:00
|
|
|
fn translate_gva(&self, gva: u64, flags: u64) -> Result<(u64, u32)>;
|
2021-02-12 15:17:18 +00:00
|
|
|
///
|
|
|
|
/// Initialize TDX support on the vCPU
|
|
|
|
///
|
|
|
|
#[cfg(feature = "tdx")]
|
2022-09-27 11:28:30 +00:00
|
|
|
fn tdx_init(&self, _hob_address: u64) -> Result<()> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
2022-02-07 14:36:39 +00:00
|
|
|
///
|
|
|
|
/// Set the "immediate_exit" state
|
|
|
|
///
|
2022-07-20 22:02:43 +00:00
|
|
|
fn set_immediate_exit(&self, _exit: bool) {}
|
2022-02-16 14:39:54 +00:00
|
|
|
#[cfg(feature = "tdx")]
|
|
|
|
///
|
|
|
|
/// Returns the details about TDX exit reason
|
|
|
|
///
|
2022-09-27 11:28:30 +00:00
|
|
|
fn get_tdx_exit_details(&mut self) -> Result<TdxExitDetails> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
2022-02-16 14:39:54 +00:00
|
|
|
#[cfg(feature = "tdx")]
|
|
|
|
///
|
|
|
|
/// Set the status code for TDX exit
|
|
|
|
///
|
2022-09-27 11:28:30 +00:00
|
|
|
fn set_tdx_status(&mut self, _status: TdxExitStatus) {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
2022-07-08 14:08:10 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Return the list of initial MSR entries for a VCPU
|
|
|
|
///
|
2022-07-19 09:51:18 +00:00
|
|
|
fn boot_msr_entries(&self) -> Vec<MsrEntry>;
|
2023-02-08 19:06:15 +00:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
///
|
|
|
|
/// Get the frequency of the TSC if available
|
|
|
|
///
|
|
|
|
fn tsc_khz(&self) -> Result<Option<u32>> {
|
|
|
|
Ok(None)
|
|
|
|
}
|
2020-06-03 19:23:56 +00:00
|
|
|
}
|