s390/pkey: Provide and pass xflags within pkey and zcrypt layers
authorHarald Freudenberger <freude@linux.ibm.com>
Thu, 24 Apr 2025 13:36:18 +0000 (15:36 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 30 Apr 2025 09:34:03 +0000 (11:34 +0200)
commite5a7f7e0c61cc061f63e5659a0527fd48b216c77
tree3322b9d2e29ad6a2723d94747904b2e086243ed0
parenta42831f0b74dccaaeedc7f420a43b93b952fdf0c
s390/pkey: Provide and pass xflags within pkey and zcrypt layers

Provide and pass the xflag parameter from pkey ioctls through
the pkey handler and further down to the implementations
(CCA, EP11, PCKMO and UV). So all the code is now prepared
and ready to support xflags ("execution flag").

The pkey layer supports the xflag PKEY_XFLAG_NOMEMALLOC: If this
flag is given in the xflags parameter, the pkey implementation is
not allowed to allocate memory but instead should fall back to use
preallocated memory or simple fail with -ENOMEM. This flag is for
protected key derive within a cipher or similar which must not
allocate memory which would cause io operations - see also the
CRYPTO_ALG_ALLOCATES_MEMORY flag in crypto.h.

Within the pkey handlers this flag is then to be translated to
appropriate zcrypt xflags before any zcrypt related functions
are called. So the PKEY_XFLAG_NOMEMALLOC translates to
ZCRYPT_XFLAG_NOMEMALLOC - If this flag is set, no memory
allocations which may trigger any IO operations are done.

The pkey in-kernel pkey API still does not provide this xflag
param. That's intended to come with a separate patch which
enables this functionality.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Link: https://lore.kernel.org/r/20250424133619.16495-25-freude@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
13 files changed:
arch/s390/include/asm/pkey.h
drivers/s390/crypto/pkey_api.c
drivers/s390/crypto/pkey_base.c
drivers/s390/crypto/pkey_base.h
drivers/s390/crypto/pkey_cca.c
drivers/s390/crypto/pkey_ep11.c
drivers/s390/crypto/pkey_pckmo.c
drivers/s390/crypto/pkey_sysfs.c
drivers/s390/crypto/pkey_uv.c
drivers/s390/crypto/zcrypt_ccamisc.c
drivers/s390/crypto/zcrypt_ccamisc.h
drivers/s390/crypto/zcrypt_ep11misc.c
drivers/s390/crypto/zcrypt_ep11misc.h