19 #ifndef ASYLO_PLATFORM_CORE_ENCLAVE_MANAGER_H_ 20 #define ASYLO_PLATFORM_CORE_ENCLAVE_MANAGER_H_ 28 #include "absl/container/flat_hash_map.h" 29 #include "absl/memory/memory.h" 30 #include "absl/status/status.h" 31 #include "absl/strings/string_view.h" 32 #include "absl/synchronization/mutex.h" 33 #include "absl/time/time.h" 34 #include "absl/types/variant.h" 35 #include "asylo/enclave.pb.h" 36 #include "asylo/platform/core/enclave_client.h" 37 #include "asylo/platform/core/enclave_config_util.h" 38 #include "asylo/platform/core/shared_resource_manager.h" 39 #include "asylo/platform/primitives/untrusted_primitives.h" 40 #include "asylo/platform/primitives/util/message.h" 41 #include "asylo/util/status.h" 42 #include "asylo/util/statusor.h" 63 class EnclaveManager {
173 ABSL_LOCKS_EXCLUDED(client_table_lock_);
182 ABSL_LOCKS_EXCLUDED(client_table_lock_);
202 ABSL_LOCKS_EXCLUDED(client_table_lock_);
208 return &shared_resource_manager_;
215 return &shared_resource_manager_;
221 ABSL_LOCKS_EXCLUDED(client_table_lock_);
224 EnclaveManager() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
225 EnclaveManager(EnclaveManager
const &) =
delete;
226 EnclaveManager &operator=(EnclaveManager
const &) =
delete;
233 Status LoadFakeEnclave(absl::string_view name,
const EnclaveLoader &loader,
234 const EnclaveConfig &config,
235 void *base_address =
nullptr,
236 const size_t enclave_size = 0)
237 ABSL_LOCKS_EXCLUDED(client_table_lock_);
241 void RemoveEnclaveReference(absl::string_view name)
242 ABSL_LOCKS_EXCLUDED(client_table_lock_);
245 SharedResourceManager shared_resource_manager_;
248 std::atomic<int64_t> clock_monotonic_;
251 std::atomic<int64_t> clock_realtime_;
255 mutable absl::Mutex client_table_lock_;
257 absl::flat_hash_map<std::string, std::unique_ptr<EnclaveClient>>
258 client_by_name_ ABSL_GUARDED_BY(client_table_lock_);
259 absl::flat_hash_map<
const EnclaveClient *, std::string> name_by_client_
260 ABSL_GUARDED_BY(client_table_lock_);
262 absl::flat_hash_map<
const EnclaveClient *, EnclaveLoadConfig>
263 load_config_by_client_ ABSL_GUARDED_BY(client_table_lock_);
266 static absl::Mutex mu_;
269 static EnclaveManager *instance_ ABSL_GUARDED_BY(mu_);
299 "EnclaveLoader::LoadEnclave not implemented for test enclave");
static StatusOr< EnclaveManager * > Instance()
Fetches the EnclaveManager singleton instance.
Status LoadEnclave(absl::string_view name, const EnclaveLoader &loader, EnclaveConfig config, void *base_address=nullptr, const size_t enclave_size=0)
Loads an enclave.
Status LoadEnclave(const EnclaveLoadConfig &load_config)
Loads an enclave.
EnclaveClient * GetClient(absl::string_view name) const ABSL_LOCKS_EXCLUDED(client_table_lock_)
Fetches a client to a loaded enclave.
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
static Status Configure(const EnclaveManagerOptions &options)
virtual ~EnclaveLoader()=default
SharedResourceManager * shared_resources()
Fetches the shared resource manager object.
Definition: enclave_manager.h:207
Status LoadEnclave(absl::string_view name, const EnclaveLoader &loader, void *base_address=nullptr, const size_t enclave_size=0)
Loads an enclave.
Enclave Manager configuration.
Definition: enclave_manager.h:49
const SharedResourceManager * shared_resources() const
Fetches the shared resource manager object.
Definition: enclave_manager.h:214
const absl::string_view GetName(const EnclaveClient *client) const ABSL_LOCKS_EXCLUDED(client_table_lock_)
Returns the name of an enclave client.
EnclaveLoadConfig GetLoadConfigFromClient(EnclaveClient *client) ABSL_LOCKS_EXCLUDED(client_table_lock_)
Get the load config of an enclave.
Status DestroyEnclave(EnclaveClient *client, const EnclaveFinal &final_input, bool skip_finalize=false) ABSL_LOCKS_EXCLUDED(client_table_lock_)
Destroys an enclave.
primitives::Client * LoadEnclaveInChildProcess(absl::string_view enclave_name, void *enclave_base_address, size_t enclave_size)
virtual EnclaveLoadConfig GetEnclaveLoadConfig() const =0