Struct GuestAddress
pub struct GuestAddress(pub u64);Expand description
Represents a guest physical address (GPA).
§Notes:
On ARM64, a 32-bit hypervisor may be used to support a 64-bit guest. For simplicity,
u64 is used to store the the raw value no matter if the guest a 32-bit or 64-bit virtual
machine.
Tuple Fields§
§0: u64Trait Implementations§
§impl Address for GuestAddress
impl Address for GuestAddress
§fn new(value: u64) -> GuestAddress
fn new(value: u64) -> GuestAddress
Creates an address from a raw address value.
§fn checked_offset_from(&self, base: GuestAddress) -> Option<u64>
fn checked_offset_from(&self, base: GuestAddress) -> Option<u64>
Computes the offset from this address to the given base address. Read more
§fn checked_add(&self, other: u64) -> Option<GuestAddress>
fn checked_add(&self, other: u64) -> Option<GuestAddress>
Computes
self + other, returning None if overflow occurred.§fn overflowing_add(&self, other: u64) -> (GuestAddress, bool)
fn overflowing_add(&self, other: u64) -> (GuestAddress, bool)
Computes
self + other. Read more§fn unchecked_add(&self, offset: u64) -> GuestAddress
fn unchecked_add(&self, offset: u64) -> GuestAddress
Computes
self + offset. Read more§fn checked_sub(&self, other: u64) -> Option<GuestAddress>
fn checked_sub(&self, other: u64) -> Option<GuestAddress>
Subtracts two addresses, checking for underflow. If underflow happens,
None is returned.§fn overflowing_sub(&self, other: u64) -> (GuestAddress, bool)
fn overflowing_sub(&self, other: u64) -> (GuestAddress, bool)
Computes
self - other. Read more§fn unchecked_sub(&self, other: u64) -> GuestAddress
fn unchecked_sub(&self, other: u64) -> GuestAddress
Computes
self - other. Read more§fn mask(&self, mask: Self::V) -> Self::V
fn mask(&self, mask: Self::V) -> Self::V
Returns the bitwise and of the address with the given mask.
§fn unchecked_offset_from(&self, base: Self) -> Self::V
fn unchecked_offset_from(&self, base: Self) -> Self::V
Computes the offset from this address to the given base address. Read more
§fn checked_align_up(&self, power_of_two: Self::V) -> Option<Self>
fn checked_align_up(&self, power_of_two: Self::V) -> Option<Self>
Returns self, aligned to the given power of two.
§fn unchecked_align_up(&self, power_of_two: Self::V) -> Self
fn unchecked_align_up(&self, power_of_two: Self::V) -> Self
Returns self, aligned to the given power of two.
Only use this when the result is guaranteed not to overflow.
§impl AddressValue for GuestAddress
impl AddressValue for GuestAddress
§impl BitAnd<u64> for GuestAddress
impl BitAnd<u64> for GuestAddress
§type Output = GuestAddress
type Output = GuestAddress
The resulting type after applying the
& operator.§fn bitand(self, other: u64) -> GuestAddress
fn bitand(self, other: u64) -> GuestAddress
Performs the
& operation. Read more§impl BitOr<u64> for GuestAddress
impl BitOr<u64> for GuestAddress
§type Output = GuestAddress
type Output = GuestAddress
The resulting type after applying the
| operator.§fn bitor(self, other: u64) -> GuestAddress
fn bitor(self, other: u64) -> GuestAddress
Performs the
| operation. Read more§impl<T> Bytes<GuestAddress> for Twhere
T: GuestMemory + ?Sized,
impl<T> Bytes<GuestAddress> for Twhere
T: GuestMemory + ?Sized,
§fn write_slice(&self, buf: &[u8], addr: GuestAddress) -> Result<(), Error>
fn write_slice(&self, buf: &[u8], addr: GuestAddress) -> Result<(), Error>
§Examples
- Write a slice at guestaddress 0x1000. (uses the
backend-mmapfeature)
gm.write_slice(&[1, 2, 3, 4, 5], start_addr)
.expect("Could not write slice to guest memory");§fn read_slice(&self, buf: &mut [u8], addr: GuestAddress) -> Result<(), Error>
fn read_slice(&self, buf: &mut [u8], addr: GuestAddress) -> Result<(), Error>
§Examples
- Read a slice of length 16 at guestaddress 0x1000. (uses the
backend-mmapfeature)
let start_addr = GuestAddress(0x1000);
let mut gm = GuestMemoryMmap::<()>::from_ranges(&vec![(start_addr, 0x400)])
.expect("Could not create guest memory");
let buf = &mut [0u8; 16];
gm.read_slice(buf, start_addr)
.expect("Could not read slice from guest memory");§fn write(&self, buf: &[u8], addr: GuestAddress) -> Result<usize, Error>
fn write(&self, buf: &[u8], addr: GuestAddress) -> Result<usize, Error>
Writes a slice into the container at
addr. Read more§fn read(&self, buf: &mut [u8], addr: GuestAddress) -> Result<usize, Error>
fn read(&self, buf: &mut [u8], addr: GuestAddress) -> Result<usize, Error>
Reads data from the container at
addr into a slice. Read more§fn read_volatile_from<F>(
&self,
addr: GuestAddress,
src: &mut F,
count: usize,
) -> Result<usize, Error>where
F: ReadVolatile,
fn read_volatile_from<F>(
&self,
addr: GuestAddress,
src: &mut F,
count: usize,
) -> Result<usize, Error>where
F: ReadVolatile,
Reads up to
count bytes from src and writes them into the container at addr.
Unlike VolatileRead::read_volatile, this function retries on EINTR being returned from
the underlying I/O read operation. Read more§fn read_exact_volatile_from<F>(
&self,
addr: GuestAddress,
src: &mut F,
count: usize,
) -> Result<(), Error>where
F: ReadVolatile,
fn read_exact_volatile_from<F>(
&self,
addr: GuestAddress,
src: &mut F,
count: usize,
) -> Result<(), Error>where
F: ReadVolatile,
§fn write_volatile_to<F>(
&self,
addr: GuestAddress,
dst: &mut F,
count: usize,
) -> Result<usize, Error>where
F: WriteVolatile,
fn write_volatile_to<F>(
&self,
addr: GuestAddress,
dst: &mut F,
count: usize,
) -> Result<usize, Error>where
F: WriteVolatile,
Reads up to
count bytes from the container at addr and writes them into dst.
Unlike VolatileWrite::write_volatile, this function retries on EINTR being returned by
the underlying I/O write operation. Read more§fn write_all_volatile_to<F>(
&self,
addr: GuestAddress,
dst: &mut F,
count: usize,
) -> Result<(), Error>where
F: WriteVolatile,
fn write_all_volatile_to<F>(
&self,
addr: GuestAddress,
dst: &mut F,
count: usize,
) -> Result<(), Error>where
F: WriteVolatile,
§fn store<O>(
&self,
val: O,
addr: GuestAddress,
order: Ordering,
) -> Result<(), Error>where
O: AtomicAccess,
fn store<O>(
&self,
val: O,
addr: GuestAddress,
order: Ordering,
) -> Result<(), Error>where
O: AtomicAccess,
Atomically store a value at the specified address.
§fn load<O>(&self, addr: GuestAddress, order: Ordering) -> Result<O, Error>where
O: AtomicAccess,
fn load<O>(&self, addr: GuestAddress, order: Ordering) -> Result<O, Error>where
O: AtomicAccess,
Atomically load a value from the specified address.
§impl Clone for GuestAddress
impl Clone for GuestAddress
§fn clone(&self) -> GuestAddress
fn clone(&self) -> GuestAddress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for GuestAddress
impl Debug for GuestAddress
§impl Default for GuestAddress
impl Default for GuestAddress
§fn default() -> GuestAddress
fn default() -> GuestAddress
Returns the “default value” for a type. Read more
§impl Ord for GuestAddress
impl Ord for GuestAddress
§impl PartialEq for GuestAddress
impl PartialEq for GuestAddress
§impl PartialOrd for GuestAddress
impl PartialOrd for GuestAddress
impl Copy for GuestAddress
impl Eq for GuestAddress
impl StructuralPartialEq for GuestAddress
Auto Trait Implementations§
impl Freeze for GuestAddress
impl RefUnwindSafe for GuestAddress
impl Send for GuestAddress
impl Sync for GuestAddress
impl Unpin for GuestAddress
impl UnwindSafe for GuestAddress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.