From 7f90cf30437f44377c575cb7f385a1ad8f1282f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 25 Dec 2021 00:26:17 +0100 Subject: [PATCH] module: icp: remove unused struct crypto_ctx::cc_{session,flags,opstate} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #12901 --- module/icp/api/kcf_mac.c | 7 +++---- module/icp/core/kcf_sched.c | 12 +----------- module/icp/include/sys/crypto/sched_impl.h | 16 +--------------- module/icp/include/sys/crypto/spi.h | 7 ------- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/module/icp/api/kcf_mac.c b/module/icp/api/kcf_mac.c index cf805ee1cc..369ba55cec 100644 --- a/module/icp/api/kcf_mac.c +++ b/module/icp/api/kcf_mac.c @@ -137,7 +137,6 @@ retry: * Arguments: * pd: pointer to the descriptor of the provider to use for this * operation. - * sid: provider session id. * mech: crypto_mechanism_t pointer. * mech_type is a valid value previously returned by * crypto_mech2id(); @@ -168,7 +167,7 @@ retry: * See comment in the beginning of the file. */ static int -crypto_mac_init_prov(crypto_provider_t provider, crypto_session_id_t sid, +crypto_mac_init_prov(crypto_provider_t provider, crypto_mechanism_t *mech, crypto_key_t *key, crypto_spi_ctx_template_t tmpl, crypto_context_t *ctxp, crypto_call_req_t *crq) { @@ -180,7 +179,7 @@ crypto_mac_init_prov(crypto_provider_t provider, crypto_session_id_t sid, ASSERT(KCF_PROV_REFHELD(pd)); /* Allocate and initialize the canonical context */ - if ((ctx = kcf_new_ctx(crq, real_provider, sid)) == NULL) + if ((ctx = kcf_new_ctx(crq, real_provider)) == NULL) return (CRYPTO_HOST_MEMORY); crypto_mechanism_t lmech = *mech; @@ -235,7 +234,7 @@ retry: if (((ctx_tmpl = (kcf_ctx_template_t *)tmpl) != NULL)) spi_ctx_tmpl = ctx_tmpl->ct_prov_tmpl; - error = crypto_mac_init_prov(pd, pd->pd_sid, mech, key, + error = crypto_mac_init_prov(pd, mech, key, spi_ctx_tmpl, ctxp, crq); if (error != CRYPTO_SUCCESS && error != CRYPTO_QUEUED && IS_RECOVERABLE(error)) { diff --git a/module/icp/core/kcf_sched.c b/module/icp/core/kcf_sched.c index 7fe5381f94..d074bab852 100644 --- a/module/icp/core/kcf_sched.c +++ b/module/icp/core/kcf_sched.c @@ -43,8 +43,7 @@ ulong_t kcf_swprov_hndl = 0; * Create a new context. */ crypto_ctx_t * -kcf_new_ctx(crypto_call_req_t *crq, kcf_provider_desc_t *pd, - crypto_session_id_t sid) +kcf_new_ctx(crypto_call_req_t *crq, kcf_provider_desc_t *pd) { crypto_ctx_t *ctx; kcf_context_t *kcf_ctx; @@ -62,11 +61,8 @@ kcf_new_ctx(crypto_call_req_t *crq, kcf_provider_desc_t *pd, ctx = &kcf_ctx->kc_glbl_ctx; ctx->cc_provider = pd->pd_prov_handle; - ctx->cc_session = sid; ctx->cc_provider_private = NULL; ctx->cc_framework_private = (void *)kcf_ctx; - ctx->cc_flags = 0; - ctx->cc_opstate = NULL; return (ctx); } @@ -107,12 +103,6 @@ kcf_free_context(kcf_context_t *kcf_ctx) /* kcf_ctx->kc_prov_desc has a hold on pd */ KCF_PROV_REFRELE(kcf_ctx->kc_prov_desc); - /* check if this context is shared with a provider */ - if ((gctx->cc_flags & CRYPTO_INIT_OPSTATE) && - kcf_ctx->kc_sw_prov_desc != NULL) { - KCF_PROV_REFRELE(kcf_ctx->kc_sw_prov_desc); - } - kmem_cache_free(kcf_context_cache, kcf_ctx); } diff --git a/module/icp/include/sys/crypto/sched_impl.h b/module/icp/include/sys/crypto/sched_impl.h index b322bab5f7..0f39619583 100644 --- a/module/icp/include/sys/crypto/sched_impl.h +++ b/module/icp/include/sys/crypto/sched_impl.h @@ -82,9 +82,6 @@ typedef struct kcf_prov_tried { error == CRYPTO_KEY_SIZE_RANGE || \ error == CRYPTO_NO_PERMISSION) -#define KCF_ATOMIC_INCR(x) atomic_add_32(&(x), 1) -#define KCF_ATOMIC_DECR(x) atomic_add_32(&(x), -1) - /* * Internal representation of a canonical context. We contain crypto_ctx_t * structure in order to have just one memory allocation. The SPI @@ -97,16 +94,6 @@ typedef struct kcf_context { kcf_provider_desc_t *kc_sw_prov_desc; /* Prov. descriptor */ } kcf_context_t; -/* - * Bump up the reference count on the framework private context. A - * global context or a request that references this structure should - * do a hold. - */ -#define KCF_CONTEXT_REFHOLD(ictx) { \ - atomic_add_32(&(ictx)->kc_refcnt, 1); \ - ASSERT((ictx)->kc_refcnt != 0); \ -} - /* * Decrement the reference count on the framework private context. * When the last reference is released, the framework private @@ -159,8 +146,7 @@ extern kcf_prov_tried_t *kcf_insert_triedlist(kcf_prov_tried_t **, kcf_provider_desc_t *, int); extern kcf_provider_desc_t *kcf_get_mech_provider(crypto_mech_type_t, kcf_mech_entry_t **, int *, kcf_prov_tried_t *, crypto_func_group_t); -extern crypto_ctx_t *kcf_new_ctx(crypto_call_req_t *, kcf_provider_desc_t *, - crypto_session_id_t); +extern crypto_ctx_t *kcf_new_ctx(crypto_call_req_t *, kcf_provider_desc_t *); extern void kcf_sched_destroy(void); extern void kcf_sched_init(void); extern void kcf_free_context(kcf_context_t *); diff --git a/module/icp/include/sys/crypto/spi.h b/module/icp/include/sys/crypto/spi.h index a047a30a06..ba383a750e 100644 --- a/module/icp/include/sys/crypto/spi.h +++ b/module/icp/include/sys/crypto/spi.h @@ -65,10 +65,6 @@ typedef void *crypto_spi_ctx_template_t; */ typedef void *crypto_req_handle_t; -/* Values for cc_flags field */ -#define CRYPTO_INIT_OPSTATE 0x00000001 /* allocate and init cc_opstate */ -#define CRYPTO_USE_OPSTATE 0x00000002 /* .. start using it as context */ - /* * The context structure is passed from the kernel to a provider. * It contains the information needed to process a multi-part or @@ -81,11 +77,8 @@ typedef void *crypto_req_handle_t; */ typedef struct crypto_ctx { crypto_provider_handle_t cc_provider; - crypto_session_id_t cc_session; void *cc_provider_private; /* owned by provider */ void *cc_framework_private; /* owned by framework */ - uint32_t cc_flags; /* flags */ - void *cc_opstate; /* state */ } crypto_ctx_t; /*