Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Aug 2023 09:36:05 -0400
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        Shawn Anastasio <sanastasio@raptorengineering.com>
Cc:        freebsd-ppc@FreeBSD.org, freebsd-hackers@FreeBSD.org, Timothy Pearson <tpearson@raptorengineering.com>, John Baldwin <jhb@freebsd.org>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello,

Good to see this!  I'll answer inline.

On Thu, 3 Aug 2023 12:51:57 -0500
Shawn Anastasio <sanastasio@raptorengineering.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20230804093605.2a61eeed>