From e8beeaa1116cc771360a24c9c1f9e6f47ced0e28 Mon Sep 17 00:00:00 2001 From: Attila Fülöp Date: Fri, 30 Oct 2020 23:24:21 +0100 Subject: ICP: gcm: Allocate hash subkey table separately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While evaluating other assembler implementations it turns out that the precomputed hash subkey tables vary in size, from 8*16 bytes (avx2/avx512) up to 48*16 bytes (avx512-vaes), depending on the implementation. To be able to handle the size differences later, allocate `gcm_Htable` dynamically rather then having a fixed size array, and adapt consumers. Reviewed-by: Brian Behlendorf Signed-off-by: Attila Fülöp Closes #11102 --- module/icp/io/aes.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'module/icp/io') diff --git a/module/icp/io/aes.c b/module/icp/io/aes.c index 96fb6bb1a..e540af447 100644 --- a/module/icp/io/aes.c +++ b/module/icp/io/aes.c @@ -1051,6 +1051,16 @@ out: bzero(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len); kmem_free(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len); } +#ifdef CAN_USE_GCM_ASM + if (aes_ctx.ac_flags & (GCM_MODE|GMAC_MODE) && + ((gcm_ctx_t *)&aes_ctx)->gcm_Htable != NULL) { + + gcm_ctx_t *ctx = (gcm_ctx_t *)&aes_ctx; + + bzero(ctx->gcm_Htable, ctx->gcm_htab_len); + kmem_free(ctx->gcm_Htable, ctx->gcm_htab_len); + } +#endif return (ret); } @@ -1209,6 +1219,14 @@ out: vmem_free(((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf, ((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf_len); } +#ifdef CAN_USE_GCM_ASM + if (((gcm_ctx_t *)&aes_ctx)->gcm_Htable != NULL) { + gcm_ctx_t *ctx = (gcm_ctx_t *)&aes_ctx; + + bzero(ctx->gcm_Htable, ctx->gcm_htab_len); + kmem_free(ctx->gcm_Htable, ctx->gcm_htab_len); + } +#endif } return (ret); -- cgit v1.2.3