X-Git-Url: https://git.wh0rd.org/?p=ICEs.git;a=blobdiff_plain;f=388835%2Faesni-intel_glue.i;fp=388835%2Faesni-intel_glue.i;h=e5099bd9e32b7a02166b6a4bf4af23dc804fad9a;hp=0000000000000000000000000000000000000000;hb=bd3239d2bbe0de3a200b266503e3330b1e391489;hpb=dbff64cb4b7530861c2309c794efdd4e0cf47a23 diff --git a/388835/aesni-intel_glue.i b/388835/aesni-intel_glue.i new file mode 100644 index 0000000..e5099bd --- /dev/null +++ b/388835/aesni-intel_glue.i @@ -0,0 +1,32 @@ +__attribute__ ((always_inline)) __attribute__ ((pure)) +int cpu_has(unsigned short bit) +{ + asm goto ("1: jmp %l[t_no]\n" "2:\n" ".section .altinstructions,\"a\"\n" + ".balign 4\n" ".long 1b\n" ".long 0\n" ".word %P0\n" ".byte 2b - 1b\n" ".byte 0\n" + ".previous\n"::"i" (bit)::t_no); + return 1; + t_no:return 0; +} + +union thread_xstate { + int swd; + int xstate_bv; +}; + +void aes_decrypt(union thread_xstate *state) +{ + if (fpu_usable()) { + decrypt(); + return; + } + + if (__builtin_constant_p(cpu_has(154)) ? cpu_has(154) : cpu_has(154)) { + if (state->xstate_bv) + return; + } else if (cpu_has(24)) {} + + if (state->swd) + asm volatile ("fnclex"); +} + +void (*funcptr)(void) = aes_decrypt;