class Environment
Defined at line 54 of file ../../src/bringup/lib/restricted-machine/include/bringup/lib/restricted-machine/environment.h
restricted_machine::Environment provides the necessary environment for
restricted machine computation to occur. It is responsible for:
- ElfMachine-appropriate mapped and loaded ELF binary blobs.
- Symbol resolution for loaded blobs.
- Accessible memory mapping and allocation.
- Hardware support checking.
Environments may be reused across multiple Machine instances, but any
writable memory shared between them must be managed by the Machine caller
or code run by the Machine-itself.
Public Members
static const size_t kDefaultMemoryPoolSize
static basic_string_view kPingFunctionName
static basic_string_view kThunkFunctionName
static basic_string_view kCallerBlobName
Public Methods
void ~Environment ()
Defined at line 28 of file ../../src/bringup/lib/restricted-machine/environment.cc
void Environment ()
Defined at line 56 of file ../../src/bringup/lib/restricted-machine/include/bringup/lib/restricted-machine/environment.h
bool HardwareSupported (const MachineType & machine)
Confirms that restricted mode is supported for the target machine
architecture.
Defined at line 140 of file ../../src/bringup/lib/restricted-machine/environment.cc
bool Initialize (MachineType machine, size_t shared_mem_size, uint64_t address_limit)
Initializes the environment for a given machine type.
This sets up a shared memory VMO that can be used for allocating memory
accessible to code running within the restricted machine.
|machine|: The target machine architecture. Defaults to the running
architecture.
|shared_mem_size|: The size of the shared memory pool to allocate.
|address_limit|: The upper bound on memory addresses accessible within the
environment.
Defined at line 34 of file ../../src/bringup/lib/restricted-machine/environment.cc
zx::result<> AddLoadableBlob (const std::string_view & vmo_name, std::optional<zx_vaddr_t> map_at)
Loads and maps a blob from a VMO, exposing all discoverable symbols.
|vmo_name|: The name of the VMO to load.
|map_at|: An optional address to map the blob at.
Defined at line 104 of file ../../src/bringup/lib/restricted-machine/environment.cc
zx::result<> AddLoadableBlob (const std::string_view & vmo_name, const std::vector<std::string_view> & symbols, bool export_symbols, std::optional<zx_vaddr_t> map_at)
Loads and maps a blob from a VMO, exposing only the requested symbols.
|vmo_name|: The name of the VMO to load.
|symbols|: A list of symbols to expose.
|export_symbols|: If true, the symbols are exported for other blobs to use.
|map_at|: An optional address to map the blob at.
Defined at line 115 of file ../../src/bringup/lib/restricted-machine/environment.cc
template <typename T, typename... Args>
zx::result<Argument<T>> MakeArgumentResult (Args... args)
Allocates and constructs an object in the shared memory pool.
Returns a zx::result containing an Argument
<T
> on success.
Defined at line 124 of file ../../src/bringup/lib/restricted-machine/include/bringup/lib/restricted-machine/environment.h
template <typename T, typename... Args>
Argument<T> MakeArgument (Args... args)
A convenience wrapper for MakeArgumentResult that asserts on failure.
Defined at line 137 of file ../../src/bringup/lib/restricted-machine/include/bringup/lib/restricted-machine/environment.h
zx::result<Allocation> Allocate (size_t size)
Allocates a region of memory from the shared memory pool.
|size|: The size of the allocation.
Defined at line 157 of file ../../src/bringup/lib/restricted-machine/environment.cc
zx::result<uint64_t> SymbolAddress (std::string_view name)
Returns the address of a symbol.
|name|: The name of the symbol to look up.
Defined at line 171 of file ../../src/bringup/lib/restricted-machine/environment.cc
std::string GetLoadableBlobPath (const std::string_view & prefix)
Returns the "path" to the loadable .so which is requested from the loader
using the given client-specific |prefix|.
Defined at line 109 of file ../../src/bringup/lib/restricted-machine/environment.cc
MachineType machine ()
Returns the machine type of the environment.
Defined at line 153 of file ../../src/bringup/lib/restricted-machine/include/bringup/lib/restricted-machine/environment.h
uint64_t address_limit ()
Returns the address limit of the environment.
Defined at line 156 of file ../../src/bringup/lib/restricted-machine/include/bringup/lib/restricted-machine/environment.h