1 #ifndef _SGXINTRIN_H_INCLUDED
2 #define _SGXINTRIN_H_INCLUDED
5 #pragma GCC push_options
6 #pragma GCC target("sgx")
7 #define __DISABLE_SGX__
10 #define __encls_bc(leaf, b, c, retval) \
11 __asm__ __volatile__ ("encls\n\t" \
13 : "a" (leaf), "b" (b), "c" (c) \
16 #define __encls_bcd(leaf, b, c, d, retval) \
17 __asm__ __volatile__("encls\n\t" \
19 : "a" (leaf), "b" (b), "c" (c), "d" (d) \
22 #define __encls_c(leaf, c, retval) \
23 __asm__ __volatile__("encls\n\t" \
25 : "a" (leaf), "c" (c) \
28 #define __encls_edbgrd(leaf, b, c, retval) \
29 __asm__ __volatile__("encls\n\t" \
30 : "=a" (retval), "=b" (b) \
31 : "a" (leaf), "c" (c))
33 #define __encls_generic(leaf, b, c, d, retval) \
34 __asm__ __volatile__("encls\n\t" \
35 : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\
36 : "a" (leaf), "b" (b), "c" (c), "d" (d) \
39 #define __enclu_bc(leaf, b, c, retval) \
40 __asm__ __volatile__("enclu\n\t" \
42 : "a" (leaf), "b" (b), "c" (c) \
45 #define __enclu_bcd(leaf, b, c, d, retval) \
46 __asm__ __volatile__("enclu\n\t" \
48 : "a" (leaf), "b" (b), "c" (c), "d" (d) \
51 #define __enclu_eenter(leaf, b, c, retval) \
52 __asm__ __volatile__("enclu\n\t" \
53 : "=a" (retval), "=c" (c) \
54 : "a" (leaf), "b" (b), "c" (c) \
57 #define __enclu_eexit(leaf, b, c, retval) \
58 __asm__ __volatile__("enclu\n\t" \
59 : "=a" (retval), "=c" (c) \
60 : "a" (leaf), "b" (b) \
63 #define __enclu_generic(leaf, b, c, d, retval) \
64 __asm__ __volatile__("enclu\n\t" \
65 : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\
66 : "a" (leaf), "b" (b), "c" (c), "d" (d) \
71 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
72 _encls_u32 (const int __L
, size_t __D
[])
93 enum __encls_type __T
= (enum __encls_type
)__L
;
95 if (!__builtin_constant_p (__T
))
96 __encls_generic (__L
, __D
[0], __D
[1], __D
[2], __R
);
107 __encls_bc (__L
, __D
[0], __D
[1], __R
);
113 __encls_bcd (__L
, __D
[0], __D
[1], __D
[2], __R
);
118 __encls_c (__L
, __D
[1], __R
);
121 __encls_edbgrd (__L
, __D
[0], __D
[1], __R
);
130 __attribute__((__gnu_inline__
, __always_inline__
, __artificial__
))
131 _enclu_u32 (const int __L
, size_t __D
[])
135 __SGX_EREPORT
= 0x00,
136 __SGX_EGETKEY
= 0x01,
138 __SGX_ERESUME
= 0x03,
140 __SGX_EACCEPT
= 0x05,
142 __SGX_EACCEPTCOPY
= 0x07
144 enum __enclu_type __T
= (enum __enclu_type
) __L
;
146 if (!__builtin_constant_p (__T
))
147 __enclu_generic (__L
, __D
[0], __D
[1], __D
[2], __R
);
151 case __SGX_EACCEPTCOPY
:
152 __enclu_bcd (__L
, __D
[0], __D
[1], __D
[2], __R
);
158 __enclu_bc (__L
, __D
[0], __D
[1], __R
);
161 __enclu_eenter (__L
, __D
[0], __D
[1], __R
);
164 __enclu_eexit (__L
, __D
[0], __D
[1], __R
);
172 #ifdef __DISABLE_SGX__
173 #undef __DISABLE_SGX__
174 #pragma GCC pop_options
175 #endif /* __DISABLE_SGX__ */
177 #endif /* _SGXINTRIN_H_INCLUDED */