From nobody Thu Nov 25 13:40:13 2021 X-Original-To: dev-commits-src-main@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 A468B18A039D; Thu, 25 Nov 2021 13:40:25 +0000 (UTC) (envelope-from leandro.lupori@gmail.com) Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J0Jsj3nS8z4qPN; Thu, 25 Nov 2021 13:40:25 +0000 (UTC) (envelope-from leandro.lupori@gmail.com) Received: by mail-oi1-x230.google.com with SMTP id u74so12626000oie.8; Thu, 25 Nov 2021 05:40:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IXFOo5wxcbw/m9/k+jHxZGeSl4hkzyIfkhz4KJOqO78=; b=alqh7QWi/pysA1w7T+B97E/FgV7mb92QMBsbmmrEFZCATp6z2zU6pzTOglJDYIRXIm Hsl4YA6tKKEQnQakV/6l1g2J3rZDNME+k9/W9Guh072YSvU4bM8RBWa50jpo/IXnLfbT qKcKSDInfjIECYHTYkLLIup+/hH9UGhPpOx9h+VkO72DliopKcnBzlmN6yGmTnjOSNl5 WA0RmPyImYIVwLBHOvCkBJxs5VsQsOh26qU39gEwmh+FfhPH/F4W4yjKDsl63fbzHS3o Hm65dcNqJYNZ8KmZOT9xcBbnxXixzAwj5jZxi2y+jI3/MS/4lpKdwbVb4W13NSM+0gac heMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IXFOo5wxcbw/m9/k+jHxZGeSl4hkzyIfkhz4KJOqO78=; b=i3+8XNs8tY2xvmuLV08gE98hpV/AxwOaW1ME7NMiQINiMBttFXyOadUcWNZnQwrPhy cmqQr6bTjl2ZBnIV3kvOsjx5PFxGrYWOL57h+Thzg//hV1GMetalh0EH5hReD1XZ6Vhy PFyzKdSyVYomYB74vDTSgAP1MqAGuLfxMgDr8ILP8aKVRxYjW1TTtpThzpuxiwLYo7L6 ZpSPCWHfebbSDt/8+9Xfkp30bEEdxriSmK8iSTbwg+Qh+KldmXQdmT0tzvFLBEORL5Mf WXnNiyHESeSwmWPRfIlcE5ymnja3EYI3eUbrATAHZPpQq4ThMUfZtXJITSdVRi/SHCXG +Dkg== X-Gm-Message-State: AOAM5307P4zE5u3bVSF2uJNkfGsdjn0nMJx2TbkAxBX/VfSHsRL5RehH eetn6ZLerDKsOFWMnjbGRyRkqHbXWmH3M56bOygqeoMR X-Google-Smtp-Source: ABdhPJzvnEjdeV6lo8lOa7KQskKwQtmeH9DEYfpjQoXrmLDcNekXeWvQEROSGqeSGx1JZEj3DE5iJ5rz0s5DIj1ZmNk= X-Received: by 2002:a05:6808:347:: with SMTP id j7mr15640971oie.111.1637847624820; Thu, 25 Nov 2021 05:40:24 -0800 (PST) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202111232227.1ANMRCYk070382@gitrepo.freebsd.org> <133897a3-6db4-9353-cccd-c1d82e23146e@FreeBSD.org> In-Reply-To: From: Leandro Lupori Date: Thu, 25 Nov 2021 10:40:13 -0300 Message-ID: Subject: Re: git: 3a60869237b8 - main - Add assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le To: Piotr Kubaj Cc: John Baldwin , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000dfa99a05d19d1dec" X-Rspamd-Queue-Id: 4J0Jsj3nS8z4qPN X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N --000000000000dfa99a05d19d1dec Content-Type: text/plain; charset="UTF-8" On Wed, Nov 24, 2021 at 6:52 PM Piotr Kubaj wrote: > 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 -fno-common -fPIC > -mlongcall -fno-omit-frame-pointer > -fdebug-prefix-map=./machine=/usr/src/sys/powerpc/include -MD > -MF.depend.ossl.o -MTossl.o -mno-altivec -msoft-float -mabi=elfv2 > -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls > -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith > -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__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-pointer-sign -Wno-error-shift-negative-value > -Wno-address-of-packed-member -Wno-format-zero-length -std=iso9899:1999 > -c /usr/src/sys/crypto/openssl/ossl.c -o ossl.o > > > /usr/src/sys/crypto/openssl/ossl.c:190:4: error: implicit declaration > of 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 > identifier 'FPU_KERN_NOCTX' > > > fpu_kern_enter(curthread, NULL, > FPU_KERN_NOCTX); > > > ^ > > > /usr/src/sys/crypto/openssl/ossl.c:193:4: error: implicit declaration > of 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' > declared here > > > fpu_kern_enter(curthread, NULL, > FPU_KERN_NOCTX); > > > ^ > > > /usr/src/sys/crypto/openssl/ossl.c:214:6: error: implicit declaration > of function 'is_fpu_kern_thread' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > > > if (is_fpu_kern_thread(0)) { > > > ^ > > > /usr/src/sys/crypto/openssl/ossl.c:217:3: error: implicit declaration > of 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 > identifier 'FPU_KERN_NOCTX' > > > fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); > > > ^ > > > /usr/src/sys/crypto/openssl/ossl.c:263:3: error: implicit declaration > of function 'fpu_kern_leave' is invalid in C99 > [-Werror,-Wimplicit-function-declaration] > > > fpu_kern_leave(curthread, NULL); > > > ^ > > > 7 errors generated. > > > > > > AFAIK porting those is not easy and it's certainly above my pay grade. > > > > 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 > permit 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 > information. > > That said, after looking at > https://community.nxp.com/t5/MPC5xxx/Example-code-for-context-switch-for-MPC56XX-PowerPC/m-p/732248/highlight/true, > it seems like indeed registers other than GPRs are saved and restored. > > > I tried looking at > https://cgit.freebsd.org/src/diff/?id=6ed982a221e024d64dd0ab776e6197643fa1530e. > fpu_kern_enter() and fpu_kern_leave() are quite scary :) > > AFAIK, non-integer registers are also saved/restored on a context switch on PowerPC, but only if there is an underlying user process that has used any FPU/Altivec/VSX instruction. I guess it will need some adjustments if the kernel itself starts using those registers. > > > > > 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=3a60869237b8b315fe66497cf5299ec08b688533 > > >>> > > >>> 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 > and powerpc64le > > >>> > > >>> Summary: > > >>> 1. > https://github.com/openssl/openssl/commit/34ab13b7d8e3e723adb60be8142e38b7c9cd382a > > >>> 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 > fairly simple > > >> (just adding the right asm files in Makefiles and the powerpc > equivalent of > > >> OSSL_cpuid). > > >> > > >> -- > > >> John Baldwin > > > > > > -- > > John Baldwin > > -- > --000000000000dfa99a05d19d1dec--