gdb: Do not use VmmOps for memory manipulation

We don't use the VmmOps trait directly for manipulating memory in the
core of the VMM as it's really designed for the MSHV crate to handle
instruction decoding. As I plan to make this trait MSHV specific to
allow reduced locking for MMIO and PIO handling when running on KVM this
use should be removed.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2022-05-04 15:22:27 +01:00 committed by Bo Chen
parent 5bd7a1f03c
commit c47e3b8689
2 changed files with 15 additions and 13 deletions

View File

@ -46,8 +46,9 @@ use std::sync::{Arc, Barrier, Mutex};
use std::{cmp, io, result, thread};
use thiserror::Error;
use vm_device::BusDevice;
use vm_memory::GuestAddress;
use vm_memory::GuestMemoryAtomic;
#[cfg(feature = "gdb")]
use vm_memory::{Bytes, GuestAddressSpace};
use vm_memory::{GuestAddress, GuestMemoryAtomic};
use vm_migration::{
Migratable, MigratableError, Pausable, Snapshot, SnapshotDataSection, Snapshottable,
Transportable,
@ -2046,10 +2047,11 @@ impl Debuggable for CpuManager {
};
let psize = arch::PAGE_SIZE as u64;
let read_len = std::cmp::min(len as u64 - total_read, psize - (paddr & (psize - 1)));
self.vmmops
.guest_mem_read(
paddr,
self.vm_memory
.memory()
.read(
&mut buf[total_read as usize..total_read as usize + read_len as usize],
GuestAddress(paddr),
)
.map_err(DebuggableError::ReadMem)?;
total_read += read_len;
@ -2078,10 +2080,11 @@ impl Debuggable for CpuManager {
data.len() as u64 - total_written,
psize - (paddr & (psize - 1)),
);
self.vmmops
.guest_mem_write(
paddr,
self.vm_memory
.memory()
.write(
&data[total_written as usize..total_written as usize + write_len as usize],
GuestAddress(paddr),
)
.map_err(DebuggableError::WriteMem)?;
total_written += write_len;

View File

@ -5,8 +5,6 @@
//
// SPDX-License-Identifier: BSD-3-Clause
use std::{os::unix::net::UnixListener, sync::mpsc};
use gdbstub::{
arch::Arch,
common::{Signal, Tid},
@ -30,7 +28,8 @@ use gdbstub::{
use gdbstub_arch::x86::reg::X86_64CoreRegs as CoreRegs;
#[cfg(target_arch = "x86_64")]
use gdbstub_arch::x86::X86_64_SSE as GdbArch;
use vm_memory::GuestAddress;
use std::{os::unix::net::UnixListener, sync::mpsc};
use vm_memory::{GuestAddress, GuestMemoryError};
#[cfg(target_arch = "x86_64")]
type ArchUsize = u64;
@ -42,8 +41,8 @@ pub enum DebuggableError {
Resume(vm_migration::MigratableError),
ReadRegs(crate::cpu::Error),
WriteRegs(crate::cpu::Error),
ReadMem(hypervisor::HypervisorVmError),
WriteMem(hypervisor::HypervisorVmError),
ReadMem(GuestMemoryError),
WriteMem(GuestMemoryError),
TranslateGva(crate::cpu::Error),
PoisonedState,
}