1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ***   To edit the content of this header, modify the corresponding
11  ***   source file (e.g. under external/kernel-headers/original/) then
12  ***   run bionic/libc/kernel/tools/update_all.py
13  ***
14  ***   Any manual change here will be lost the next time this script will
15  ***   be run. You've been warned!
16  ***
17  ****************************************************************************
18  ****************************************************************************/
19 #ifndef _UAPI_ASM_X86_SGX_H
20 #define _UAPI_ASM_X86_SGX_H
21 #include <linux/types.h>
22 #include <linux/ioctl.h>
23 enum sgx_page_flags {
24   SGX_PAGE_MEASURE = 0x01,
25 };
26 #define SGX_MAGIC 0xA4
27 #define SGX_IOC_ENCLAVE_CREATE _IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create)
28 #define SGX_IOC_ENCLAVE_ADD_PAGES _IOWR(SGX_MAGIC, 0x01, struct sgx_enclave_add_pages)
29 #define SGX_IOC_ENCLAVE_INIT _IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
30 #define SGX_IOC_ENCLAVE_PROVISION _IOW(SGX_MAGIC, 0x03, struct sgx_enclave_provision)
31 struct sgx_enclave_create {
32   __u64 src;
33 };
34 struct sgx_enclave_add_pages {
35   __u64 src;
36   __u64 offset;
37   __u64 length;
38   __u64 secinfo;
39   __u64 flags;
40   __u64 count;
41 };
42 struct sgx_enclave_init {
43   __u64 sigstruct;
44 };
45 struct sgx_enclave_provision {
46   __u64 fd;
47 };
48 struct sgx_enclave_run;
49 typedef int(* sgx_enclave_user_handler_t) (long rdi, long rsi, long rdx, long rsp, long r8, long r9, struct sgx_enclave_run * run);
50 struct sgx_enclave_run {
51   __u64 tcs;
52   __u32 function;
53   __u16 exception_vector;
54   __u16 exception_error_code;
55   __u64 exception_addr;
56   __u64 user_handler;
57   __u64 user_data;
58   __u8 reserved[216];
59 };
60 typedef int(* vdso_sgx_enter_enclave_t) (unsigned long rdi, unsigned long rsi, unsigned long rdx, unsigned int function, unsigned long r8, unsigned long r9, struct sgx_enclave_run * run);
61 #endif
62