mirror of
https://github.com/intel/linux-sgx
synced 2026-06-08 14:49:32 +00:00
83655bc3ce
Follows up on 590856d (removing the Linux LE).
Removes all of whitelist management and LE facilities from the AESM and SDK.
Leaves only skeleton API stubs behind (for partial ABI compatibility).
!BREAKING CHANGES!
- Launch-related stub(`libsgx_launch.so`) and simulation (`libsgx_launch_sim.so`) libraries
removed from the SGX SDK.
- Removed AESM support for the deprecated Linux SGX out-of-tree (OOT) driver
(will no longer attempt an enclave load if OOT driver is detected)
- AESM APIs for launch control and whitelist management will now
return SGX_ERROR_FEATURE_NOT_SUPPORTED:
Affected APIs:
* get_launch_token(...)
* sgx_get_whitelist_size(...)
* sgx_get_whitelist(...)
* sgx_register_wl_cert_chain(...)
- Deprecated `sgx_uae_launch.h` SDK header
- Marked init token inputs `reserved` in the relevant loader APIs (no longer in use)
---------
Co-authored-by: Krzysztof1 Wisniewski <krzysztof1.wisniewski@intel.com>
Signed-off-by: Mateusz Bronk <mateusz.bronk@intel.com>
108 lines
4.9 KiB
C++
108 lines
4.9 KiB
C++
/*
|
|
* Copyright (C) 2011-2021 Intel Corporation. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* * Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in
|
|
* the documentation and/or other materials provided with the
|
|
* distribution.
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
* contributors may be used to endorse or promote products derived
|
|
* from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
*/
|
|
|
|
|
|
#ifndef _LOADER_H_
|
|
#define _LOADER_H_
|
|
|
|
#include "se_wrapper.h"
|
|
#include "arch.h"
|
|
#include "enclave.h"
|
|
#include "enclave_creator.h"
|
|
#include "section_info.h"
|
|
#include "launch_checker.h"
|
|
#include "file.h"
|
|
|
|
#define GET_RELOC_FAILED ((uint8_t *)-1)
|
|
|
|
#if defined(SE_SIM)
|
|
#define ENCLAVE_ID_IOCTL m_enclave_id
|
|
#else
|
|
//only translate enclave id to start address for linux HW mode.
|
|
#define ENCLAVE_ID_IOCTL (sgx_enclave_id_t)((uintptr_t)m_start_addr)
|
|
#endif
|
|
|
|
class BinParser;
|
|
|
|
class CLoader: private Uncopyable
|
|
{
|
|
public:
|
|
CLoader(uint8_t *mapped_file_base, BinParser &parser);
|
|
virtual ~CLoader();
|
|
int load_enclave(Reserved_FormerlyLaunchToken *reserved, int flag, const metadata_t *metadata, sgx_config_id_t *config_id, sgx_config_svn_t config_svn, le_prd_css_file_t *prd_css_file = NULL, sgx_misc_attribute_t *misc_attr = NULL);
|
|
int load_enclave_ex(Reserved_FormerlyLaunchToken *reserved, bool is_debug, const metadata_t *metadata, sgx_config_id_t *config_id, sgx_config_svn_t config_svn, le_prd_css_file_t *prd_css_file = NULL, sgx_misc_attribute_t *misc_attr = NULL);
|
|
int destroy_enclave();
|
|
sgx_enclave_id_t get_enclave_id() const;
|
|
const void* get_start_addr() const;
|
|
uint64_t get_elrange_start_addr() const;
|
|
uint64_t get_elrange_size() const;
|
|
const secs_t& get_secs() const;
|
|
const std::vector<std::pair<tcs_t *, bool>>& get_tcs_list() const;
|
|
void* get_symbol_address(const char* const sym);
|
|
int set_memory_protection();
|
|
|
|
private:
|
|
int build_mem_region(const section_info_t &sec_info);
|
|
int build_image(Reserved_FormerlyLaunchToken * const reserved, sgx_attributes_t * const secs_attr, sgx_config_id_t *config_id, sgx_config_svn_t config_svn, le_prd_css_file_t *prd_css_file, sgx_misc_attribute_t * const misc_attr);
|
|
int build_secs(sgx_attributes_t * const secs_attr, sgx_config_id_t *config_id, sgx_config_svn_t config_svn, sgx_misc_attribute_t * const misc_attr);
|
|
int build_context(const uint64_t start_rva, layout_entry_t *layout);
|
|
int build_contexts(layout_t *layout_start, layout_t *layout_end, uint64_t delta);
|
|
int build_partial_page(const uint64_t rva, const uint64_t size, const void *source, const sec_info_t &sinfo, const uint32_t attr);
|
|
int build_pages(const uint64_t start_rva, const uint64_t size, const void *source, const sec_info_t &sinfo, const uint32_t attr);
|
|
bool is_relocation_page(const uint64_t rva, std::vector<uint8_t> *bitmap);
|
|
|
|
bool is_ae(const enclave_css_t *enclave_css);
|
|
bool is_metadata_buffer(uint32_t offset, uint32_t size);
|
|
bool is_enclave_buffer(uint64_t offset, uint64_t size);
|
|
int validate_layout_table();
|
|
int validate_patch_table();
|
|
int validate_metadata();
|
|
int get_debug_flag(const token_t * const reserved);
|
|
virtual int build_sections(std::vector<uint8_t> *bitmap);
|
|
int set_context_protection(layout_t *layout_start, layout_t *layout_end, uint64_t delta);
|
|
int set_elrange_config();
|
|
|
|
uint8_t *m_mapped_file_base;
|
|
sgx_enclave_id_t m_enclave_id;
|
|
void *m_start_addr;
|
|
uint64_t m_elrange_start_address;
|
|
uint64_t m_elrange_size;
|
|
|
|
// the TCS list
|
|
std::vector<std::pair<tcs_t *, bool>> m_tcs_list;
|
|
// the enclave creation parameters
|
|
const metadata_t *m_metadata;
|
|
secs_t m_secs;
|
|
BinParser &m_parser;
|
|
};
|
|
|
|
#endif
|