linux-stable/tools/testing/selftests/sgx/main.h
Reinette Chatre 33c5aac3bf selftests/sgx: Test complete changing of page type flow
Support for changing an enclave page's type enables an initialized
enclave to be expanded with support for more threads by changing the
type of a regular enclave page to that of a Thread Control Structure
(TCS).  Additionally, being able to change a TCS or regular enclave
page's type to be trimmed (SGX_PAGE_TYPE_TRIM) initiates the removal
of the page from the enclave.

Test changing page type to TCS as well as page removal flows
in two phases: In the first phase support for a new thread is
dynamically added to an initialized enclave and in the second phase
the pages associated with the new thread are removed from the enclave.
As an additional sanity check after the second phase the page used as
a TCS page during the first phase is added back as a regular page and
ensured that it can be written to (which is not possible if it was a
TCS page).

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lkml.kernel.org/r/d05b48b00338683a94dcaef9f478540fc3d6d5f9.1652137848.git.reinette.chatre@intel.com
2022-07-07 10:13:04 -07:00

46 lines
993 B
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright(c) 2016-20 Intel Corporation.
*/
#ifndef MAIN_H
#define MAIN_H
#define ENCL_HEAP_SIZE_DEFAULT 4096
struct encl_segment {
void *src;
off_t offset;
size_t size;
unsigned int prot;
unsigned int flags;
bool measure;
};
struct encl {
int fd;
void *bin;
off_t bin_size;
void *src;
size_t src_size;
size_t encl_size;
off_t encl_base;
unsigned int nr_segments;
struct encl_segment *segment_tbl;
struct sgx_secs secs;
struct sgx_sigstruct sigstruct;
};
extern unsigned char sign_key[];
extern unsigned char sign_key_end[];
void encl_delete(struct encl *ctx);
bool encl_load(const char *path, struct encl *encl, unsigned long heap_size);
bool encl_measure(struct encl *encl);
bool encl_build(struct encl *encl);
uint64_t encl_get_entry(struct encl *encl, const char *symbol);
int sgx_enter_enclave(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9,
struct sgx_enclave_run *run);
#endif /* MAIN_H */