Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/openssl/dist/crypto Part of PR port-powe...



details:   https://anonhg.NetBSD.org/src/rev/9f4e1618b3f5
branches:  trunk
changeset: 935619:9f4e1618b3f5
user:      rin <rin%NetBSD.org@localhost>
date:      Tue Jul 07 01:47:47 2020 +0000

description:
Part of PR port-powerpc/55425
openssl fails on FPU emulation for powerpc

When machdep.fpu_present sysctl variable can be retrieved, and
its value is zero, avoid using FPU arithmetic.

FPU is absent and emulated by kernel in that case, and calculation
results are not correct in bit-to-bit precision.

This behavior should be useful even if we could fix FPU emulation;
it is much faster to skip FPU arithmetic in general, rather than
relying upon emulation by kernel via illegal instruction handler.

diffstat:

 crypto/external/bsd/openssl/dist/crypto/ppccap.c |  16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diffs (33 lines):

diff -r 2c2d9599d078 -r 9f4e1618b3f5 crypto/external/bsd/openssl/dist/crypto/ppccap.c
--- a/crypto/external/bsd/openssl/dist/crypto/ppccap.c  Tue Jul 07 01:39:23 2020 +0000
+++ b/crypto/external/bsd/openssl/dist/crypto/ppccap.c  Tue Jul 07 01:47:47 2020 +0000
@@ -26,6 +26,10 @@
 # include <sys/types.h>
 # include <sys/sysctl.h>
 #endif
+#if defined(__NetBSD__)
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#endif
 #include <openssl/crypto.h>
 #include <openssl/bn.h>
 #include <internal/cryptlib.h>
@@ -365,6 +369,18 @@
     sigaction(SIGILL, &ill_act, &ill_oact);
 
 #ifndef OSSL_IMPLEMENT_GETAUXVAL
+# ifdef __NetBSD__
+    int error, val;
+    size_t len = sizeof(val);
+
+    /*
+     * If machdep.fpu_present == 0, FPU is absent and emulated by software.
+     * Avoid using it as calculation results may not be correct in bit-to-bit
+     * precision.
+     */
+    error = sysctlbyname("machdep.fpu_present", &val, &len, NULL, 0);
+    if (error != 0 || (error == 0 && val != 0))
+# endif
     if (sigsetjmp(ill_jmp,1) == 0) {
         OPENSSL_fpu_probe();
         OPENSSL_ppccap_P |= PPC_FPU;



Home | Main Index | Thread Index | Old Index