pub struct GuestSharedMemory {
pub lock: Arc<RwLock<()>>,
/* private fields */
}
Expand description
A GuestSharedMemory is used to represent the reference to all-of-memory that is taken by the virtual cpu. Because of the memory model limitations that affect HostSharedMemory, it is likely fairly important (to ensure that our UB remains limited to interaction with an external compilation unit that likely can’t be discovered by the compiler) that rust users do not perform racy accesses to the guest communication buffers that are also accessed by HostSharedMemory.
Fields§
§lock: Arc<RwLock<()>>
The lock that indicates this shared memory is being used by non-Rust code
This lock must be held whenever the guest is executing, because it prevents the host from converting its HostSharedMemory to an ExclusiveSharedMemory. Since the guest may arbitrarily mutate the shared memory, only synchronized accesses from Rust should be allowed!
We cannot enforce this in the type system, because the memory is mapped in to the VM at VM creation time.
Trait Implementations§
Source§fn region(&self) -> &HostMapping
fn region(&self) -> &HostMapping
Source§fn with_exclusivity<T, F: FnOnce(&mut ExclusiveSharedMemory) -> T>(
&mut self,
f: F,
) -> Result<T>
fn with_exclusivity<T, F: FnOnce(&mut ExclusiveSharedMemory) -> T>( &mut self, f: F, ) -> Result<T>
Source§fn base_addr(&self) -> usize
fn base_addr(&self) -> usize
unsafe
because doing anything with this
pointer itself requires unsafe
.Source§fn base_ptr(&self) -> *mut u8
fn base_ptr(&self) -> *mut u8
unsafe
because doing anything with
this pointer itself requires unsafe
.Source§fn mem_size(&self) -> usize
fn mem_size(&self) -> usize
self
.
The returned size does not include the size of the surrounding
guard pages.