|
65 | 65 | (int)_xatoi_res; \ |
66 | 66 | }) |
67 | 67 |
|
68 | | - /* Kbuild+gcc on x86 doesn't consistently honor the default ALIGN16 on stack objects, |
69 | | - * but gives adequate alignment with "32". |
| 68 | + /* Kbuild+gcc on x86 doesn't consistently honor the default ALIGN16 on stack |
| 69 | + * objects, but gives adequate alignment with "32". |
70 | 70 | */ |
71 | 71 | #if defined(CONFIG_X86) && !defined(ALIGN16) |
72 | 72 | #define ALIGN16 __attribute__ ( (aligned (32))) |
|
157 | 157 | (sizeof(s) - 1) : strlen(s)) |
158 | 158 |
|
159 | 159 | static inline void *my_memcpy(void *dest, const void *src, size_t n) { |
160 | | - if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n) & (uintptr_t)(sizeof(uintptr_t) - 1))) { |
| 160 | + if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n) |
| 161 | + & (uintptr_t)(sizeof(uintptr_t) - 1))) |
| 162 | + { |
161 | 163 | uintptr_t *src_longs = (uintptr_t *)src, |
162 | 164 | *dest_longs = (uintptr_t *)dest, |
163 | 165 | *endp = (uintptr_t *)((u8 *)src + n); |
|
176 | 178 | #define memcpy my_memcpy |
177 | 179 |
|
178 | 180 | static inline void *my_memset(void *dest, int c, size_t n) { |
179 | | - if (! (((uintptr_t)dest | (uintptr_t)n) & (uintptr_t)(sizeof(uintptr_t) - 1))) { |
| 181 | + if (! (((uintptr_t)dest | (uintptr_t)n) |
| 182 | + & (uintptr_t)(sizeof(uintptr_t) - 1))) |
| 183 | + { |
180 | 184 | uintptr_t c_long = __builtin_choose_expr( |
181 | 185 | sizeof(uintptr_t) == 8, |
182 | 186 | (uintptr_t)(u8)c * 0x0101010101010101UL, |
183 | 187 | (uintptr_t)(u8)c * 0x01010101U |
184 | 188 | ); |
185 | | - uintptr_t *dest_longs = (uintptr_t *)dest, *endp = (uintptr_t *)((u8 *)dest_longs + n); |
| 189 | + uintptr_t *dest_longs = (uintptr_t *)dest, |
| 190 | + *endp = (uintptr_t *)((u8 *)dest_longs + n); |
186 | 191 | while (dest_longs < endp) |
187 | 192 | *dest_longs++ = c_long; |
188 | 193 | } else { |
|
196 | 201 | #define memset my_memset |
197 | 202 |
|
198 | 203 | static inline void *my_memmove(void *dest, const void *src, size_t n) { |
199 | | - if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n) & (uintptr_t)(sizeof(uintptr_t) - 1))) { |
200 | | - uintptr_t *src_longs = (uintptr_t *)src, *dest_longs = (uintptr_t *)dest; |
| 204 | + if (! (((uintptr_t)dest | (uintptr_t)src | (uintptr_t)n) |
| 205 | + & (uintptr_t)(sizeof(uintptr_t) - 1))) |
| 206 | + { |
| 207 | + uintptr_t *src_longs = (uintptr_t *)src, |
| 208 | + *dest_longs = (uintptr_t *)dest; |
201 | 209 | n >>= __builtin_choose_expr( |
202 | 210 | sizeof(uintptr_t) == 8, |
203 | 211 | 3U, |
|
270 | 278 | #include <crypto/internal/aead.h> |
271 | 279 | #include <crypto/internal/skcipher.h> |
272 | 280 |
|
| 281 | + /* the LKCAPI assumes that expanded encrypt and decrypt keys will stay |
| 282 | + * loaded simultaneously, and the Linux in-tree implementations have two |
| 283 | + * AES key structs in each context, one for each direction. in |
| 284 | + * linuxkm/lkcapi_glue.c (used for CBC, CFB, and GCM), we do the same |
| 285 | + * thing with "struct km_AesCtx". however, wolfCrypt struct AesXts |
| 286 | + * already has two AES expanded keys, the main and tweak, and the tweak |
| 287 | + * is always used in the encrypt direction regardless of the main |
| 288 | + * direction. to avoid allocating and computing a duplicate second |
| 289 | + * tweak encrypt key, we set |
| 290 | + * WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS, which adds a second |
| 291 | + * Aes slot to wolfCrypt's struct AesXts, and activates support for |
| 292 | + * AES_ENCRYPTION_AND_DECRYPTION on AES-XTS. |
| 293 | + */ |
273 | 294 | #ifndef WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS |
274 | 295 | #define WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS |
275 | 296 | #endif |
276 | 297 | #endif |
277 | 298 |
|
278 | | - #if defined(WOLFSSL_AESNI) || defined(USE_INTEL_SPEEDUP) || defined(WOLFSSL_SP_X86_64_ASM) |
| 299 | + #if defined(WOLFSSL_AESNI) || defined(USE_INTEL_SPEEDUP) || \ |
| 300 | + defined(WOLFSSL_SP_X86_64_ASM) |
279 | 301 | #ifndef CONFIG_X86 |
280 | 302 | #error X86 SIMD extensions requested, but CONFIG_X86 is not set. |
281 | 303 | #endif |
|
301 | 323 | #endif |
302 | 324 | #endif |
303 | 325 |
|
304 | | - /* benchmarks.c uses floating point math, so needs a working SAVE_VECTOR_REGISTERS(). */ |
305 | | - #if defined(WOLFSSL_LINUXKM_BENCHMARKS) && !defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) |
| 326 | + /* benchmarks.c uses floating point math, so needs a working |
| 327 | + * SAVE_VECTOR_REGISTERS(). |
| 328 | + */ |
| 329 | + #if defined(WOLFSSL_LINUXKM_BENCHMARKS) && \ |
| 330 | + !defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) |
306 | 331 | #define WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS |
307 | 332 | #endif |
308 | 333 |
|
309 | | - #if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86) |
| 334 | + #if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS) && \ |
| 335 | + defined(CONFIG_X86) |
310 | 336 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) |
311 | 337 | #include <asm/i387.h> |
312 | 338 | #else |
313 | 339 | #include <asm/simd.h> |
314 | 340 | #endif |
315 | 341 | #ifndef SAVE_VECTOR_REGISTERS |
316 | | - #define SAVE_VECTOR_REGISTERS(fail_clause) { int _svr_ret = save_vector_registers_x86(); if (_svr_ret != 0) { fail_clause } } |
| 342 | + #define SAVE_VECTOR_REGISTERS(fail_clause) { \ |
| 343 | + int _svr_ret = save_vector_registers_x86(); \ |
| 344 | + if (_svr_ret != 0) { \ |
| 345 | + fail_clause \ |
| 346 | + } \ |
| 347 | + } |
317 | 348 | #ifdef DEBUG_VECTOR_REGISTER_ACCESS_FUZZING |
318 | | - #define SAVE_VECTOR_REGISTERS2() ({ int _fuzzer_ret = SAVE_VECTOR_REGISTERS2_fuzzer(); (_fuzzer_ret == 0) ? save_vector_registers_x86() : _fuzzer_ret; }) |
| 349 | + #define SAVE_VECTOR_REGISTERS2() ({ \ |
| 350 | + int _fuzzer_ret = SAVE_VECTOR_REGISTERS2_fuzzer(); \ |
| 351 | + (_fuzzer_ret == 0) ? \ |
| 352 | + save_vector_registers_x86() : \ |
| 353 | + _fuzzer_ret; \ |
| 354 | + }) |
319 | 355 | #else |
320 | 356 | #define SAVE_VECTOR_REGISTERS2() save_vector_registers_x86() |
321 | 357 | #endif |
|
0 commit comments