Skip to main content

WorldMemory

Struct WorldMemory 

Source
struct WorldMemory {
    world_id: u64,
}
Expand description

World-facing memory adapter: linear guest-physical accesses through the world translation, page by page.

Fields§

§world_id: u64

Implementations§

Source§

impl WorldMemory

Source

const fn new(world_id: u64) -> Self

Source

fn read_bytes(&mut self, linear: u32, out: &mut [u8]) -> bool

Reads out.len() bytes at linear address linear.

Source

fn write_bytes(&mut self, linear: u32, bytes: &[u8]) -> bool

Writes bytes at linear address linear.

Source

fn word(&mut self, linear: u32) -> Option<u16>

Reads a little-endian u16.

Source

fn dword(&mut self, linear: u32) -> Option<u32>

Reads a little-endian u32.

Source

fn page(&self, linear: u64) -> Option<*mut u8>

HHDM pointer to the page containing linear (linear page-aligned).

Source

fn read_physical(&mut self, phys: u64, out: &mut [u8]) -> bool

Reads out.len() bytes at host-physical address phys.

The device fast path receives addresses that the second-level walk has already resolved, so they must not go through vm::debug_translate a second time: the higher-half direct map is the correct window. It is linear, so a page split is unnecessary, but the access stays byte-wise and volatile like the guest-physical one.

Source

fn write_physical(&mut self, phys: u64, bytes: &[u8]) -> bool

Writes bytes at host-physical address phys.

Trait Implementations§

Source§

impl BiosMemory for WorldMemory

Source§

fn read_u8(&mut self, linear: u32) -> Option<u8>

Reads one byte. Returns None when the address is not readable.
Source§

fn write_u8(&mut self, linear: u32, value: u8) -> bool

Writes one byte. Returns false when the address is not writable.
Source§

fn read(&mut self, linear: u32, out: &mut [u8]) -> bool

Reads out.len() bytes. Returns false when the range is not readable.
Source§

fn write(&mut self, linear: u32, bytes: &[u8]) -> bool

Writes bytes. Returns false when the range is not writable.
Source§

impl PhysMemory for WorldMemory

Physical view of the world for the device fast path.

emulate::MemoryView resolves a guest address through the second-level tables and then asks emulate::PhysMemory for the resulting host-physical bytes. The adapter therefore uses the direct-map accessors: forwarding to the guest-physical read_bytes/write_bytes would translate the address a second time (as if it were a GPA) and silently break every replayed access.

Source§

fn read_bytes(&mut self, phys: u64, out: &mut [u8]) -> bool

Copies out.len() bytes from phys into out.
Source§

fn write_bytes(&mut self, phys: u64, bytes: &[u8]) -> bool

Copies bytes to phys.
Source§

fn read_u64(&mut self, phys: u64) -> Option<u64>

Reads a little-endian 64-bit value.
Source§

impl RomMemory for WorldMemory

Source§

fn write(&mut self, linear: u32, bytes: &[u8]) -> bool

Writes bytes at linear. Returns false when the range is not writable or not mapped.
Source§

fn read(&mut self, linear: u32, out: &mut [u8]) -> bool

Reads out.len() bytes from linear. Returns false when the range is not readable or not mapped.
Source§

fn write_u16(&mut self, linear: u32, value: u16) -> bool

Writes a little-endian u16 at linear.
Source§

fn write_u32(&mut self, linear: u32, value: u32) -> bool

Writes a little-endian u32 at linear.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.