]> git.wh0rd.org - ICEs.git/blob - 388835/aesni-intel_glue.i.6
more
[ICEs.git] / 388835 / aesni-intel_glue.i.6
1 struct list_head {
2 };
3 int __static_cpu_has(unsigned short bit)
4 {
5 asm goto ("1: jmp %l[t_no]\n" "2:\n" ".section .altinstructions,\"a\"\n"
6 " " ".balign 4" " " "\n" " " ".long" " " "1b\n" " " ".long"
7 " " "0\n" " .word %P0\n" " .byte 2b - 1b\n" " .byte 0\n"
8 ".previous\n"::"i" (bit)::t_no);
9 return 1;
10 t_no:return 0;
11 }
12
13 struct cpuinfo_x86 {
14 unsigned int x86_capability[10];
15 } __attribute__ ((__aligned__((1 << (6)))));
16 extern struct cpuinfo_x86 boot_cpu_data;
17 struct i387_fxsave_struct {
18 unsigned short swd;
19 } __attribute__ ((aligned(16)));
20 struct xsave_hdr_struct {
21 unsigned long long xstate_bv;
22 } __attribute__ ((packed));
23 struct xsave_struct {
24 struct xsave_hdr_struct xsave_hdr;
25 } __attribute__ ((packed, aligned(64)));
26 union thread_xstate {
27 struct i387_fxsave_struct fxsave;
28 struct xsave_struct xsave;
29 };
30 struct fpu {
31 union thread_xstate *state;
32 };
33 struct cipher_alg {
34 void (*cia_decrypt) (struct crypto_tfm * tfm, unsigned char *dst,
35 const unsigned char *src);
36 };
37 struct crypto_alg {
38 struct list_head cra_list;
39 union {
40 struct cipher_alg cipher;
41 } cra_u;
42 };
43 static __attribute__ ((always_inline)) __attribute__ ((pure))
44 int use_xsave(void)
45 {
46 return (__builtin_constant_p
47 ((__builtin_constant_p(154)
48 &&
49 ((4 == 0
50 && (1UL << (26) &
51 ((1 << 0) | (1 << 6) |
52 (1 << 8) | (1 << 15))))
53 || ((4) == 1 && (1UL << (26) & 0)) || ((4) == 2
54 && (1UL <<
55 (26) & 0)) || ((4) == 3 && (1UL << (26) & 0)) || ((4) == 4 && (1UL << (26) & 0)) || ((4) == 5 && (1UL << (26) & 0)) || ((4) == 6 && (1UL << (26) & 0)) || ((4) == 7 && (1UL << (26) & 0)) || ((4) == 8 && (1UL << (26) & 0)) || ((4) == 9 && (1UL << (26) & 0))) ? 1 : (__builtin_constant_p(154) ? constant_test_bit(154, ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((154)), ((unsigned long *)((&boot_cpu_data)->x86_capability)))))) ? (__builtin_constant_p((154)) && (((4) == 0 && (1UL << (26) & ((1 << (0 & 31)) | (1 << ((6) & 31)) | (1 << ((0 * 32 + 8) & 31)) | (1 << ((15) & 31)) | 0))) || ((4) == 1 && (1UL << (26) & 0)) || ((4) == 2 && (1UL << (26) & 0)) || ((4) == 3 && (1UL << (26) & 0)) || ((4) == 4 && (1UL << (26) & 0)) || ((4) == 5 && (1UL << (26) & 0)) || ((4) == 6 && (1UL << (26) & 0)) || ((4) == 7 && (1UL << (26) & 0)) || ((4) == 8 && (1UL << (26) & 0)) || ((4) == 9 && (1UL << (26) & 0))) ? 1 : (__builtin_constant_p(((154))) ? constant_test_bit(((154)), ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((154)), ((unsigned long *)((&boot_cpu_data)->x86_capability))))) : __builtin_constant_p((154)) ? __static_cpu_has((154)) : (__builtin_constant_p((154)) && (((4) == 0 && (1UL << (26) & ((1 << (0 & 31)) | (1 << ((6) & 31)) | (1 << ((8) & 31)) | (1 << ((15) & 31)) | 0))) || ((4) == 1 && (1UL << (26) & 0)) || ((4) == 2 && (1UL << (26) & 0)) || ((4) == 3 && (1UL << (26) & 0)) || ((4) == 4 && (1UL << (26) & 0)) || ((4) == 5 && (1UL << (26) & 0)) || ((4) == 6 && (1UL << (26) & 0)) || ((4) == 7 && (1UL << (26) & 0)) || ((4) == 8 && (1UL << (26) & 0)) || ((4) == 9 && (1UL << (26) & 0))) ? 1 : (__builtin_constant_p(((154))) ? constant_test_bit(((154)), ((unsigned long *)((&boot_cpu_data)->x86_capability))) : variable_test_bit(((154)), ((unsigned long *)((&boot_cpu_data)->x86_capability))))));
56 }
57
58 static inline __attribute__ ((always_inline)) __attribute__ ((always_inline))
59 __attribute__ ((pure))
60 int use_fxsr(void)
61 {
62 return (__builtin_constant_p
63 ((
64 (__builtin_constant_p(24) ?
65 constant_test_bit(24,
66 ((unsigned long *)((&boot_cpu_data)->
67 x86_capability))) :
68 variable_test_bit(24,
69 ((unsigned long *)((&boot_cpu_data)->
70 x86_capability))))))
71 ?
72 (
73 __builtin_constant_p(24) ?
74 constant_test_bit(24, ((unsigned long *)((&boot_cpu_data)->x86_capability))) :
75 variable_test_bit(24, ((unsigned long *)((&boot_cpu_data)->x86_capability)))
76
77 ) :
78 __builtin_constant_p((24)) ? __static_cpu_has((24))
79 : (
80 (__builtin_constant_p(24) ?
81 constant_test_bit(24,
82 ((unsigned long *)((&boot_cpu_data)->
83 x86_capability))) :
84 variable_test_bit(24,
85 ((unsigned long *)((&boot_cpu_data)->
86 x86_capability))))));
87 }
88
89 static inline __attribute__ ((always_inline))
90 void fpu_save_init(struct fpu *fpu)
91 {
92 if (__builtin_constant_p(use_xsave())? use_xsave() : use_xsave()) {
93 if (__builtin_constant_p
94 (((!(fpu->state->xsave.xsave_hdr.
95 xstate_bv & 0x1)))) ? ! !((!(fpu->state->xsave.
96 xsave_hdr.
97 xstate_bv & 0x1))) : ( {
98 ! !((!(fpu->state->xsave.xsave_hdr.xstate_bv & 0x1)));}
99 ))
100 return;
101 } else if (use_fxsr()) {
102 }
103 if (__builtin_constant_p
104 ((((__builtin_constant_p(fpu->state->fxsave.swd & (1 << 7)) ?
105 ! !(fpu->state->fxsave.swd & (1 << 7)) : ( {
106 __builtin_expect(! !
107 (fpu->
108 state->
109 fxsave.
110 swd
111 & (1
112 <<
113 7)),
114 1);}
115 )))))?
116 ! !(((__builtin_constant_p(fpu->state->fxsave.swd & (1 << 7)) ?
117 ! !(fpu->state->fxsave.swd & (1 << 7)) : ( {
118 __builtin_expect(! !
119 (fpu->
120 state->
121 fxsave.
122 swd
123 &
124 (1
125 <<
126 7)),
127 1);}
128 )))): ( {
129 int ______r;
130 ______r =
131 ! !(((__builtin_constant_p(fpu->state->fxsave.swd & (1 << 7))
132 ? ! !(fpu->state->fxsave.swd & (1 << 7)) : ( {
133 ______r =
134 __builtin_expect
135 (! !
136 (fpu->
137 state->
138 fxsave.
139 swd & (1
140 <<
141 7)),
142 1);}
143 ))));}
144 ))
145 asm volatile ("fnclex");
146 }
147
148 static __attribute__ ((always_inline))
149 void __save_init_fpu(void)
150 {
151 fpu_save_init(0);
152 }
153
154 static __attribute__ ((always_inline))
155 void kernel_fpu_begin(void)
156 {
157 __save_init_fpu();
158 }
159
160 static void aes_decrypt(void)
161 {
162 if (!irq_fpu_usable())
163 crypto_aes_decrypt_x86(0);
164 else
165 kernel_fpu_begin();
166 }
167
168 static struct crypto_alg aesni_alg = {
169 .cra_list = {
170 &aesni_alg.cra_list, &aesni_alg.cra_list}
171 ,.cra_u = {
172 .cipher = {
173 .cia_decrypt = aes_decrypt}
174 }
175 };
176
177 static struct crypto_alg ablk_ecb_alg = {
178 };
179
180 int aesni_init(void)
181 {
182 if (! !crypto_register_alg(&aesni_alg))
183 crypto_unregister_alg(&ablk_ecb_alg);
184 }