VmCtx

Struct VmCtx 

Source
pub struct VmCtx {
Show 30 fields pub futex: AtomicU32, pub program_counter: AtomicU32, pub jump_into: AtomicU64, pub next_native_program_counter: AtomicU64, pub tmp_reg: AtomicU64, pub rip: AtomicU64, pub next_program_counter: AtomicU32, pub arg: AtomicU32, pub arg2: AtomicU32, pub arg3: AtomicU32, pub _align_dummy: [u64; 4], pub gas: AtomicI64, pub regs: [AtomicU64; 13], pub heap_info: VmCtxHeapInfo, pub shm_memory_map_offset: AtomicU64, pub shm_memory_map_count: AtomicU64, pub shm_code_offset: AtomicU64, pub shm_code_length: AtomicU64, pub shm_jump_table_offset: AtomicU64, pub shm_jump_table_length: AtomicU64, pub sysreturn_address: AtomicU64, pub uffd_enabled: AtomicBool, pub heap_base: UnsafeCell<u32>, pub heap_initial_threshold: UnsafeCell<u32>, pub heap_max_size: UnsafeCell<u32>, pub page_size: UnsafeCell<u32>, pub counters: CacheAligned<VmCtxCounters>, pub init: VmInit, pub message_length: UnsafeCell<u32>, pub message_buffer: UnsafeCell<[u8; 512]>, /* private fields */
}
Expand description

The virtual machine context.

This is mapped in shared memory and used by the sandbox to keep its state in, as well as by the host to communicate with the sandbox.

Fields§

§futex: AtomicU32

The futex used to synchronize the sandbox with the host process.

§program_counter: AtomicU32

The address of the instruction currently being executed.

§jump_into: AtomicU64

Address to which to jump to.

§next_native_program_counter: AtomicU64

The address of the native code to call inside of the VM process, if non-zero.

§tmp_reg: AtomicU64§rip: AtomicU64§next_program_counter: AtomicU32

The address of the next instruction to be executed.

§arg: AtomicU32

A multipurpose field:

  • the hostcall number that was triggered,
  • the sbrk argument,
  • the sbrk return value,
§arg2: AtomicU32§arg3: AtomicU32§_align_dummy: [u64; 4]§gas: AtomicI64

The current gas counter.

§regs: [AtomicU64; 13]

A dump of all of the registers of the VM.

§heap_info: VmCtxHeapInfo

The state of the program’s heap.

§shm_memory_map_offset: AtomicU64

Offset in shared memory to this sandbox’s memory map.

§shm_memory_map_count: AtomicU64

Number of maps to map.

§shm_code_offset: AtomicU64

Offset in shared memory to this sandbox’s code.

§shm_code_length: AtomicU64

Length this sandbox’s code.

§shm_jump_table_offset: AtomicU64

Offset in shared memory to this sandbox’s jump table.

§shm_jump_table_length: AtomicU64

Length of sandbox’s jump table, in bytes.

§sysreturn_address: AtomicU64

Address of the sysreturn routine.

§uffd_enabled: AtomicBool

Whether userfaultfd-based memory management is enabled.

§heap_base: UnsafeCell<u32>

Address to the base of the heap.

§heap_initial_threshold: UnsafeCell<u32>

The initial heap growth threshold.

§heap_max_size: UnsafeCell<u32>

The maximum heap size.

§page_size: UnsafeCell<u32>

The page size.

§counters: CacheAligned<VmCtxCounters>

Performance counters. Only for debugging.

§init: VmInit

One-time args used during initialization.

§message_length: UnsafeCell<u32>

Length of the message in the message buffer.

§message_buffer: UnsafeCell<[u8; 512]>

A buffer used to marshal error messages.

Implementations§

Source§

impl VmCtx

Source

pub const fn zeroed() -> Self

Creates a zeroed VM context.

Source

pub const fn new() -> Self

Creates a fresh VM context.

Auto Trait Implementations§

§

impl !Freeze for VmCtx

§

impl !RefUnwindSafe for VmCtx

§

impl Send for VmCtx

§

impl !Sync for VmCtx

§

impl Unpin for VmCtx

§

impl UnwindSafe for VmCtx

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
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.