Re: [PATCH v13 11/18] target/s390x: Base support for cpacf protected keys and pckmo
Ilya Leoshkevich <[email protected]> Wed, 5 Aug 2026 00:00:27 +0200
| Newsgroups | gmane.comp.emulators.qemu |
|---|---|
| Message-ID | <[email protected]> |
On 8/3/26 18:12, Harald Freudenberger wrote:
> Add base support for cpacf protected key handling.
> Add support for the pckmo subfunctions PCKMO-Encrypt-AES-128-Key,
> PCKMO-Encrypt-AES-192-Key and PCKMO-Encrypt-AES-256-Key which deal
> with protected keys. These pckmo subfunctions derive a protected key
> from an AES clear key by encrypting it with an internal AES wrapping
> key. More details about protected keys can be found in the
> "z/Architecture Prinziples of Operation" document.
>
> The qemu version provided here is only a fake intended to make
> protected key available for developing and testing purpose:
> * The protected key is 'derived' from the clear key by xoring
> the fixed pattern 0xAAAA... onto the key value.
> * The AES Wrapping Key Verification Pattern is a fixed
> value of 32 bytes 0xFACEFACE...
>
> Add preprocessor defines for the xor pattern and wkvp used to
> construct ('encrypt') a protected key from a clear key value with
> this implementation. Also add some static functions to 'encrypt'
> from clear key to protected key and 'decrypt' back to cpacf_aes.c.
>
> The preprocessor defines shall be used later in testcases to
> construct and decode protected keys.
>
> Signed-off-by: Harald Freudenberger <[email protected]>
> Tested-by: Holger Dengler <[email protected]>
> ---
> target/s390x/gen-features.c | 3 ++
> target/s390x/tcg/cpacf.h | 29 +++++++++++++++
> target/s390x/tcg/cpacf_aes.c | 64 ++++++++++++++++++++++++++++++++
> target/s390x/tcg/crypto_helper.c | 21 +++++++++++
> target/s390x/tcg/translate.c | 9 ++++-
> 5 files changed, 124 insertions(+), 2 deletions(-)
Should we add IF_PRIV to insn-data.h.inc? POp says PCKMO is privileged,
but currently it seems to be defined as reachable from userspace:
D(0xb928, PCKMO, RRE, MSA3, 0, 0, 0, 0, msa, 0,
S390_FEAT_TYPE_PCKMO)
This may mess up the test, but it should be convertible to a system
test, which can be written in C, see tests/tcg/s390x/mvc-smc.c.
[...]