diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index c8285c231..3f01fe239 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -6,13 +6,14 @@ use crate::arch::emulator::{PlatformEmulator, PlatformError}; #[cfg(target_arch = "x86_64")] -use crate::arch::x86::emulator::{Emulator, EmulatorCpuState}; +use crate::arch::x86::emulator::{CpuStateManager, Emulator, EmulatorCpuState}; use crate::cpu; use crate::cpu::Vcpu; use crate::hypervisor; use crate::vec_with_array_field; use crate::vm::{self, InterruptSourceConfig, VmOps}; use crate::HypervisorType; +use iced_x86::Register; use mshv_bindings::*; use mshv_ioctls::{set_registers_64, InterruptRequest, Mshv, NoDatamatch, VcpuFd, VmFd, VmType}; use std::any::Any; @@ -1636,8 +1637,11 @@ impl<'a> PlatformEmulator for MshvEmulatorContext<'a> { self.translate(gva) } - fn fetch(&self, _ip: u64, _instruction_bytes: &mut [u8]) -> Result<(), PlatformError> { - Err(PlatformError::MemoryReadFailure(anyhow!("unimplemented"))) + fn fetch(&self, ip: u64, instruction_bytes: &mut [u8]) -> Result<(), PlatformError> { + let rip = + self.cpu_state(self.vcpu.vp_index as usize)? + .linearize(Register::CS, ip, false)?; + self.read_memory(rip, instruction_bytes) } }