mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: emulator: Add initial fetch support
When the x86 instruction decoder tells us about some missing bytes from the instruction stream, we call into the platform fetch method and emulate one last instruction. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
7dc92d1dac
commit
1ac4c42a84
@@ -71,6 +71,9 @@ pub enum EmulationError<T: Debug> {
|
||||
#[error("Instruction Exception: {0}")]
|
||||
InstructionException(Exception<T>),
|
||||
|
||||
#[error("Instruction fetching error: {0}")]
|
||||
InstructionFetchingError(#[source] anyhow::Error),
|
||||
|
||||
#[error("Platform emulation error: {0}")]
|
||||
PlatformEmulationError(PlatformError),
|
||||
}
|
||||
@@ -126,6 +129,14 @@ pub trait PlatformEmulator: Send + Sync {
|
||||
/// * `gva` - Guest virtual address to translate.
|
||||
///
|
||||
fn gva_to_gpa(&self, gva: u64) -> Result<u64, PlatformError>;
|
||||
|
||||
/// Fetch instruction bytes from memory.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ip` - Instruction pointer virtual address to start fetching instructions from.
|
||||
///
|
||||
fn fetch(&self, ip: u64, instruction_bytes: &mut [u8]) -> Result<(), PlatformError>;
|
||||
}
|
||||
|
||||
pub type EmulationResult<S, E> = std::result::Result<S, EmulationError<E>>;
|
||||
|
||||
Reference in New Issue
Block a user