crypto: eip93: fix request lifetime and completion handling
v2 cover crypto: eip93: fix request lifetime and completion handling
This is v2 of the EIP-93 fix series:
https://lore.kernel.org/linux-crypto/[email protected]/
This series keeps the remaining request lifetime and completion handling fixes from v1. Patch 1/6 from v1 is omitted because an equivalent devm_request_threaded_irq() failure handling fix is already in this tree as commit 85a61bf9145d ("crypto: inside-secure/eip93 - Add check for devm_request_threaded_irq").
The patches collect EIP-93 fixes that had been carried out-of-tree and rework them for the current driver. The original fixes came from work by multiple people; the individual commits carry provenance trailers where the original author, reporter or tester is known.
Tested on a Lumen W1700K2 wireless AP running a Linux 6.18 based OpenWrt build, after verifying that the resulting driver changes match the corresponding OpenWrt patch diffs, modulo upstream context differences.
Changes in v2:
- Drop the IRQ request error patch; the equivalent fix is already present.
- Rebase the remaining fixes onto cryptodev-2.6 master at e264401ce477.
- Keep the remaining code changes unchanged from v1.
Jihong Min (5):
crypto: eip93: guard DMA cleanup on uninitialized mappings
crypto: eip93: reject HMAC requests before setkey
crypto: eip93: use request-local SA records for cipher requests
crypto: eip93: order result descriptor reads after PE_READY
crypto: eip93: handle request ID exhaustion
.../crypto/inside-secure/eip93/eip93-aead.c | 34 +++++--- .../crypto/inside-secure/eip93/eip93-cipher.c | 34 +++++--- .../crypto/inside-secure/eip93/eip93-cipher.h | 3 +- .../crypto/inside-secure/eip93/eip93-common.c | 65 ++++++++++++--- .../crypto/inside-secure/eip93/eip93-common.h | 3 + .../crypto/inside-secure/eip93/eip93-hash.c | 79 +++++++++++++------ .../crypto/inside-secure/eip93/eip93-main.c | 19 +++-- .../crypto/inside-secure/eip93/eip93-main.h | 2 + 8 files changed, 174 insertions(+), 65 deletions(-)
base-commit: e264401ce4776a288524e5b87593d4d864147115
Signature · 1 line
2.53.0
PATCH v2 1/5 crypto: eip93: guard DMA cleanup on uninitialized mappings
Several error paths can reach cleanup before all DMA addresses have been initialized or mapped. Initialize request DMA handles and check them before cleanup so the driver does not unmap zero or stale addresses.
If mapping the temporary HMAC SA record fails, also release the block data DMA mapping that was already active.
--- .../crypto/inside-secure/eip93/eip93-common.c | 8 ++- .../crypto/inside-secure/eip93/eip93-hash.c | 54 ++++++++++++------- 2 files changed, 41 insertions(+), 21 deletions(-)
drivers/crypto/inside-secure/eip93/eip93-common.c +6 -2
@@ -527,6 +527,8 @@ int eip93_send_req(struct crypto_async_request *async, rctx->sa_state_ctr =NULL ; rctx->sa_state =NULL ; + rctx->sa_state_ctr_base =0 ; + rctx->sa_state_base =0 ;if (IS_ECB (flags)) goto skip_iv;
@@ -534,8 +536,10 @@ int eip93_send_req(struct crypto_async_request *async,memcpy (iv, reqiv, rctx->ivsize); rctx->sa_state =kzalloc (sizeof (*rctx->sa_state),GFP_KERNEL ); -if (!rctx->sa_state) -return -ENOMEM ; +if (!rctx->sa_state) { + err = -ENOMEM ; + goto free_sa_state; + } sa_state = rctx->sa_state;
drivers/crypto/inside-secure/eip93/eip93-hash.c +35 -19
111 lines not on this page · raw message
Signature · 1 line
2.53.0
Herbert Xu
maintainerRe: [PATCH v2 1/5] crypto: eip93: guard DMA cleanup on uninitialized mappings
drivers/crypto/inside-secure/eip93/eip93-common.c int eip93_send_req(struct crypto_async_request *async, · line 542
Quoted 11 lines · Jihong Min
drivers/crypto/inside-secure/eip93/eip93-common.c +4
-2@@ -534,8 +536,10 @@ int eip93_send_req(struct crypto_async_request *async,memcpy (iv, reqiv, rctx->ivsize); rctx->sa_state =kzalloc (sizeof (*rctx->sa_state),GFP_KERNEL ); -if (!rctx->sa_state) -return -ENOMEM ; +if (!rctx->sa_state) { + err = -ENOMEM ; + goto free_sa_state; + }
What kind of non-sense is this?
Please stop wasting my time.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH v2 2/5 crypto: eip93: reject HMAC requests before setkey
In reply to Jihong MinHMAC requests need the precomputed ipad/opad state installed by setkey(). Using an HMAC tfm before setkey() initializes the request with an all-zero ipad and produces invalid hardware input.
Reject those requests during hash init so the failure is explicit.
--- drivers/crypto/inside-secure/eip93/eip93-hash.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/inside-secure/eip93/eip93-hash.c +3 -0
@@ -300,6 +300,9 @@ static int eip93_hash_init(struct ahash_request *req)struct eip93_hash_ctx *ctx =crypto_ahash_ctx (ahash);struct sa_state *sa_state = &rctx->sa_state; +if (IS_HMAC (ctx->flags) && !memchr_inv (ctx->ipad,0 ,SHA256_BLOCK_SIZE )) +return -EINVAL ; +memset (sa_state->state_byte_cnt,0 ,sizeof (u32) *2 );eip93_hash_init_sa_state_digest (ctx->flags &EIP93_HASH_MASK , sa_state->state_i_digest);
Signature · 1 line
2.53.0
PATCH v2 3/5 crypto: eip93: use request-local SA records for cipher requests
In reply to Jihong MinCipher and AEAD requests keep mutable direction and copy flags in the SA record. Updating the tfm-level SA record for decrypt requests can leak those settings into concurrent requests using the same transform.
Copy the prepared SA record into the request context and apply the request-specific flags there. Map that request-local record for DMA, then unmap it on normal completion and validation failures.
--- .../crypto/inside-secure/eip93/eip93-aead.c | 34 +++++++++++++------ .../crypto/inside-secure/eip93/eip93-cipher.c | 34 ++++++++++++------- .../crypto/inside-secure/eip93/eip93-cipher.h | 3 +- .../crypto/inside-secure/eip93/eip93-common.c | 9 +++++ 4 files changed, 55 insertions(+), 25 deletions(-)
drivers/crypto/inside-secure/eip93/eip93-aead.c +23 -11
@@ -42,12 +42,18 @@ void eip93_aead_handle_result(struct crypto_async_request *async, int err)static int eip93_aead_send_req (struct crypto_async_request *async) { +struct eip93_crypto_ctx *ctx =crypto_tfm_ctx (async->tfm);struct aead_request *req =aead_request_cast (async);struct eip93_cipher_reqctx *rctx =aead_request_ctx (req);int err; err =check_valid_request (rctx);if (err) { +if (rctx->sa_record_base) { +dma_unmap_single (ctx->eip93->dev, rctx->sa_record_base, +sizeof (rctx->sa_record),DMA_TO_DEVICE ); + rctx->sa_record_base =0 ; + }aead_request_complete (req, err);return err; }
@@ -81,8 +87,6 @@ static void eip93_aead_cra_exit(struct crypto_tfm *tfm) {struct eip93_crypto_ctx *ctx =crypto_tfm_ctx (tfm); -dma_unmap_single (ctx->eip93->dev, ctx->sa_record_base, -sizeof (*ctx->sa_record),DMA_TO_DEVICE );kfree (ctx->sa_record); }
@@ -191,11 +195,24 @@ static int eip93_aead_crypt(struct aead_request *req)struct crypto_aead *aead =crypto_aead_reqtfm (req);int ret; - ctx->sa_record_base =dma_map_single (ctx->eip93->dev, ctx->sa_record, -sizeof (*ctx->sa_record),DMA_TO_DEVICE ); - ret =dma_mapping_error (ctx->eip93->dev, ctx->sa_record_base); -if (ret) +memcpy (&rctx->sa_record, ctx->sa_record,sizeof (rctx->sa_record)); +if (IS_DECRYPT (rctx->flags)) { + rctx->sa_record.sa_cmd0_word |=EIP93_SA_CMD_DIRECTION_IN ; + rctx->sa_record.sa_cmd1_word &= ~(EIP93_SA_CMD_COPY_PAD | +EIP93_SA_CMD_COPY_DIGEST ); + }else { + rctx->sa_record.sa_cmd0_word &= ~EIP93_SA_CMD_DIRECTION_IN ; + rctx->sa_record.sa_cmd1_word |=EIP93_SA_CMD_COPY_PAD | +EIP93_SA_CMD_COPY_DIGEST ; + } + + rctx->sa_record_base =dma_map_single (ctx->eip93->dev, &rctx->sa_record, +sizeof (rctx->sa_record),DMA_TO_DEVICE ); + ret =dma_mapping_error (ctx->eip93->dev, rctx->sa_record_base); +if (ret) { + rctx->sa_record_base =0 ;return ret; + } rctx->textsize = req->cryptlen; rctx->blksize = ctx->blksize;
@@ -205,7 +222,6 @@ static int eip93_aead_crypt(struct aead_request *req) rctx->sg_dst = req->dst; rctx->ivsize =crypto_aead_ivsize (aead); rctx->desc_flags =EIP93_DESC_AEAD ; - rctx->sa_record_base = ctx->sa_record_base;if (IS_DECRYPT (rctx->flags)) rctx->textsize -= rctx->authsize;
@@ -238,10 +254,6 @@ static int eip93_aead_decrypt(struct aead_request *req)struct eip93_crypto_ctx *ctx =crypto_tfm_ctx (req->base.tfm);struct eip93_cipher_reqctx *rctx =aead_request_ctx (req); - ctx->sa_record->sa_cmd0_word |=EIP93_SA_CMD_DIRECTION_IN ; - ctx->sa_record->sa_cmd1_word &= ~(EIP93_SA_CMD_COPY_PAD | -EIP93_SA_CMD_COPY_DIGEST ); - rctx->flags = ctx->flags; rctx->flags |=EIP93_DECRYPT ;if (ctx->set_assoc) {
drivers/crypto/inside-secure/eip93/eip93-cipher.c +21 -13
@@ -32,6 +32,7 @@ void eip93_skcipher_handle_result(struct crypto_async_request *async, int err)static int eip93_skcipher_send_req (struct crypto_async_request *async) { +struct eip93_crypto_ctx *ctx =crypto_tfm_ctx (async->tfm);struct skcipher_request *req =skcipher_request_cast (async);struct eip93_cipher_reqctx *rctx =skcipher_request_ctx (req);int err;
@@ -39,6 +40,11 @@ static int eip93_skcipher_send_req(struct crypto_async_request *async) err =check_valid_request (rctx);if (err) { +if (rctx->sa_record_base) { +dma_unmap_single (ctx->eip93->dev, rctx->sa_record_base, +sizeof (rctx->sa_record),DMA_TO_DEVICE ); + rctx->sa_record_base =0 ; + }skcipher_request_complete (req, err);return err; }
@@ -72,8 +78,6 @@ static void eip93_skcipher_cra_exit(struct crypto_tfm *tfm) {struct eip93_crypto_ctx *ctx =crypto_tfm_ctx (tfm); -dma_unmap_single (ctx->eip93->dev, ctx->sa_record_base, -sizeof (*ctx->sa_record),DMA_TO_DEVICE );kfree (ctx->sa_record); }
@@ -133,7 +137,7 @@ static int eip93_skcipher_setkey(struct crypto_skcipher *ctfm, const u8 *key,return 0 ; } -static int eip93_skcipher_crypt (struct skcipher_request *req) +static int eip93_skcipher_crypt (struct skcipher_request *req,bool encrypt) {struct eip93_cipher_reqctx *rctx =skcipher_request_ctx (req);struct crypto_async_request *async = &req->base;
@@ -153,11 +157,19 @@ static int eip93_skcipher_crypt(struct skcipher_request *req) crypto_skcipher_blocksize(skcipher)))return -EINVAL ; - ctx->sa_record_base =dma_map_single (ctx->eip93->dev, ctx->sa_record, -sizeof (*ctx->sa_record),DMA_TO_DEVICE ); - ret =dma_mapping_error (ctx->eip93->dev, ctx->sa_record_base); -if (ret) +memcpy (&rctx->sa_record, ctx->sa_record,sizeof (rctx->sa_record)); +if (encrypt) + rctx->sa_record.sa_cmd0_word &= ~EIP93_SA_CMD_DIRECTION_IN ; +else + rctx->sa_record.sa_cmd0_word |=EIP93_SA_CMD_DIRECTION_IN ; + + rctx->sa_record_base =dma_map_single (ctx->eip93->dev, &rctx->sa_record, +sizeof (rctx->sa_record),DMA_TO_DEVICE ); + ret =dma_mapping_error (ctx->eip93->dev, rctx->sa_record_base); +if (ret) { + rctx->sa_record_base =0 ;return ret; + } rctx->assoclen =0 ; rctx->textsize = req->cryptlen;
@@ -167,7 +179,6 @@ static int eip93_skcipher_crypt(struct skcipher_request *req) rctx->ivsize =crypto_skcipher_ivsize (skcipher); rctx->blksize = ctx->blksize; rctx->desc_flags =EIP93_DESC_SKCIPHER ; - rctx->sa_record_base = ctx->sa_record_base;return eip93_skcipher_send_req (async); }
@@ -181,22 +192,19 @@ static int eip93_skcipher_encrypt(struct skcipher_request *req) rctx->flags = tmpl->flags; rctx->flags |=EIP93_ENCRYPT ; -return eip93_skcipher_crypt (req); +return eip93_skcipher_crypt (req, true); }static int eip93_skcipher_decrypt (struct skcipher_request *req) { -struct eip93_crypto_ctx *ctx =crypto_tfm_ctx (req->base.tfm);struct eip93_cipher_reqctx *rctx =skcipher_request_ctx (req);struct eip93_alg_template *tmpl =container_of (req->base.tfm->__crt_alg, struct eip93_alg_template, alg.skcipher.base); - ctx->sa_record->sa_cmd0_word |=EIP93_SA_CMD_DIRECTION_IN ; - rctx->flags = tmpl->flags; rctx->flags |=EIP93_DECRYPT ; -return eip93_skcipher_crypt (req); +return eip93_skcipher_crypt (req, false); }/* Available algorithms in this module */
drivers/crypto/inside-secure/eip93/eip93-cipher.h +2 -1
@@ -9,6 +9,7 @@#define _EIP93_CIPHER_H_#include "eip93-main.h" +#include "eip93-regs.h" struct eip93_crypto_ctx {struct eip93_device *eip93;
@@ -16,7 +17,6 @@ struct eip93_crypto_ctx {struct sa_record *sa_record;u32 sa_nonce;int blksize; -dma_addr_t sa_record_base;/* AEAD specific */ unsigned int authsize;unsigned int assoclen;
@@ -32,6 +32,7 @@ struct eip93_cipher_reqctx {unsigned int textsize;unsigned int assoclen;unsigned int authsize; +struct sa_record sa_record__aligned(CRYPTO_DMA_ALIGN) ;dma_addr_t sa_record_base;struct sa_state *sa_state;dma_addr_t sa_state_base;
drivers/crypto/inside-secure/eip93/eip93-common.c +9 -0
@@ -637,6 +637,10 @@ int eip93_send_req(struct crypto_async_request *async, DMA_TO_DEVICE); free_sa_state:kfree (rctx->sa_state); +if (rctx->sa_record_base) +dma_unmap_single (eip93->dev, rctx->sa_record_base, +sizeof (rctx->sa_record),DMA_TO_DEVICE ); + rctx->sa_record_base =0 ;return err; }
@@ -693,6 +697,11 @@ void eip93_handle_result(struct eip93_device *eip93, struct eip93_cipher_reqctxsizeof (*rctx->sa_state_ctr), DMA_FROM_DEVICE); +if (rctx->sa_record_base) +dma_unmap_single (eip93->dev, rctx->sa_record_base, +sizeof (rctx->sa_record),DMA_TO_DEVICE ); + rctx->sa_record_base =0 ; +if (rctx->sa_state) dma_unmap_single(eip93->dev, rctx->sa_state_base, sizeof(*rctx->sa_state),
Signature · 1 line
2.53.0
PATCH v2 4/5 crypto: eip93: order result descriptor reads after PE_READY
In reply to Jihong MinThe result handler polls ownership bits until the packet engine reports the descriptor as ready. Ensure later descriptor reads observe the DMA writes that completed before PE_READY became visible.
Use the value already read from the descriptor for error parsing.
--- drivers/crypto/inside-secure/eip93/eip93-main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/crypto/inside-secure/eip93/eip93-main.c +8 -5
@@ -224,11 +224,14 @@ static void eip93_handle_result_descriptor(struct eip93_device *eip93)FIELD_GET (EIP93_PE_LENGTH_HOST_PE_READY , pe_length) != EIP93_PE_LENGTH_PE_READY); - err = rdesc->pe_ctrl_stat_word & (EIP93_PE_CTRL_PE_EXT_ERR_CODE | -EIP93_PE_CTRL_PE_EXT_ERR | -EIP93_PE_CTRL_PE_SEQNUM_ERR | -EIP93_PE_CTRL_PE_PAD_ERR | -EIP93_PE_CTRL_PE_AUTH_ERR ); +/* Order descriptor reads after device ownership is returned. */ +dma_rmb (); + + err = pe_ctrl_stat & (EIP93_PE_CTRL_PE_EXT_ERR_CODE | +EIP93_PE_CTRL_PE_EXT_ERR | +EIP93_PE_CTRL_PE_SEQNUM_ERR | +EIP93_PE_CTRL_PE_PAD_ERR | +EIP93_PE_CTRL_PE_AUTH_ERR ); desc_flags =FIELD_GET (EIP93_PE_USER_ID_DESC_FLAGS , rdesc->user_id); crypto_idr =FIELD_GET (EIP93_PE_USER_ID_CRYPTO_IDR , rdesc->user_id);
Signature · 1 line
2.53.0
PATCH v2 5/5 crypto: eip93: handle request ID exhaustion
In reply to Jihong MinThe driver stores the async request pointer in an IDR and places the ID in the hardware descriptor. The old allocation used the ring depth as the IDR limit. It also did not check allocation failure, so request pressure could encode a negative error value as a descriptor user ID.
Allocate request IDs from the full user ID field range and wait while the IDR is full. Publish the descriptor only after DMA mappings and ID allocation have succeeded. Add unwind paths for mappings that are active when ID allocation fails, and tolerate stale or missing result IDs in the interrupt handler.
--- .../crypto/inside-secure/eip93/eip93-common.c | 48 +++++++++++++++---- .../crypto/inside-secure/eip93/eip93-common.h | 3 ++ .../crypto/inside-secure/eip93/eip93-hash.c | 26 +++++++--- .../crypto/inside-secure/eip93/eip93-main.c | 6 +++ .../crypto/inside-secure/eip93/eip93-main.h | 2 + 5 files changed, 69 insertions(+), 16 deletions(-)
drivers/crypto/inside-secure/eip93/eip93-common.c +39 -9
@@ -65,6 +65,31 @@ int eip93_parse_ctrl_stat_err(struct eip93_device *eip93, int err) } } +int eip93_alloc_request_id (struct eip93_device *eip93,void *request) +{ +int id; + +scoped_guard (spinlock_bh, &eip93->ring->idr_lock) + id = idr_alloc(&eip93->ring->crypto_async_idr, request, 0, +EIP93_REQUEST_IDR_LIMIT ,GFP_ATOMIC ); + +return id; +} + +int eip93_alloc_request_id_wait (struct eip93_device *eip93,void *request) +{ +int id; + +for (;;) { + id =eip93_alloc_request_id (eip93, request); +if (id != -ENOSPC ) +return id; + +usleep_range (EIP93_RING_BUSY_DELAY , +EIP93_RING_BUSY_DELAY *2 ); + } +} +static void *eip93_ring_next_wptr (struct eip93_device *eip93,struct eip93_desc_ring *ring) {
@@ -597,15 +622,6 @@ int eip93_send_req(struct crypto_async_request *async, cdesc.sa_addr = rctx->sa_record_base; cdesc.arc4_addr =0 ; - scoped_guard(spinlock_bh, &eip93->ring->idr_lock) - crypto_async_idr =idr_alloc (&eip93->ring->crypto_async_idr, async,0 , -EIP93_RING_NUM -1 ,GFP_ATOMIC ); - - cdesc.user_id =FIELD_PREP (EIP93_PE_USER_ID_CRYPTO_IDR , (u16 )crypto_async_idr) | -FIELD_PREP (EIP93_PE_USER_ID_DESC_FLAGS , rctx->desc_flags); - - rctx->cdesc = &cdesc; -/* map DMA_BIDIRECTIONAL to invalidate cache on destination * implies __dma_cache_wback_inv */
@@ -620,8 +636,22 @@ int eip93_send_req(struct crypto_async_request *async, goto free_sg_dma; } + crypto_async_idr =eip93_alloc_request_id_wait (eip93, async); +if (crypto_async_idr <0 ) { + err = crypto_async_idr; + goto free_src_sg_dma; + } + + cdesc.user_id =FIELD_PREP (EIP93_PE_USER_ID_CRYPTO_IDR , crypto_async_idr) | +FIELD_PREP (EIP93_PE_USER_ID_DESC_FLAGS , rctx->desc_flags); + + rctx->cdesc = &cdesc; +return eip93_scatter_combine (eip93, rctx, datalen, split, offsetin); +free_src_sg_dma: +if (src != dst) +dma_unmap_sg (eip93->dev, src, rctx->src_nents,DMA_TO_DEVICE ); free_sg_dma:dma_unmap_sg (eip93->dev, dst, rctx->dst_nents,DMA_BIDIRECTIONAL ); free_sa_state_ctr_dma:
drivers/crypto/inside-secure/eip93/eip93-common.h +3 -0
@@ -17,6 +17,9 @@ void eip93_set_sa_record(struct sa_record *sa_record, const unsigned int keylen,int eip93_parse_ctrl_stat_err (struct eip93_device *eip93,int err); +int eip93_alloc_request_id (struct eip93_device *eip93,void *request); +int eip93_alloc_request_id_wait (struct eip93_device *eip93,void *request); +int eip93_hmac_setkey (u32 ctx_flags,const u8 *key,unsigned int keylen,unsigned int hashlen,u8 *ipad,u8 *opad,bool skip_ipad);
drivers/crypto/inside-secure/eip93/eip93-hash.c +19 -7
@@ -221,6 +221,7 @@ static int eip93_send_hash_req(struct crypto_async_request *async, u8 *data,struct eip93_device *eip93 = ctx->eip93;struct eip93_descriptor cdesc = { };dma_addr_t src_addr; +bool hmac_sa_mapped = false;int ret;/* Map block data to DMA */
@@ -258,22 +259,23 @@ static int eip93_send_hash_req(struct crypto_async_request *async, u8 *data, ret =dma_mapping_error (eip93->dev, rctx->sa_record_hmac_base);if (ret) { rctx->sa_record_hmac_base =0 ; -dma_unmap_single (eip93->dev, src_addr, len, -DMA_TO_DEVICE ); -return ret; + goto unmap_src; } cdesc.sa_addr = rctx->sa_record_hmac_base; + hmac_sa_mapped = true; } cdesc.pe_ctrl_stat_word |=EIP93_PE_CTRL_PE_HASH_FINAL ; } - scoped_guard(spinlock_bh, &eip93->ring->idr_lock) - crypto_async_idr =idr_alloc (&eip93->ring->crypto_async_idr, async,0 , -EIP93_RING_NUM -1 ,GFP_ATOMIC ); + crypto_async_idr =eip93_alloc_request_id_wait (eip93, async); +if (crypto_async_idr <0 ) { + ret = crypto_async_idr; + goto unmap_hmac_sa; + } - cdesc.user_id |=FIELD_PREP (EIP93_PE_USER_ID_CRYPTO_IDR , (u16 )crypto_async_idr) | + cdesc.user_id |=FIELD_PREP (EIP93_PE_USER_ID_CRYPTO_IDR , crypto_async_idr) |FIELD_PREP (EIP93_PE_USER_ID_DESC_FLAGS ,EIP93_DESC_LAST ); }
@@ -291,6 +293,16 @@ static int eip93_send_hash_req(struct crypto_async_request *async, u8 *data, *data_dma = src_addr;return 0 ; + +unmap_hmac_sa: +if (hmac_sa_mapped) { +dma_unmap_single (eip93->dev, rctx->sa_record_hmac_base, +sizeof (rctx->sa_record_hmac),DMA_TO_DEVICE ); + rctx->sa_record_hmac_base =0 ; + } +unmap_src: +dma_unmap_single (eip93->dev, src_addr, len,DMA_TO_DEVICE ); +return ret; }static int eip93_hash_init (struct ahash_request *req)
drivers/crypto/inside-secure/eip93/eip93-main.c +6 -0
@@ -257,6 +257,12 @@ static void eip93_handle_result_descriptor(struct eip93_device *eip93)idr_remove (&eip93->ring->crypto_async_idr, crypto_idr); } +if (!async) { +dev_warn_ratelimited (eip93->dev,"missing request id %u\n" , + crypto_idr); + goto get_more; + } +/* Parse error in ctrl stat word */ err =eip93_parse_ctrl_stat_err (eip93, err);
drivers/crypto/inside-secure/eip93/eip93-main.h +2 -0
@@ -13,11 +13,13 @@#include <crypto/internal/skcipher.h> #include <linux/bitfield.h> #include <linux/interrupt.h> +#include <linux/limits.h> #define EIP93_RING_BUSY_DELAY 500#define EIP93_RING_NUM 512#define EIP93_RING_BUSY 32 +#define EIP93_REQUEST_IDR_LIMIT (U16_MAX + 1)#define EIP93_CRA_PRIORITY 1500#define EIP93_RING_SA_STATE_ADDR (base, idx) ((base) + (idx))
Signature · 1 line
2.53.0