NetBSD-Bugs archive

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

port-powerpc/55425: openssl fails on FPU emulation for powerpc



>Number:         55425
>Category:       port-powerpc
>Synopsis:       openssl fails on FPU emulation for powerpc
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-powerpc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 27 10:50:00 +0000 2020
>Originator:     Rin Okuyama
>Release:        9.99.68
>Organization:
Department of Physics, Meiji University
>Environment:
NetBSD obs266 9.99.68 NetBSD 9.99.68 (OBS266) #264: Sat Jun 27 13:39:00 JST 2020  rin@latipes:/usr/src/sys/arch/evbppc/compile/OBS266 evbppc
>Description:
tests/crypto/libcrypto/t_ciphers:evp fails on ibm4xx where FPU is
emulated by kernel:

tc-start: 1592971605.449921, evp
...
tc-se:    # Starting "Chacha20" tests at line 2455
tc-se:    # ERROR: (memory) 'expected == got' failed @ /usr/src/crypto/external/bsd/openssl/dist/test/evp_test.c:92
tc-se:    # --- expected
tc-se:    # +++ got
tc-se:    # 0000:-1ae10b594f09e26a 7e902ecbd0600691
tc-se:    # 0000:+153c72743c64d370 ecaeefcd68f9f41d
tc-se:    #       ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^

It works on macppc box with real FPU, or even on ibm4xx with
environmental OPENSSL_ppccap=0, which forcibly disables assembly codes
optimized for FPU.

Note that this is not a bug in code for Chacha20, but that for poly1305,
only where FPU is utilized.

This means that our FPU emulation is incomplete. I wonder whether we can
implement FPU emulation, in practice, at a level where results of integer
arithmetic are perfectly same as real hardwares.
>How-To-Repeat:
On ibm4xx or booke machines,

cd /usr/tests/crypto/libcrypto && atf-run t_ciphers
>Fix:
As a workaround, turn off FPU optimization on architectures without FPU.
The presence of FPU is automatically detected by openssl, but this test
passes even on machines without FPU because of emulation. Therefore, I'd
like to propose machdep.fpu_present sysctl variable like other ports, and
if it is zero, disable FPU codes in openssl:

http://www.netbsd.org/~rin/powerpc_machdep_fpu_present_20200627.patch
http://www.netbsd.org/~rin/openssl_powerpc_fpu_20200627.patch

Also note that this is meaningful even if we can fix FPU emulation;
codes optimized for ALU should be faster than that with FPU emulation.
So, I will commit the workaround above if there's no objection.



Home | Main Index | Thread Index | Old Index