From nobody Fri Aug 04 13:36:05 2023 X-Original-To: freebsd-ppc@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 4RHRZ019Hsz4kTK0; Fri, 4 Aug 2023 13:36:08 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RHRZ00J0cz3CB1; Fri, 4 Aug 2023 13:36:08 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691156168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0uNWYYnTDq/VsgaoM7Gz88oWckbqfTd9WXszadGHlHs=; b=CMv/0qPnN9qJ7UZLopHjtiKSpk1Nxk+DhD985KOyasZYX3xVJe/J+uRVDfhhIiNrGndnzg 3DclY+SVYy1Pm0zj5G9Xf/XWRhOwQa+MEq2QGrCKJDfeRmweDgNtznFjrM/bVBt0p9Zpwu cLa+u1ftgy6xrT80YxMbVOvJOBGiSJxnRxXKQvIcGDJO+NPgx9um8zCH9n4RhU0aR97Zty ie0to8VaWNpotbffaAUHVKr5d345lvNGoKNnuKzvGDarXLtPzsLHjOHTZb2QOvbascXlmA voKu6JJJ+Fsa0OY3fp9TF0E6suFgwAz4ahjJH5jIqwk9wWvWUFDBz/WmgR9DxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691156168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0uNWYYnTDq/VsgaoM7Gz88oWckbqfTd9WXszadGHlHs=; b=Ljwh13sKvW6Y48rxM6qoLL+wugY0MKmKZzL+skwfg1TCH6zKWSWkq/M/Fguaq+j2oBcgcR U6KzfTWRAE3w/waauA7XUJt30dqMdoA563HIo3cYf+usDQSxYJu35A/8hZbMLsMgkOsdPs 4oH/hLSLCqLNiidsYkNnqsqY9YegSwyIq9Bz6ymyl3arSWHxU6Xe4Wqdjg2MW02702f743 S+zfJDUbfV57yH/lGHXIV7QM5+0k9bpAHGtqg4UxXeFfVsS8SU2mk/saB9vR8ncFvNLs4g GANggh9RIykJmp5FKzqZC/iqEdPAjzqzN9fcvLZE1KedVEE7vLVLhG6hR/mpiA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691156168; a=rsa-sha256; cv=none; b=RObrsH7YmWsI2rshvLtDh8nNtHcWeIcg4SZi1t/02ob567xW66NFL1IS73NRFWCTcAI77W bHr2y7S1VJVPjLmSQabrkCmzyAdpFyFzAi0fgHQ7SsHFasbnsPsnChfdpRO9zjJY+E4TmG jDilDYpcGplep/d0cPFFhoPLcOi7UbRgJVJTUcB1/faDECZyOYwKe740/rNYbi3SoOMfBq qPI23ZLAmp/cqYSnWa5cJfWPDXwow32UdG0RL2U+ML/Rk1A8pN9KQuOvKvhohJgXbOFdeH /EJlOqWd2XvZ7rRz//DZHmLL22gk0TN46WVmwO5yHiq0q9Wy1Bux1+MFKPD3Ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from ralga.knownspace (ip-163-182-7-56.dynamic.fuse.net [163.182.7.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhibbits) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RHRYz4kGlz11LF; Fri, 4 Aug 2023 13:36:07 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Date: Fri, 4 Aug 2023 09:36:05 -0400 From: Justin Hibbits To: Shawn Anastasio Cc: freebsd-ppc@FreeBSD.org, freebsd-hackers@FreeBSD.org, Timothy Pearson , John Baldwin Subject: Re: Implementing in-kernel AES crypto acceleration on ppc (POWER8+) Message-ID: <20230804093605.2a61eeed@ralga.knownspace> In-Reply-To: <0c24b4b7-b4c8-242d-6187-15b171c50c19@raptorengineering.com> References: <0c24b4b7-b4c8-242d-6187-15b171c50c19@raptorengineering.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; powerpc64le-unknown-linux-gnu) List-Id: Porting FreeBSD to the PowerPC List-Archive: https://lists.freebsd.org/archives/freebsd-ppc List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ppc@freebsd.org X-BeenThere: freebsd-ppc@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello, Good to see this! I'll answer inline. On Thu, 3 Aug 2023 12:51:57 -0500 Shawn Anastasio wrote: > Hello all, > > Raptor Engineering is interested in adding support for in-kernel AES > acceleration on ppc64 via the VMX crypto instructions added in ISA > 2.07B, and I wanted to reach out to the community with a few > questions. I would love to see this added. > > 1. As I understand it, FreeBSD already has support for in-kernel > crypto acceleration on x86 and ARM via the aesni and armv8_crypto > drivers respectively that each implement the cryptodev interface. Am I > correct in understanding that adding AES acceleration for Power > would just involve creating another driver here, or are there other > pieces of the puzzle that I've missed? John Baldwin can probably answer this better, but I think your understanding is correct. There might be some plumbing needed as well, but that should be minimal. > > 2. I see that both the aesni and armv8 drivers make use of the > fpu_kern_enter/fpu_kern_leave functions to guard access to vector > registers, but it appears that these functions aren't implemented > on ppc. Is that correct, or does an in-kernel facility for safely > accessing vector registers on ppc already exist? Nope, ppc doesn't have these facilities yet. It shouldn't be hard to implement, we just haven't done it yet. If you're interested in implementing them, you should be able to model it after arm64, largely. > > 3. For the accelerated AES implementation itself, I've noticed that > cryptogams[*] contains an implementation that is both widely > deployed (and thus tested and likely to be correct) and also BSD > licensed. Would it be acceptable to import the relevant routines to > the FreeBSD kernel and have the new cryptodev driver simply call into > them, or are there other considerations involved? I think the right way to do that would be to import the code as-is as third party code, and call into the routines that you need. You can #ifdef out the unneeded bits, but try to keep it as intact as possible from upstream. > > 4. Is there a userspace test framework for the cryptodev API that > could be used to validate and benchmark the new implementation, or > would I have to write that myself? It appears that OpenSSL had > support for /dev/crypto at one point, but I'm not sure that is the > case any longer. John Baldwin might have some ideas here, too. > > My apologies for the large number of questions, but I look forward to > hearing back and working with the FreeBSD community to get this > implemented. > > Thanks, > Shawn Anastasio > > [*] https://github.com/dot-asm/cryptogams > - Justin