Re: [PATCH v4 09/24] s390/zcrypt: Introduce pre-allocated device status array for cca misc

Holger Dengler
2025-04-11T13:06:43Z

On 09/04/2025 16:02, Harald Freudenberger wrote:
> Introduce a pre-allocated device status array memory together with
> a mutex controlling the occupation to be used by the findcard2()
> function. Limit the device status array to max 128 cards and max
> 128 domains to reduce the size of this pre-allocated memory to 64 KB.
>
> Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
> Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
> ---
> drivers/s390/crypto/zcrypt_ccamisc.c | 49 ++++++++++++++++++++++------
> 1 file changed, 39 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/s390/crypto/zcrypt_ccamisc.c b/drivers/s390/crypto/zcrypt_ccamisc.c
> index 0d3bf6b1fcb4..f2af3cb7a917 100644
> --- a/drivers/s390/crypto/zcrypt_ccamisc.c
> +++ b/drivers/s390/crypto/zcrypt_ccamisc.c
> @@ -51,6 +51,22 @@ static DEFINE_SPINLOCK(cca_info_list_lock);
> #define CPRB_MEMPOOL_ITEM_SIZE (16 * 1024)
> static mempool_t *cprb_mempool;
>
> +/*
> + * This is a pre-allocated memory for the device status array
> + * used within the findcard() functions. It is currently

findcard() --> findcard2()?

> + * 128 * 128 * 4 bytes = 64 KB big. Usage of this memory is
> + * controlled via dev_status_mem_mutex. Needs adaption if more
> + * than 128 cards or domains to be are supported.
> + */
> +#define ZCRYPT_DEV_STATUS_CARD_MAX 128
> +#define ZCRYPT_DEV_STATUS_QUEUE_MAX 128
> +#define ZCRYPT_DEV_STATUS_ENTRIES (ZCRYPT_DEV_STATUS_CARD_MAX * \
> + ZCRYPT_DEV_STATUS_QUEUE_MAX)
> +#define ZCRYPT_DEV_STATUS_EXT_SIZE (ZCRYPT_DEV_STATUS_ENTRIES * \
> + sizeof(struct zcrypt_device_status_ext))
> +static void *dev_status_mem;
> +static DEFINE_MUTEX(dev_status_mem_mutex);
> +
> /*
> * Simple check if the token is a valid CCA secure AES data key
> * token. If keybitsize is given, the bitsize of the key is
[...]

--
Mit freundlichen Grüßen / Kind regards
Holger Dengler
--
IBM Systems, Linux on IBM Z Development
dengler@linux.ibm.com