xref: /linux/tools/testing/selftests/sgx/defines.h (revision 022416496008bd51cb7b33975cc0008749329a86)
12adcba79SJarkko Sakkinen /* SPDX-License-Identifier: GPL-2.0 */
22adcba79SJarkko Sakkinen /*
32adcba79SJarkko Sakkinen  * Copyright(c) 2016-20 Intel Corporation.
42adcba79SJarkko Sakkinen  */
52adcba79SJarkko Sakkinen 
62adcba79SJarkko Sakkinen #ifndef DEFINES_H
72adcba79SJarkko Sakkinen #define DEFINES_H
82adcba79SJarkko Sakkinen 
92adcba79SJarkko Sakkinen #include <stdint.h>
102adcba79SJarkko Sakkinen 
112adcba79SJarkko Sakkinen #define PAGE_SIZE 4096
122adcba79SJarkko Sakkinen #define PAGE_MASK (~(PAGE_SIZE - 1))
132adcba79SJarkko Sakkinen 
142adcba79SJarkko Sakkinen #define __aligned(x) __attribute__((__aligned__(x)))
152adcba79SJarkko Sakkinen #define __packed __attribute__((packed))
16a4c39ef4SJo Van Bulck #define __used __attribute__((used))
17*02241649SJo Van Bulck #define __section(x)__attribute__((__section__(x)))
182adcba79SJarkko Sakkinen 
198ca52cc3SSean Christopherson #include "../../../../arch/x86/include/asm/sgx.h"
202adcba79SJarkko Sakkinen #include "../../../../arch/x86/include/asm/enclu.h"
212adcba79SJarkko Sakkinen #include "../../../../arch/x86/include/uapi/asm/sgx.h"
222adcba79SJarkko Sakkinen 
2322118ce1SJarkko Sakkinen enum encl_op_type {
24c085dfc7SReinette Chatre 	ENCL_OP_PUT_TO_BUFFER,
25c085dfc7SReinette Chatre 	ENCL_OP_GET_FROM_BUFFER,
26abc5cec4SReinette Chatre 	ENCL_OP_PUT_TO_ADDRESS,
27abc5cec4SReinette Chatre 	ENCL_OP_GET_FROM_ADDRESS,
28688542e2SReinette Chatre 	ENCL_OP_NOP,
2920404a80SReinette Chatre 	ENCL_OP_EACCEPT,
3020404a80SReinette Chatre 	ENCL_OP_EMODPE,
31b564982fSReinette Chatre 	ENCL_OP_INIT_TCS_PAGE,
3241493a09SJarkko Sakkinen 	ENCL_OP_MAX,
3322118ce1SJarkko Sakkinen };
3422118ce1SJarkko Sakkinen 
3541493a09SJarkko Sakkinen struct encl_op_header {
3622118ce1SJarkko Sakkinen 	uint64_t type;
3741493a09SJarkko Sakkinen };
3841493a09SJarkko Sakkinen 
39c085dfc7SReinette Chatre struct encl_op_put_to_buf {
4041493a09SJarkko Sakkinen 	struct encl_op_header header;
4141493a09SJarkko Sakkinen 	uint64_t value;
4241493a09SJarkko Sakkinen };
4341493a09SJarkko Sakkinen 
44c085dfc7SReinette Chatre struct encl_op_get_from_buf {
4541493a09SJarkko Sakkinen 	struct encl_op_header header;
4641493a09SJarkko Sakkinen 	uint64_t value;
4722118ce1SJarkko Sakkinen };
4822118ce1SJarkko Sakkinen 
49abc5cec4SReinette Chatre struct encl_op_put_to_addr {
50abc5cec4SReinette Chatre 	struct encl_op_header header;
51abc5cec4SReinette Chatre 	uint64_t value;
52abc5cec4SReinette Chatre 	uint64_t addr;
53abc5cec4SReinette Chatre };
54abc5cec4SReinette Chatre 
55abc5cec4SReinette Chatre struct encl_op_get_from_addr {
56abc5cec4SReinette Chatre 	struct encl_op_header header;
57abc5cec4SReinette Chatre 	uint64_t value;
58abc5cec4SReinette Chatre 	uint64_t addr;
59abc5cec4SReinette Chatre };
60abc5cec4SReinette Chatre 
6120404a80SReinette Chatre struct encl_op_eaccept {
6220404a80SReinette Chatre 	struct encl_op_header header;
6320404a80SReinette Chatre 	uint64_t epc_addr;
6420404a80SReinette Chatre 	uint64_t flags;
6520404a80SReinette Chatre 	uint64_t ret;
6620404a80SReinette Chatre };
6720404a80SReinette Chatre 
6820404a80SReinette Chatre struct encl_op_emodpe {
6920404a80SReinette Chatre 	struct encl_op_header header;
7020404a80SReinette Chatre 	uint64_t epc_addr;
7120404a80SReinette Chatre 	uint64_t flags;
7220404a80SReinette Chatre };
7320404a80SReinette Chatre 
74b564982fSReinette Chatre struct encl_op_init_tcs_page {
75b564982fSReinette Chatre 	struct encl_op_header header;
76b564982fSReinette Chatre 	uint64_t tcs_page;
77b564982fSReinette Chatre 	uint64_t ssa;
78b564982fSReinette Chatre 	uint64_t entry;
79b564982fSReinette Chatre };
80b564982fSReinette Chatre 
812adcba79SJarkko Sakkinen #endif /* DEFINES_H */
82