Skip to main content

GuestMemory

Trait GuestMemory 

Source
pub trait GuestMemory: Send + Sync {
    // Required methods
    fn read(&self, gpa: u64, buf: &mut [u8]) -> Result<()>;
    fn write(&self, gpa: u64, data: &[u8]) -> Result<()>;

    // Provided methods
    fn read_u64(&self, gpa: u64) -> Result<u64> { ... }
    fn read_u32(&self, gpa: u64) -> Result<u32> { ... }
}
Expand description

Access to guest-physical memory.

Implement this for whatever owns the guest RAM. The crate ships MappedMemory, which covers the common case where guest RAM is mapped into the tracer’s own address space (your own VMM, or QEMU via the LD_PRELOAD interposer).

Required Methods§

Source

fn read(&self, gpa: u64, buf: &mut [u8]) -> Result<()>

Copies buf.len() bytes starting at guest-physical address gpa.

Source

fn write(&self, gpa: u64, data: &[u8]) -> Result<()>

Copies data to guest-physical address gpa.

Provided Methods§

Source

fn read_u64(&self, gpa: u64) -> Result<u64>

Reads a little-endian u64.

Source

fn read_u32(&self, gpa: u64) -> Result<u32>

Reads a little-endian u32.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§