]> git.wh0rd.org - ICEs.git/blob - 388835/aesni-intel_glue.i.1
more
[ICEs.git] / 388835 / aesni-intel_glue.i.1
1 typedef unsigned int __u32;
2 typedef unsigned char u8;
3 typedef unsigned short u16;
4 typedef unsigned int u32;
5 typedef unsigned long long u64;
6 struct ftrace_branch_data {
7 };
8 enum {
9 false = 0, true = 1
10 };
11 typedef _Bool bool;
12 struct list_head {
13 };
14 static inline __attribute__ ((always_inline)) __attribute__ ((always_inline))
15 __attribute__ ((pure))
16 bool __static_cpu_has(u16 bit)
17 {
18 asm goto ("1: jmp %l[t_no]\n" "2:\n" ".section .altinstructions,\"a\"\n"
19 " " ".balign 4" " " "\n" " " ".long" " " "1b\n" " " ".long"
20 " " "0\n" " .word %P0\n" " .byte 2b - 1b\n" " .byte 0\n"
21 ".previous\n"::"i" (bit)::t_no);
22 return true;
23 t_no:return false;
24 }
25
26 struct cpuinfo_x86 {
27 __u32 x86_capability[10];
28 } __attribute__ ((__aligned__((1 << (6)))));
29 extern struct cpuinfo_x86 boot_cpu_data;
30 struct i387_fxsave_struct {
31 u16 swd;
32 } __attribute__ ((aligned(16)));
33 struct xsave_hdr_struct {
34 u64 xstate_bv;
35 } __attribute__ ((packed));
36 struct xsave_struct {
37 struct xsave_hdr_struct xsave_hdr;
38 } __attribute__ ((packed, aligned(64)));
39 union thread_xstate {
40 struct i387_fxsave_struct fxsave;
41 struct xsave_struct xsave;
42 };
43 struct fpu {
44 union thread_xstate *state;
45 };
46 struct thread_struct {
47 struct fpu fpu;
48 } mm_segment_t;
49 struct thread_info {
50 struct task_struct *task;
51 __u32 status;
52 };
53 extern struct module __this_module;
54 struct cipher_alg {
55 unsigned int cia_min_keysize;
56 unsigned int cia_max_keysize;
57 int (*cia_setkey) (struct crypto_tfm * tfm, const u8 * key,
58 unsigned int keylen);
59 void (*cia_encrypt) (struct crypto_tfm * tfm, u8 * dst, const u8 * src);
60 void (*cia_decrypt) (struct crypto_tfm * tfm, u8 * dst, const u8 * src);
61 };
62 struct crypto_alg {
63 struct list_head cra_list;
64 u32 cra_flags;
65 unsigned int cra_blocksize;
66 unsigned int cra_ctxsize;
67 unsigned int cra_alignmask;
68 int cra_priority;
69 char cra_name[64];
70 char cra_driver_name[64];
71 const struct crypto_type *cra_type;
72 union {
73 struct cipher_alg cipher;
74 } cra_u;
75 struct module *cra_module;
76 };
77 extern const struct crypto_type crypto_ablkcipher_type;
78 extern const struct crypto_type crypto_blkcipher_type;
79 struct crypto_aes_ctx {
80 };
81 struct task_struct {
82 struct thread_struct thread;
83 };
84 static inline __attribute__ ((always_inline)) __attribute__ ((always_inline))
85 __attribute__ ((pure))
86 bool use_xsave(void)
87 {
88 return (__builtin_constant_p
89 ((__builtin_constant_p((4 * 32 + 26))
90 &&
91 (((((4 * 32 + 26)) >> 5) == 0
92 && (1UL << (((4 * 32 + 26)) & 31) &
93 ((1 << ((0 * 32 + 0) & 31)) | 0 | 0 |
94 (1 << ((0 * 32 + 6) & 31)) | (1 << ((0 * 32 + 8) & 31))
95 | 0 | 0 | (1 << ((0 * 32 + 15) & 31)) | 0 | 0)))
96 || ((((4 * 32 + 26)) >> 5) == 1
97 && (1UL << (((4 * 32 + 26)) & 31) & (0 | 0)))
98 || ((((4 * 32 + 26)) >> 5) == 2
99 && (1UL << (((4 * 32 + 26)) & 31) & 0))
100 || ((((4 * 32 + 26)) >> 5) == 3
101 && (1UL << (((4 * 32 + 26)) & 31) & (0)))
102 || ((((4 * 32 + 26)) >> 5) == 4
103 && (1UL << (((4 * 32 + 26)) & 31) & 0))
104 || ((((4 * 32 + 26)) >> 5) == 5
105 && (1UL << (((4 * 32 + 26)) & 31) & 0))
106 || ((((4 * 32 + 26)) >> 5) == 6
107 && (1UL << (((4 * 32 + 26)) & 31) & 0))
108 || ((((4 * 32 + 26)) >> 5) == 7
109 && (1UL << (((4 * 32 + 26)) & 31) & 0))
110 || ((((4 * 32 + 26)) >> 5) == 8
111 && (1UL << (((4 * 32 + 26)) & 31) & 0))
112 || ((((4 * 32 + 26)) >> 5) == 9
113 && (1UL << (((4 * 32 + 26)) & 31) & 0))) ? 1
114 : (__builtin_constant_p(((4 * 32 + 26))) ?
115 constant_test_bit(((4 * 32 + 26)),
116 ((unsigned long *)((&boot_cpu_data)->
117 x86_capability))) :
118 variable_test_bit(((4 * 32 + 26)),
119 ((unsigned long *)((&boot_cpu_data)->
120 x86_capability))))))
121 ? (__builtin_constant_p((4 * 32 + 26))
122 &&
123 (((((4 * 32 + 26)) >> 5) == 0
124 && (1UL << (((4 * 32 + 26)) & 31) &
125 ((1 << ((0 * 32 + 0) & 31)) | 0 | 0 |
126 (1 << ((0 * 32 + 6) & 31)) | (1 <<
127 ((0 * 32 +
128 8) & 31)) | 0 | 0 | (1
129 <<
130 ((0 * 32 + 15) & 31)) | 0 | 0))) || ((((4 * 32 + 26)) >> 5) == 1 && (1UL << (((4 * 32 + 26)) & 31) & (0 | 0))) || ((((4 * 32 + 26)) >> 5) == 2 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 3 && (1UL << (((4 * 32 + 26)) & 31) & (0))) || ((((4 * 32 + 26)) >> 5) == 4 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 5 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 6 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 7 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 8 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 9 && (1UL << (((4 * 32 + 26)) & 31) & 0))) ? 1 : (__builtin_constant_p(((4 * 32 + 26))) ? constant_test_bit(((4 * 32 + 26)), ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((4 * 32 + 26)), ((unsigned long *)((&boot_cpu_data)->x86_capability))))) : __builtin_constant_p((4 * 32 + 26)) ? __static_cpu_has((4 * 32 + 26)) : (__builtin_constant_p((4 * 32 + 26)) && (((((4 * 32 + 26)) >> 5) == 0 && (1UL << (((4 * 32 + 26)) & 31) & ((1 << ((0 * 32 + 0) & 31)) | 0 | 0 | (1 << ((0 * 32 + 6) & 31)) | (1 << ((0 * 32 + 8) & 31)) | 0 | 0 | (1 << ((0 * 32 + 15) & 31)) | 0 | 0))) || ((((4 * 32 + 26)) >> 5) == 1 && (1UL << (((4 * 32 + 26)) & 31) & (0 | 0))) || ((((4 * 32 + 26)) >> 5) == 2 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 3 && (1UL << (((4 * 32 + 26)) & 31) & (0))) || ((((4 * 32 + 26)) >> 5) == 4 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 5 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 6 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 7 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 8 && (1UL << (((4 * 32 + 26)) & 31) & 0)) || ((((4 * 32 + 26)) >> 5) == 9 && (1UL << (((4 * 32 + 26)) & 31) & 0))) ? 1 : (__builtin_constant_p(((4 * 32 + 26))) ? constant_test_bit(((4 * 32 + 26)), ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((4 * 32 + 26)), ((unsigned long *)((&boot_cpu_data)->x86_capability))))));
131 }
132
133 static inline __attribute__ ((always_inline)) __attribute__ ((always_inline))
134 __attribute__ ((pure))
135 bool use_fxsr(void)
136 {
137 return (__builtin_constant_p
138 ((__builtin_constant_p((0 * 32 + 24))
139 &&
140 (((((0 * 32 + 24)) >> 5) == 0
141 && (1UL << (((0 * 32 + 24)) & 31) &
142 ((1 << ((0 * 32 + 0) & 31)) | 0 | 0 |
143 (1 << ((0 * 32 + 6) & 31)) | (1 << ((0 * 32 + 8) & 31))
144 | 0 | 0 | (1 << ((0 * 32 + 15) & 31)) | 0 | 0)))
145 || ((((0 * 32 + 24)) >> 5) == 1
146 && (1UL << (((0 * 32 + 24)) & 31) & (0 | 0)))
147 || ((((0 * 32 + 24)) >> 5) == 2
148 && (1UL << (((0 * 32 + 24)) & 31) & 0))
149 || ((((0 * 32 + 24)) >> 5) == 3
150 && (1UL << (((0 * 32 + 24)) & 31) & (0)))
151 || ((((0 * 32 + 24)) >> 5) == 4
152 && (1UL << (((0 * 32 + 24)) & 31) & 0))
153 || ((((0 * 32 + 24)) >> 5) == 5
154 && (1UL << (((0 * 32 + 24)) & 31) & 0))
155 || ((((0 * 32 + 24)) >> 5) == 6
156 && (1UL << (((0 * 32 + 24)) & 31) & 0))
157 || ((((0 * 32 + 24)) >> 5) == 7
158 && (1UL << (((0 * 32 + 24)) & 31) & 0))
159 || ((((0 * 32 + 24)) >> 5) == 8
160 && (1UL << (((0 * 32 + 24)) & 31) & 0))
161 || ((((0 * 32 + 24)) >> 5) == 9
162 && (1UL << (((0 * 32 + 24)) & 31) & 0))) ? 1
163 : (__builtin_constant_p(((0 * 32 + 24))) ?
164 constant_test_bit(((0 * 32 + 24)),
165 ((unsigned long *)((&boot_cpu_data)->
166 x86_capability))) :
167 variable_test_bit(((0 * 32 + 24)),
168 ((unsigned long *)((&boot_cpu_data)->
169 x86_capability))))))
170 ? (__builtin_constant_p((0 * 32 + 24))
171 &&
172 (((((0 * 32 + 24)) >> 5) == 0
173 && (1UL << (((0 * 32 + 24)) & 31) &
174 ((1 << ((0 * 32 + 0) & 31)) | 0 | 0 |
175 (1 << ((0 * 32 + 6) & 31)) | (1 <<
176 ((0 * 32 +
177 8) & 31)) | 0 | 0 | (1
178 <<
179 ((0 * 32 + 15) & 31)) | 0 | 0))) || ((((0 * 32 + 24)) >> 5) == 1 && (1UL << (((0 * 32 + 24)) & 31) & (0 | 0))) || ((((0 * 32 + 24)) >> 5) == 2 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 3 && (1UL << (((0 * 32 + 24)) & 31) & (0))) || ((((0 * 32 + 24)) >> 5) == 4 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 5 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 6 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 7 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 8 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 9 && (1UL << (((0 * 32 + 24)) & 31) & 0))) ? 1 : (__builtin_constant_p(((0 * 32 + 24))) ? constant_test_bit(((0 * 32 + 24)), ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((0 * 32 + 24)), ((unsigned long *)((&boot_cpu_data)->x86_capability))))) : __builtin_constant_p((0 * 32 + 24)) ? __static_cpu_has((0 * 32 + 24)) : (__builtin_constant_p((0 * 32 + 24)) && (((((0 * 32 + 24)) >> 5) == 0 && (1UL << (((0 * 32 + 24)) & 31) & ((1 << ((0 * 32 + 0) & 31)) | 0 | 0 | (1 << ((0 * 32 + 6) & 31)) | (1 << ((0 * 32 + 8) & 31)) | 0 | 0 | (1 << ((0 * 32 + 15) & 31)) | 0 | 0))) || ((((0 * 32 + 24)) >> 5) == 1 && (1UL << (((0 * 32 + 24)) & 31) & (0 | 0))) || ((((0 * 32 + 24)) >> 5) == 2 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 3 && (1UL << (((0 * 32 + 24)) & 31) & (0))) || ((((0 * 32 + 24)) >> 5) == 4 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 5 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 6 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 7 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 8 && (1UL << (((0 * 32 + 24)) & 31) & 0)) || ((((0 * 32 + 24)) >> 5) == 9 && (1UL << (((0 * 32 + 24)) & 31) & 0))) ? 1 : (__builtin_constant_p(((0 * 32 + 24))) ? constant_test_bit(((0 * 32 + 24)), ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((0 * 32 + 24)), ((unsigned long *)((&boot_cpu_data)->x86_capability))))));
180 }
181
182 static inline __attribute__ ((always_inline))
183 void fpu_save_init(struct fpu *fpu)
184 {
185 if (__builtin_constant_p(((use_xsave())))? ! !((use_xsave())) : ( {
186 int
187 ______r;
188 ______r
189 =
190 ! !((use_xsave()));}
191 )) {
192 if (__builtin_constant_p
193 (((!(fpu->state->xsave.xsave_hdr.
194 xstate_bv & 0x1)))) ? ! !((!(fpu->state->xsave.
195 xsave_hdr.
196 xstate_bv & 0x1))) : ( {
197 int
198 ______r;
199 ______r
200 =
201 ! !((!(fpu->state->xsave.xsave_hdr.xstate_bv & 0x1)));}
202 ))
203 return;
204 } else if (__builtin_constant_p(((use_fxsr())))? ! !((use_fxsr())) : ( {
205 int
206 ______r;
207 ______r
208 =
209 ! !
210 ((use_fxsr()));}
211 )) {
212 }
213 if (__builtin_constant_p
214 ((((__builtin_constant_p(fpu->state->fxsave.swd & (1 << 7)) ?
215 ! !(fpu->state->fxsave.swd & (1 << 7)) : ( {
216 int ______r;
217 ______r =
218 __builtin_expect(! !
219 (fpu->
220 state->
221 fxsave.
222 swd
223 & (1
224 <<
225 7)),
226 1);}
227 )))))?
228 ! !(((__builtin_constant_p(fpu->state->fxsave.swd & (1 << 7)) ?
229 ! !(fpu->state->fxsave.swd & (1 << 7)) : ( {
230 int ______r;
231 ______r =
232 __builtin_expect(! !
233 (fpu->
234 state->
235 fxsave.
236 swd
237 &
238 (1
239 <<
240 7)),
241 1);}
242 )))): ( {
243 int ______r;
244 ______r =
245 ! !(((__builtin_constant_p(fpu->state->fxsave.swd & (1 << 7))
246 ? ! !(fpu->state->fxsave.swd & (1 << 7)) : ( {
247 ______r =
248 __builtin_expect
249 (! !
250 (fpu->
251 state->
252 fxsave.
253 swd & (1
254 <<
255 7)),
256 1);}
257 ))));}
258 ))
259 asm volatile ("fnclex");
260 }
261
262 static inline __attribute__ ((always_inline))
263 void __save_init_fpu(struct task_struct *tsk)
264 {
265 fpu_save_init(&tsk->thread.fpu);
266 }
267
268 static inline __attribute__ ((always_inline))
269 void kernel_fpu_begin(void)
270 {
271 struct thread_info *me = current_thread_info();
272 if (__builtin_constant_p(((me->status & 0x0001))) ?
273 ! !((me->status & 0x0001)) : ( {
274 int ______r;
275 ______r = ! !((me->status & 0x0001));}
276 ))
277 __save_init_fpu(me->task);
278 }
279
280 struct async_aes_ctx {
281 };
282 static int aes_set_key(struct crypto_tfm *tfm, const u8 * in_key,
283 unsigned int key_len)
284 {
285 }
286
287 static void aes_encrypt(struct crypto_tfm *tfm, u8 * dst, const u8 * src)
288 {
289 }
290
291 static void aes_decrypt(struct crypto_tfm *tfm, u8 * dst, const u8 * src)
292 {
293 struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm));
294 if (__builtin_constant_p(((!irq_fpu_usable())))?
295 ! !((!irq_fpu_usable())) : ( {
296 int ______r;
297 ______r = ! !((!irq_fpu_usable()));}
298 ))
299 crypto_aes_decrypt_x86(ctx, dst, src);
300 else {
301 kernel_fpu_begin();
302 }
303 }
304
305 static struct crypto_alg aesni_alg = {
306 .cra_name = "aes",.cra_driver_name = "aes-aesni",.cra_priority =
307 300,.cra_flags = 0x00000001,.cra_blocksize = 16,.cra_ctxsize =
308 sizeof(struct crypto_aes_ctx) + (16) - 1,.cra_alignmask =
309 0,.cra_module = (&__this_module),.cra_list = {
310 &(aesni_alg.cra_list),
311 &(aesni_alg.cra_list)}
312 ,.cra_u = {
313 .cipher = {
314 .cia_min_keysize = 16,.cia_max_keysize =
315 32,.cia_setkey = aes_set_key,.cia_encrypt =
316 aes_encrypt,.cia_decrypt = aes_decrypt}
317 }
318 };
319
320 static struct crypto_alg blk_ecb_alg = {
321 .cra_name = "__ecb-aes-aesni",.cra_driver_name =
322 "__driver-ecb-aes-aesni",.cra_priority = 0,.cra_flags =
323 0x00000004,.cra_blocksize = 16,.cra_ctxsize =
324 sizeof(struct crypto_aes_ctx) + (16) - 1,.cra_alignmask =
325 0,.cra_type = &crypto_blkcipher_type,.cra_module =
326 (&__this_module),.cra_list = {
327 &(blk_ecb_alg.cra_list),
328 &(blk_ecb_alg.cra_list)}
329 ,
330 };
331
332 static struct crypto_alg ablk_ecb_alg = {
333 .cra_name = "ecb(aes)",.cra_driver_name =
334 "ecb-aes-aesni",.cra_priority = 400,.cra_flags =
335 0x00000005 | 0x00000080,.cra_blocksize = 16,.cra_ctxsize =
336 sizeof(struct async_aes_ctx),.cra_alignmask = 0,.cra_type =
337 &crypto_ablkcipher_type,.cra_module = (&__this_module),.cra_list = {
338 &
339 (ablk_ecb_alg.
340 cra_list),
341 &
342 (ablk_ecb_alg.
343 cra_list)}
344 ,
345 };
346
347 static struct crypto_alg ablk_cbc_alg = {
348 .cra_name = "cbc(aes)",.cra_driver_name =
349 "cbc-aes-aesni",.cra_priority = 400,.cra_flags =
350 0x00000005 | 0x00000080,.cra_blocksize = 16,.cra_ctxsize =
351 sizeof(struct async_aes_ctx),.cra_alignmask = 0,.cra_type =
352 &crypto_ablkcipher_type,.cra_module = (&__this_module),.cra_list = {
353 &
354 (ablk_cbc_alg.
355 cra_list),
356 &
357 (ablk_cbc_alg.
358 cra_list)}
359 ,
360 };
361
362 static struct crypto_alg ablk_pcbc_alg = {
363 .cra_name = "pcbc(aes)",.cra_driver_name =
364 "pcbc-aes-aesni",.cra_priority = 400,.cra_flags =
365 0x00000005 | 0x00000080,.cra_blocksize = 16,.cra_ctxsize =
366 sizeof(struct async_aes_ctx),.cra_alignmask = 0,.cra_type =
367 &crypto_ablkcipher_type,.cra_module = (&__this_module),.cra_list = {
368 &
369 (ablk_pcbc_alg.
370 cra_list),
371 &
372 (ablk_pcbc_alg.
373 cra_list)}
374 ,
375 };
376
377 static int __attribute__ ((__section__(".init.text")))
378 __attribute__ ((__cold__))
379 __attribute__ ((no_instrument_function)) aesni_init(void)
380 {
381 int err;
382 if (__builtin_constant_p((((err = crypto_register_alg(&aesni_alg))))) ?
383 ! !(((err = crypto_register_alg(&aesni_alg)))) : ( {
384 int ______r;
385 ______r =
386 ! !(((err =
387 crypto_register_alg
388 (&aesni_alg))));}
389 ))
390 goto ablk_cbc_err;
391 ablk_cbc_err:crypto_unregister_alg(&ablk_ecb_alg);
392 }
393
394 int init_module(void) __attribute__ ((alias("aesni_init")));