[PATCH v3 00/14] s390: Extend qemu cpacf support

Harald Freudenberger posted 14 patches 1 day, 20 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260123114308.19401-1-freude@linux.ibm.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Thomas Huth <thuth@redhat.com>
target/s390x/gen-features.c      |  31 +
target/s390x/tcg/cpacf.h         |  51 ++
target/s390x/tcg/cpacf_aes.c     | 969 +++++++++++++++++++++++++++++++
target/s390x/tcg/cpacf_sha256.c  | 229 ++++++++
target/s390x/tcg/cpacf_sha512.c  | 241 ++++++++
target/s390x/tcg/crypto_helper.c | 416 +++++++------
target/s390x/tcg/insn-data.h.inc |   1 +
target/s390x/tcg/meson.build     |   3 +
target/s390x/tcg/translate.c     |   7 +
9 files changed, 1734 insertions(+), 214 deletions(-)
create mode 100644 target/s390x/tcg/cpacf.h
create mode 100644 target/s390x/tcg/cpacf_aes.c
create mode 100644 target/s390x/tcg/cpacf_sha256.c
create mode 100644 target/s390x/tcg/cpacf_sha512.c
[PATCH v3 00/14] s390: Extend qemu cpacf support
Posted by Harald Freudenberger 1 day, 20 hours ago
This patch series extends the s390 qemu cpacf support to be able to
run a subset of the cpacf instruction cross platform. Eric Biggers and
others have asked to be able to verify our s390 cpacf exploitation
code. So here now is a set of patches verified on x86 and s390 which
over (slow but working) support for a subset of the subfunctions of
some of the cpacf instructions.

Test: As this series is more or less complete, a full blown linux
can be run and the 'usual' in-kernel crpyto modules will be
automatically loaded which run a bunch of test cases. So there
is now support for these kernel modules:
* sha256_s390x (autoloaded, sha256)
* sha512_s390x (autoloaded, sha512)
* aes_s390x (autoloaded, clear key aes ecb, cbc, ctr, xts)
* pkey_pckmo (autoloaded, derive AES protected key from clear key)
* paes_s390x (not autoloaded, protected key aes ecb, cbc, ctr, xts)
All these modules run selftests if configured by the kernel (which is
enabled by default). Failures are reported via syslog. Additionally
the aes testcases from libica can be run either inside such an qemu
environment or with a static build executed with the qemu tcg
application qemu-s390x --cpu max <static-build-libica-test>.

Changelog:
v1: Initial version with
    - Related code restructured
    - Support KIMD SHA512 and thus SHA256
    - Support KMC AES-128, AES-192 and AES-256 and thus have basic AES
      support (ECB mode) enabled.
    - Support PCC Compute-XTS-Parameter-AES-128 and
      Compute-XTS-Parameter-AES-256 but only for block sequence number
      0. This is a requirement for the next step:
    - Support KM XTS-AES-128 and KM XTS-AES-256. Together with the
      minimal PCC support this enables AES-XTS CPACF acceleration.
v2: - Basic PCKMO support to be able to 'derive' an AES protected key
      from clear key. See header details.
    - Support protected key AES-ECB.
    - Support protected key AES-CBC.
    - Minimal protected key AES-XTS support for cpacf PCC.
    - Support protected key AES-XTS.
    - Support AES-CTR.
    - Support protected key AES-CTR.
v3: - Reordered patches as suggested by Finn.
    - One small bug fix in cpacf_aes.c related to address translation.

Harald Freudenberger (14):
  target/s390x: Rework s390 cpacf implementations
  target/s390x: Move cpacf sha512 code into a new file
  target/s390x: Support cpacf sha256
  target/s390x: Support AES ECB for cpacf km instruction
  target/s390x: Support AES CBC for cpacf kmc instruction
  target/s390x: Support AES CTR for cpacf kmctr instruction
  target/s390x: Minimal AES XTS support for cpacf pcc instruction
  target/s390x: Support AES XTS for cpacf km instruction
  target/s390x: Support pckmo encrypt AES subfunctions
  target/s390x: Support protected key AES ECB for cpacf km instruction
  target/s390x: Support protected key AES CBC for cpacf kmc instruction
  target/s390x: Support protected key AES CTR for cpacf kmctr
    instruction
  target/s390x: Minimal protected key AES XTS support for cpacf pcc
    instruction
  target/s390x: Support protected key AES XTS for cpacf km instruction

 target/s390x/gen-features.c      |  31 +
 target/s390x/tcg/cpacf.h         |  51 ++
 target/s390x/tcg/cpacf_aes.c     | 969 +++++++++++++++++++++++++++++++
 target/s390x/tcg/cpacf_sha256.c  | 229 ++++++++
 target/s390x/tcg/cpacf_sha512.c  | 241 ++++++++
 target/s390x/tcg/crypto_helper.c | 416 +++++++------
 target/s390x/tcg/insn-data.h.inc |   1 +
 target/s390x/tcg/meson.build     |   3 +
 target/s390x/tcg/translate.c     |   7 +
 9 files changed, 1734 insertions(+), 214 deletions(-)
 create mode 100644 target/s390x/tcg/cpacf.h
 create mode 100644 target/s390x/tcg/cpacf_aes.c
 create mode 100644 target/s390x/tcg/cpacf_sha256.c
 create mode 100644 target/s390x/tcg/cpacf_sha512.c

--
2.43.0