xref: /linux/tools/testing/selftests/sgx/main.h (revision 07f0148aafe8c95a3a76cd59e9e75b4d78d1d31d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright(c) 2016-20 Intel Corporation.
4  */
5 
6 #ifndef MAIN_H
7 #define MAIN_H
8 
9 #define ENCL_HEAP_SIZE_DEFAULT	4096
10 
11 struct encl_segment {
12 	void *src;
13 	off_t offset;
14 	size_t size;
15 	unsigned int prot;
16 	unsigned int flags;
17 	bool measure;
18 };
19 
20 struct encl {
21 	int fd;
22 	void *bin;
23 	off_t bin_size;
24 	void *src;
25 	size_t src_size;
26 	size_t encl_size;
27 	off_t encl_base;
28 	unsigned int nr_segments;
29 	struct encl_segment *segment_tbl;
30 	struct sgx_secs secs;
31 	struct sgx_sigstruct sigstruct;
32 };
33 
34 extern unsigned char sign_key[];
35 extern unsigned char sign_key_end[];
36 
37 void encl_delete(struct encl *ctx);
38 bool encl_load(const char *path, struct encl *encl, unsigned long heap_size);
39 bool encl_measure(struct encl *encl);
40 bool encl_build(struct encl *encl);
41 uint64_t encl_get_entry(struct encl *encl, const char *symbol);
42 
43 int sgx_enter_enclave(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9,
44 		      struct sgx_enclave_run *run);
45 
46 #endif /* MAIN_H */
47