Sun Jul 19 15:33:08 2020 UTC ()
Expand on importance of not using fpu for crypto if there's no fpu.


(riastradh)
diff -r1.17 -r1.18 src/crypto/external/bsd/openssl/dist/crypto/ppccap.c

cvs diff -r1.17 -r1.18 src/crypto/external/bsd/openssl/dist/crypto/ppccap.c (expand / switch to unified diff)

--- src/crypto/external/bsd/openssl/dist/crypto/ppccap.c 2020/07/15 08:14:41 1.17
+++ src/crypto/external/bsd/openssl/dist/crypto/ppccap.c 2020/07/19 15:33:08 1.18
@@ -364,28 +364,31 @@ void OPENSSL_cpuid_setup(void) @@ -364,28 +364,31 @@ void OPENSSL_cpuid_setup(void)
364 memset(&ill_act, 0, sizeof(ill_act)); 364 memset(&ill_act, 0, sizeof(ill_act));
365 ill_act.sa_handler = ill_handler; 365 ill_act.sa_handler = ill_handler;
366 ill_act.sa_mask = all_masked; 366 ill_act.sa_mask = all_masked;
367 367
368 sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset); 368 sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
369 sigaction(SIGILL, &ill_act, &ill_oact); 369 sigaction(SIGILL, &ill_act, &ill_oact);
370 370
371#ifndef OSSL_IMPLEMENT_GETAUXVAL 371#ifndef OSSL_IMPLEMENT_GETAUXVAL
372# ifdef __NetBSD__ 372# ifdef __NetBSD__
373 int error, val; 373 int error, val;
374 size_t len = sizeof(val); 374 size_t len = sizeof(val);
375 375
376 /* 376 /*
377 * If machdep.fpu_present == 0, FPU is absent and emulated by software. 377 * If machdep.fpu_present == 0, FPU is absent and emulated by
378 * Avoid using it for better performance. 378 * software. In that case, using FPU instructions hurts rather
 379 * than helps performance, and the software is unlikely to run in
 380 * constant time so it would expose us to timing side channel
 381 * attacks. So don't do it!
379 */ 382 */
380 error = sysctlbyname("machdep.fpu_present", &val, &len, NULL, 0); 383 error = sysctlbyname("machdep.fpu_present", &val, &len, NULL, 0);
381 if (error != 0 || (error == 0 && val != 0)) 384 if (error != 0 || (error == 0 && val != 0))
382# endif 385# endif
383 if (sigsetjmp(ill_jmp,1) == 0) { 386 if (sigsetjmp(ill_jmp,1) == 0) {
384 OPENSSL_fpu_probe(); 387 OPENSSL_fpu_probe();
385 OPENSSL_ppccap_P |= PPC_FPU; 388 OPENSSL_ppccap_P |= PPC_FPU;
386 389
387 if (sizeof(size_t) == 4) { 390 if (sizeof(size_t) == 4) {
388# ifdef __linux 391# ifdef __linux
389 struct utsname uts; 392 struct utsname uts;
390 if (uname(&uts) == 0 && strcmp(uts.machine, "ppc64") == 0) 393 if (uname(&uts) == 0 && strcmp(uts.machine, "ppc64") == 0)
391# endif 394# endif