xref: /linux/tools/testing/selftests/sgx/defines.h (revision 8a922b7728a93d837954315c98b84f6b78de0c4f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright(c) 2016-20 Intel Corporation.
4  */
5 
6 #ifndef DEFINES_H
7 #define DEFINES_H
8 
9 #include <stdint.h>
10 
11 #define PAGE_SIZE 4096
12 #define PAGE_MASK (~(PAGE_SIZE - 1))
13 
14 #define __aligned(x) __attribute__((__aligned__(x)))
15 #define __packed __attribute__((packed))
16 
17 #include "../../../../arch/x86/include/asm/sgx.h"
18 #include "../../../../arch/x86/include/asm/enclu.h"
19 #include "../../../../arch/x86/include/uapi/asm/sgx.h"
20 
21 enum encl_op_type {
22 	ENCL_OP_PUT_TO_BUFFER,
23 	ENCL_OP_GET_FROM_BUFFER,
24 	ENCL_OP_PUT_TO_ADDRESS,
25 	ENCL_OP_GET_FROM_ADDRESS,
26 	ENCL_OP_NOP,
27 	ENCL_OP_EACCEPT,
28 	ENCL_OP_EMODPE,
29 	ENCL_OP_INIT_TCS_PAGE,
30 	ENCL_OP_MAX,
31 };
32 
33 struct encl_op_header {
34 	uint64_t type;
35 };
36 
37 struct encl_op_put_to_buf {
38 	struct encl_op_header header;
39 	uint64_t value;
40 };
41 
42 struct encl_op_get_from_buf {
43 	struct encl_op_header header;
44 	uint64_t value;
45 };
46 
47 struct encl_op_put_to_addr {
48 	struct encl_op_header header;
49 	uint64_t value;
50 	uint64_t addr;
51 };
52 
53 struct encl_op_get_from_addr {
54 	struct encl_op_header header;
55 	uint64_t value;
56 	uint64_t addr;
57 };
58 
59 struct encl_op_eaccept {
60 	struct encl_op_header header;
61 	uint64_t epc_addr;
62 	uint64_t flags;
63 	uint64_t ret;
64 };
65 
66 struct encl_op_emodpe {
67 	struct encl_op_header header;
68 	uint64_t epc_addr;
69 	uint64_t flags;
70 };
71 
72 struct encl_op_init_tcs_page {
73 	struct encl_op_header header;
74 	uint64_t tcs_page;
75 	uint64_t ssa;
76 	uint64_t entry;
77 };
78 
79 #endif /* DEFINES_H */
80