From nobody Wed Nov 24 21:52:23 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AAFF2189917D; Wed, 24 Nov 2021 21:52:29 +0000 (UTC) (envelope-from pkubaj@anongoth.pl) Received: from mail.anongoth.pl (mail.anongoth.pl [46.248.190.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X448 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "anongoth.pl", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hzvqx3MB3z4d93; Wed, 24 Nov 2021 21:52:29 +0000 (UTC) (envelope-from pkubaj@anongoth.pl) Received: from anongoth.pl (unknown [192.168.1.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: pkubaj@anongoth.pl) by mail.anongoth.pl (Postfix) with ESMTPSA id 6804610BF91; Wed, 24 Nov 2021 22:52:24 +0100 (CET) Date: Wed, 24 Nov 2021 22:52:23 +0100 From: Piotr Kubaj To: John Baldwin Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 3a60869237b8 - main - Add assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le Message-ID: References: <202111232227.1ANMRCYk070382@gitrepo.freebsd.org> <133897a3-6db4-9353-cccd-c1d82e23146e@FreeBSD.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gpxZNAEMkcVKCTsV" Content-Disposition: inline In-Reply-To: <133897a3-6db4-9353-cccd-c1d82e23146e@FreeBSD.org> X-Rspamd-Queue-Id: 4Hzvqx3MB3z4d93 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N --gpxZNAEMkcVKCTsV Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 21-11-24 10:34:36, John Baldwin wrote: > On 11/24/21 10:24 AM, Piotr Kubaj wrote: > > OK, it looks like ossl uses fpu_kern functions and those are available = only an aarch64, amd64 and i386: > > cc -O2 -pipe -fno-common -fno-strict-aliasing -Werror -D_KERNEL -DKLD= _MODULE -nostdinc -include /usr/obj/usr/src/powerpc.powerpc64/sys/modules= /ossl/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fn= o-common -fPIC -mlongcall -fno-omit-frame-pointer -fdebug-prefix-map=3D./m= achine=3D/usr/src/sys/powerpc/include -MD -MF.depend.ossl.o -MTossl.o = -mno-altivec -msoft-float -mabi=3Delfv2 -ffreestanding -fwrapv -fstack-prot= ector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissin= g-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__prin= tf__=3D__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option= -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body= -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-poin= ter-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member -Wno= -format-zero-length -std=3Diso9899:1999 -c /usr/src/sys/crypto/openssl/= ossl.c -o ossl.o > > /usr/src/sys/crypto/openssl/ossl.c:190:4: error: implicit declaration o= f function 'fpu_kern_enter' is invalid in C99 [-Werror,-Wimplicit-function-= declaration] > > fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX= ); > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:190:36: error: use of undeclared ide= ntifier 'FPU_KERN_NOCTX' > > fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX= ); > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:193:4: error: implicit declaration o= f function 'fpu_kern_leave' is invalid in C99 [-Werror,-Wimplicit-function-= declaration] > > fpu_kern_leave(curthread, NULL); > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:193:4: note: did you mean 'fpu_kern_= enter'? > > /usr/src/sys/crypto/openssl/ossl.c:190:4: note: 'fpu_kern_enter' declar= ed here > > fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX= ); > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:214:6: error: implicit declaration o= f function 'is_fpu_kern_thread' is invalid in C99 [-Werror,-Wimplicit-funct= ion-declaration] > > if (is_fpu_kern_thread(0)) { > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:217:3: error: implicit declaration o= f function 'fpu_kern_enter' is invalid in C99 [-Werror,-Wimplicit-function-= declaration] > > fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:217:35: error: use of undeclared ide= ntifier 'FPU_KERN_NOCTX' > > fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); > > ^ > > /usr/src/sys/crypto/openssl/ossl.c:263:3: error: implicit declaration o= f function 'fpu_kern_leave' is invalid in C99 [-Werror,-Wimplicit-function-= declaration] > > fpu_kern_leave(curthread, NULL); > > ^ > > 7 errors generated. > >=20 > > AFAIK porting those is not easy and it's certainly above my pay grade. >=20 > Do the powerpc instructions use additional registers that are not part of= the normal > GPRs saved/restored on a context switch? If so, then, yes, you will need= to implement > something here (though the FPU_KERN_NOCTX variant is a bit simpler as it = disables > context switches and it's sufficient just to init the registers and permi= t accesses > without raising a trap until fpu_kern_leave). If not, then you can make = the use of > those functions conditional on architecture. I guess bdragon, jhibbits, luporl or adalava would be better source of info= rmation. That said, after looking at https://community.nxp.com/t5/MPC5xxx/Example-co= de-for-context-switch-for-MPC56XX-PowerPC/m-p/732248/highlight/true, it see= ms like indeed registers other than GPRs are saved and restored. I tried looking at https://cgit.freebsd.org/src/diff/?id=3D6ed982a221e024d6= 4dd0ab776e6197643fa1530e. fpu_kern_enter() and fpu_kern_leave() are quite s= cary :) >=20 > > On 21-11-24 08:15:26, John Baldwin wrote: > >> On 11/23/21 2:27 PM, Piotr Kubaj wrote: > >>> The branch main has been updated by pkubaj (ports committer): > >>> > >>> URL: https://cgit.FreeBSD.org/src/commit/?id=3D3a60869237b8b315fe6649= 7cf5299ec08b688533 > >>> > >>> commit 3a60869237b8b315fe66497cf5299ec08b688533 > >>> Author: Piotr Kubaj > >>> AuthorDate: 2021-11-22 02:28:46 +0000 > >>> Commit: Piotr Kubaj > >>> CommitDate: 2021-11-23 22:26:53 +0000 > >>> > >>> Add assembly optimized code for OpenSSL on powerpc, powerpc64 a= nd powerpc64le > >>> =20 > >>> Summary: > >>> 1. https://github.com/openssl/openssl/commit/34ab13b7d8e3e723ad= b60be8142e38b7c9cd382a > >>> needs to be merged for ELFv2 support on big-endian. > >>> 2. crypto/openssl/crypto/ppccap.c needs to be patched. > >>> Same reason as in https://github.com/openssl/openssl/pull/17082. > >> > >> Have you looked at adding powerpc support to ossl(4)? It should be fa= irly simple > >> (just adding the right asm files in Makefiles and the powerpc equivale= nt of > >> OSSL_cpuid). > >> > >> --=20 > >> John Baldwin >=20 >=20 > --=20 > John Baldwin --=20 --gpxZNAEMkcVKCTsV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEycyIeNkkgohzsoorelmbhSCDnJ0FAmGetBcACgkQelmbhSCD nJ1SoA/8DsY/DUW5sKWt4/j8mkOZpAOAttuYup7q62kGXM26udH4NLpqXZX8wXi8 2cB6JALsW/zqQTwH4NDkrVEzOZYCulxKCOEvsZVmfty14GXN5jVGWbi9IqopNtDq mhd7HT1ajxLhGwfe4UWeJbcP2XiCTxT0XrNy1mazTlBwlYMmvPfIpsd7KrRPmUbA h/md4fa7921xWuz42WUX94hs9enJX7RcxvUyPvxPQkgvgz+r0GBBndyX5JIg98an znkKhtL+RwirzAPe9jDUoD/drc/SlXR3XyqwXSHk34mYIKmUtmVRd0rWa0kz2BBX b8bmTHW5HAS6jwvSJRebZXYdIbLv06uVMKyq1I8I4waB9HpHYCI5ltoXlP/Cpjxx UNTMzlTuE3HDlxMxAI+OkTfgtv+6BTRqG5PX+P3+jaUt2R0zcVtHzIdJWri0t/RE AdiE6hmSSVSOQ3lZq/z3mqILORCqt4Xye5XNGYGPPmwvYGJEue0ZazM7tzYEzcdR DLfObyxfXnsbci23cKD8NvBD/Ij/J4war+oH78Uy8FmVmQKxtELuzbls6HtbVlLL Dqa5HJILbi3wDSAS7nLaxayU9birPJmzSwCf86XI5nBd0nYPBFepqBBpSVMSVRs6 Z2XxbL8IhQljBW1CkZ4B90jXhJZMPYUIH3MtWddnDLk/0q0o9vo= =OZhX -----END PGP SIGNATURE----- --gpxZNAEMkcVKCTsV--