selftests/x86: Add a selftest for SGX
[linux-2.6-block.git] / tools / testing / selftests / sgx / main.h
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 struct encl_segment {
10         off_t offset;
11         size_t size;
12         unsigned int prot;
13         unsigned int flags;
14 };
15
16 struct encl {
17         int fd;
18         void *bin;
19         off_t bin_size;
20         void *src;
21         size_t src_size;
22         size_t encl_size;
23         off_t encl_base;
24         unsigned int nr_segments;
25         struct encl_segment *segment_tbl;
26         struct sgx_secs secs;
27         struct sgx_sigstruct sigstruct;
28 };
29
30 void encl_delete(struct encl *ctx);
31 bool encl_load(const char *path, struct encl *encl);
32 bool encl_measure(struct encl *encl);
33 bool encl_build(struct encl *encl);
34
35 int sgx_call_vdso(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9,
36                   struct sgx_enclave_run *run);
37
38 #endif /* MAIN_H */