]> Cypherpunks repositories - gostls13.git/commit
crypto/aes: simplify key expansion in ppc64le asm
authorPaul E. Murphy <murp@ibm.com>
Thu, 24 Mar 2022 15:09:13 +0000 (10:09 -0500)
committerPaul Murphy <murp@ibm.com>
Thu, 7 Apr 2022 20:56:02 +0000 (20:56 +0000)
commit8d581f589eb9b9eac05c75f0dfe82a49c3afcd2f
treef7436b36f32eaa23bdf26b3e70f61c833dc95e1e
parent6f6942ef7afc34c6b7e1eea3031ed61acc458d2a
crypto/aes: simplify key expansion in ppc64le asm

The ported cryptogam implementation uses a subtle and tricky mechanism
using lxv/vperm/lvsl to load unaligned vectors. This is difficult to
read, and may read and write unrelated bytes if reading from an
unaligned address.

Instead, POWER8 instructions can be used to load from unaligned memory
with much less overhead. Alignment interrupts only occur when reading
or writing cache-inhibited memory, which we assume isn't used in go
today, otherwise alignment penalties are usually marginal.

Instead lxvd2x+xxpermdi and xxpermdi+stxvd2x can be used to emulate
unaligned LE bytewise loads, similar to lxv/stxv on POWER9 in
little-endian mode.

Likewise, a custom permute vector is used to emulate BE bytewise
storage operations, lxvb16x/stxvb16x, on POWER9.

This greatly simplifies the code, and it makes it much easier to store
the keys in reverse (which is exactly how the decrypt keys are expected
to be stored).

Change-Id: I2334337e31a8fdf8d13ba96231142a039f237098
Reviewed-on: https://go-review.googlesource.com/c/go/+/395494
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/crypto/aes/asm_ppc64le.s