comparison gcc/config/i386/sgxintrin.h @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Copyright (C) 2017-2018 Free Software Foundation, Inc.
2
3 This file is part of GCC.
4
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
18
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
23
1 #ifndef _SGXINTRIN_H_INCLUDED 24 #ifndef _SGXINTRIN_H_INCLUDED
2 #define _SGXINTRIN_H_INCLUDED 25 #define _SGXINTRIN_H_INCLUDED
3 26
4 #ifndef __SGX__ 27 #ifndef __SGX__
5 #pragma GCC push_options 28 #pragma GCC push_options
64 __asm__ __volatile__("enclu\n\t" \ 87 __asm__ __volatile__("enclu\n\t" \
65 : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\ 88 : "=a" (retval), "=b" (b), "=c" (c), "=d" (d)\
66 : "a" (leaf), "b" (b), "c" (c), "d" (d) \ 89 : "a" (leaf), "b" (b), "c" (c), "d" (d) \
67 : "cc") 90 : "cc")
68 91
69 92 #define __enclv_bc(leaf, b, c, retval) \
70 extern __inline int 93 __asm__ __volatile__("enclv\n\t" \
94 : "=a" (retval) \
95 : "a" (leaf), "b" (b), "c" (c) \
96 : "cc")
97
98 #define __enclv_cd(leaf, c, d, retval) \
99 __asm__ __volatile__("enclv\n\t" \
100 : "=a" (retval) \
101 : "a" (leaf), "c" (c), "d" (d) \
102 : "cc")
103
104 #define __enclv_generic(leaf, b, c, d, retval) \
105 __asm__ __volatile__("enclv\n\t" \
106 : "=a" (retval), "=b" (b), "=c" (b), "=d" (d)\
107 : "a" (leaf), "b" (b), "c" (c), "d" (d) \
108 : "cc")
109
110 extern __inline unsigned int
71 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 111 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
72 _encls_u32 (const int __L, size_t __D[]) 112 _encls_u32 (const unsigned int __L, size_t __D[])
73 { 113 {
74 enum __encls_type 114 enum __encls_type
75 { 115 {
76 __SGX_ECREATE = 0x00, 116 __SGX_ECREATE = 0x00,
77 __SGX_EADD = 0x01, 117 __SGX_EADD = 0x01,
86 __SGX_EPA = 0x0A, 126 __SGX_EPA = 0x0A,
87 __SGX_EWB = 0x0B, 127 __SGX_EWB = 0x0B,
88 __SGX_ETRACK = 0x0C, 128 __SGX_ETRACK = 0x0C,
89 __SGX_EAUG = 0x0D, 129 __SGX_EAUG = 0x0D,
90 __SGX_EMODPR = 0x0E, 130 __SGX_EMODPR = 0x0E,
91 __SGX_EMODT = 0x0F 131 __SGX_EMODT = 0x0F,
132 __SGX_ERDINFO = 0x10,
133 __SGX_ETRACKC = 0x11,
134 __SGX_ELDBC = 0x12,
135 __SGX_ELDUC = 0x13
92 }; 136 };
93 enum __encls_type __T = (enum __encls_type)__L; 137 enum __encls_type __T = (enum __encls_type)__L;
94 int __R = 0; 138 unsigned int __R = 0;
95 if (!__builtin_constant_p (__T)) 139 if (!__builtin_constant_p (__T))
96 __encls_generic (__L, __D[0], __D[1], __D[2], __R); 140 __encls_generic (__L, __D[0], __D[1], __D[2], __R);
97 else switch (__T) 141 else switch (__T)
98 { 142 {
99 case __SGX_ECREATE: 143 case __SGX_ECREATE:
102 case __SGX_EEXTEND: 146 case __SGX_EEXTEND:
103 case __SGX_EPA: 147 case __SGX_EPA:
104 case __SGX_EMODPR: 148 case __SGX_EMODPR:
105 case __SGX_EMODT: 149 case __SGX_EMODT:
106 case __SGX_EAUG: 150 case __SGX_EAUG:
151 case __SGX_ERDINFO:
107 __encls_bc (__L, __D[0], __D[1], __R); 152 __encls_bc (__L, __D[0], __D[1], __R);
108 break; 153 break;
109 case __SGX_EINIT: 154 case __SGX_EINIT:
110 case __SGX_ELDB: 155 case __SGX_ELDB:
111 case __SGX_ELDU: 156 case __SGX_ELDU:
112 case __SGX_EWB: 157 case __SGX_EWB:
158 case __SGX_ELDBC:
159 case __SGX_ELDUC:
113 __encls_bcd (__L, __D[0], __D[1], __D[2], __R); 160 __encls_bcd (__L, __D[0], __D[1], __D[2], __R);
114 break; 161 break;
115 case __SGX_EREMOVE: 162 case __SGX_EREMOVE:
116 case __SGX_EBLOCK: 163 case __SGX_EBLOCK:
117 case __SGX_ETRACK: 164 case __SGX_ETRACK:
165 case __SGX_ETRACKC:
118 __encls_c (__L, __D[1], __R); 166 __encls_c (__L, __D[1], __R);
119 break; 167 break;
120 case __SGX_EDBGRD: 168 case __SGX_EDBGRD:
121 __encls_edbgrd (__L, __D[0], __D[1], __R); 169 __encls_edbgrd (__L, __D[0], __D[1], __R);
122 break; 170 break;
123 default: 171 default:
124 return -1; 172 __encls_generic (__L, __D[0], __D[1], __D[2], __R);
125 } 173 }
126 return __R; 174 return __R;
127 } 175 }
128 176
129 extern __inline int 177 extern __inline unsigned int
130 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) 178 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
131 _enclu_u32 (const int __L, size_t __D[]) 179 _enclu_u32 (const unsigned int __L, size_t __D[])
132 { 180 {
133 enum __enclu_type 181 enum __enclu_type
134 { 182 {
135 __SGX_EREPORT = 0x00, 183 __SGX_EREPORT = 0x00,
136 __SGX_EGETKEY = 0x01, 184 __SGX_EGETKEY = 0x01,
140 __SGX_EACCEPT = 0x05, 188 __SGX_EACCEPT = 0x05,
141 __SGX_EMODPE = 0x06, 189 __SGX_EMODPE = 0x06,
142 __SGX_EACCEPTCOPY = 0x07 190 __SGX_EACCEPTCOPY = 0x07
143 }; 191 };
144 enum __enclu_type __T = (enum __enclu_type) __L; 192 enum __enclu_type __T = (enum __enclu_type) __L;
145 int __R = 0; 193 unsigned int __R = 0;
146 if (!__builtin_constant_p (__T)) 194 if (!__builtin_constant_p (__T))
147 __enclu_generic (__L, __D[0], __D[1], __D[2], __R); 195 __enclu_generic (__L, __D[0], __D[1], __D[2], __R);
148 else switch (__T) 196 else switch (__T)
149 { 197 {
150 case __SGX_EREPORT: 198 case __SGX_EREPORT:
162 break; 210 break;
163 case __SGX_EEXIT: 211 case __SGX_EEXIT:
164 __enclu_eexit (__L, __D[0], __D[1], __R); 212 __enclu_eexit (__L, __D[0], __D[1], __R);
165 break; 213 break;
166 default: 214 default:
167 return -1; 215 __enclu_generic (__L, __D[0], __D[1], __D[2], __R);
216 }
217 return __R;
218 }
219
220 extern __inline unsigned int
221 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
222 _enclv_u32 (const unsigned int __L, size_t __D[])
223 {
224 enum __enclv_type
225 {
226 __SGX_EDECVIRTCHILD = 0x00,
227 __SGX_EINCVIRTCHILD = 0x01,
228 __SGX_ESETCONTEXT = 0x02
229 };
230 unsigned int __R = 0;
231 if (!__builtin_constant_p (__L))
232 __enclv_generic (__L, __D[0], __D[1], __D[2], __R);
233 else switch (__L)
234 {
235 case __SGX_EDECVIRTCHILD:
236 case __SGX_EINCVIRTCHILD:
237 __enclv_bc (__L, __D[0], __D[1], __R);
238 break;
239 case __SGX_ESETCONTEXT:
240 __enclv_cd (__L, __D[1], __D[2], __R);
241 break;
242 default:
243 __enclv_generic (__L, __D[0], __D[1], __D[2], __R);
168 } 244 }
169 return __R; 245 return __R;
170 } 246 }
171 247
172 #ifdef __DISABLE_SGX__ 248 #ifdef __DISABLE_SGX__