From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E33383C140F; Tue, 5 May 2026 17:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003633; cv=none; b=EOPY397BDTzZ70ib7Emv08vtcr8hn6iGUhpu/MJDfJxYVUxF2qID8elxR9JcWVANGls8hfo7+9hD3moxoPxCXA1kPpZkBZLumaUP2nQiuum7KkNDxN0zLB4tcuWwDiSRs3Y13Zaj5b5NMiSr4Ee6R53znJJRVnLKRWRFD7iY8yU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003633; c=relaxed/simple; bh=d7l8rMF/C3s/JG8I/gsuys9MS5oeVq+HHK5mTKkji48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lm37SNTdUsbN7XQojFGcVjGVt3wLQQG3SYVrbMKaMNSNvfNuIEFx/BRbwJjXDzb1jlgREgcd48OXk6p5ie/JngN9/wATYobqzzE2S+GSM0BWLNfXpHcFM8mXCmvK2hMzk4fJiWkWSyxA4l1EY1ljIU+v1zl/W2B+/dOB/Ckk6pM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HPxPnauu; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HPxPnauu" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id A8428C5CD40; Tue, 5 May 2026 17:54:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B6ADC6053C; Tue, 5 May 2026 17:53:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9EEAB11AD040F; Tue, 5 May 2026 19:53:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003629; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=dxldTbtOSAyaheeA24Yh7elO+quNlogPqqRD2eUj6Dg=; b=HPxPnauuBFBE2L9olxdPuklSRsDxrywpYhKd5ByuOCMQexQo/ZtFcf4rpv2hUsE/Dd/zyp VL6/g5Ovw6ru9f8QAymtmLc2dL9J0aTmc/EucEMt20HTjFYe3u2MXIjJrt3cAzrpXlpKaN ZWU0c1i9yLdnTYYoSc+HqX+0CwaUSzdjBNAA13FRh9qQhGZDAzDLZU54lxN1DzKzdzO5m0 ivaHGdpddvw8mOxwFIElG3Dpi/FEcAOKvKLdF/PatLQXJtWgDhjIJtP/8ptaFQSHuQmJ4u 26tJtfttOckOqoe311tjvmyU1O4zj0+VU+PvwtoPYUPwt+R6OhO/WE0Hrag6pQ== From: Paul Louvel Date: Tue, 05 May 2026 19:53:02 +0200 Subject: [PATCH v2 01/12] crypto: talitos - use dma_sync_single_for_cpu() before reading descriptor header Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-1-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=2033; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=d7l8rMF/C3s/JG8I/gsuys9MS5oeVq+HHK5mTKkji48=; b=z+vo3HqZrvGx5O0cPhVMj2jvHx6+5eZVJJ84tzraSuGzKlVgfEYwAwndK6S7abyBc5f9JKXZS oOTXXRR1b4UAH+JzbymHjIfifcybmRLLpPiloJLIFuEJoYHI1FllNeb X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 In order to know if a descriptor has been processed by the device, the driver polls the FIFO to see if DESC_HDR_DONE is set on a descriptor header to confirm completion. The current code does not make sure that the CPU gets up to date data before reading the descriptor. Fix this by calling dma_sync_single_for_cpu() before reading memory written by the device. Cc: stable@vger.kernel.org Fixes: 58cdbc6d2263 ("crypto: talitos - fix hash on SEC1.") Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index bc61d0fe3514..303640e64717 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -322,15 +322,25 @@ static int talitos_submit(struct device *dev, int ch,= struct talitos_desc *desc, return -EINPROGRESS; } =20 -static __be32 get_request_hdr(struct talitos_request *request, bool is_sec= 1) +static __be32 get_request_hdr(struct device *dev, struct talitos_request *= request, bool is_sec1) { struct talitos_edesc *edesc; + dma_addr_t dma_desc; + + if (!is_sec1) { + dma_sync_single_for_cpu(dev, request->dma_desc, + TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); =20 - if (!is_sec1) return request->desc->hdr; + } =20 if (!request->desc->next_desc) - return request->desc->hdr1; + dma_desc =3D request->dma_desc; + else + dma_desc =3D be32_to_cpu(request->desc->next_desc); + + dma_sync_single_for_cpu(dev, dma_desc, TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); =20 edesc =3D container_of(request->desc, struct talitos_edesc, desc); =20 @@ -358,7 +368,7 @@ static void flush_channel(struct device *dev, int ch, i= nt error, int reset_ch) =20 /* descriptors with their done bits set don't get the error */ rmb(); - hdr =3D get_request_hdr(request, is_sec1); + hdr =3D get_request_hdr(dev, request, is_sec1); =20 if ((hdr & DESC_HDR_DONE) =3D=3D DESC_HDR_DONE) status =3D 0; --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F16447DFA6 for ; Tue, 5 May 2026 17:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003635; cv=none; b=jjlHZtCOMH8Y5EmGwpQmJLDtulX79dL7BIxaPhjnpYHcP3/LWM3oCa2bmVwXW53FKZL2/pIDpC/KoELzwxuLM8ydRBEwvLbGV/jUonU0P7bUB5UsPO8B1r9q5pUofxv4iRwqSH8fNmDaX+o4PSJzozyaFtt0xLDnG4e3oAN6+y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003635; c=relaxed/simple; bh=pRAey5L1DSsy7bJsvUd8hCd84aPrBdRE8Fi+j+xSE/M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q0ibCMcSoyYVKOgvaGEZeiVdWFmU2wRqVMwb6uq/FtW7o8bVr76E5geS8GTDkJQm0gBjQRITtAUVYtgUqzpnz6IiXf+biHx2W4bXNsTvCDIUOmXbvyU2NIBQh3/GaANKQbIH2gnGHUc12YczO8e31N3dOCJ+PbXaUWyMqL5u280= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=epT4wAtS; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="epT4wAtS" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 26A35C5CD43; Tue, 5 May 2026 17:54:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 38E316053C; Tue, 5 May 2026 17:53:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2B90C11AD0410; Tue, 5 May 2026 19:53:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003631; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=AT112QPh74pGH4i61eZtJRpEFTK6WFWEQ+WdSL4kD9Y=; b=epT4wAtSgoRbsxgpcRmXWC4G/EvRVva6/y2DCS1aHxpm4NIn0PeDh/lxb1mc7E2dlLf2OC aow9GNr2r6vZQXIDml6v6zE3cBSVmWWiW4QMKindUZkCW1qUwJV7NzNrps91tRVdqEvK9F FPdtoQIUsGn6jBxOrYe7wW9tVc8y7AbFSAUgZhyAsqZnsBQbgjx1oCmco5GRjJhwkXGvc2 sL6qVm451d9w53ZXMHQDmulHzxjREWVBDOq4TTC9ayRRUecYYHn8LnEx9xGnl/Bqx0ZRPU BwcBBdbxNG2dBB8Id1T5qgromPzXscINyTV62aeF8O66l0pdkib/3O8ElJCG4w== From: Paul Louvel Date: Tue, 05 May 2026 19:53:03 +0200 Subject: [PATCH v2 02/12] crypto: talitos - add chaining of arbitrary number of descriptor for the SEC1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-2-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=12372; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=pRAey5L1DSsy7bJsvUd8hCd84aPrBdRE8Fi+j+xSE/M=; b=73T8LHzjRO5NmOsyJkXCFJTD2kQESvyABSWzMdZMW3WalXHqxcU5a5HbxPRGGaGKgqPS6YiuC dyMfSQkosXDDPUekpiq2sg0pKJZd1HiF9m0hVzKrWAnUuuM7GQYiLzJ X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 The SEC1 hardware can process a chain of descriptors without host intervention. Only the hash implementation currently use this feature, but with a chain of at most 2 descriptors added in commit 37b5e8897eb5 ("crypto: talitos - chain in buffered data for ahash on SEC1"). Add supports for chaining an arbitrary number of descriptors in a chain. Adapt the ahash implementation to make it compatible. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 171 ++++++++++++++++++++++++++++++++++---------= ---- drivers/crypto/talitos.h | 4 ++ 2 files changed, 127 insertions(+), 48 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 303640e64717..d68d307c54f7 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -14,6 +14,7 @@ =20 #include #include +#include #include #include #include @@ -273,7 +274,10 @@ static int talitos_submit(struct device *dev, int ch, = struct talitos_desc *desc, void *context, int error), void *context) { + struct talitos_edesc *edesc =3D container_of(desc, struct talitos_edesc, = desc); struct talitos_private *priv =3D dev_get_drvdata(dev); + dma_addr_t dma_desc, prev_dma_desc; + struct talitos_edesc *prev_edesc =3D NULL; struct talitos_request *request; unsigned long flags; int head; @@ -292,14 +296,37 @@ static int talitos_submit(struct device *dev, int ch,= struct talitos_desc *desc, =20 /* map descriptor and save caller data */ if (is_sec1) { - desc->hdr1 =3D desc->hdr; - request->dma_desc =3D dma_map_single(dev, &desc->hdr1, + request->desc_chain =3D edesc->node.prev; + + list_for_each_entry(edesc, request->desc_chain, node) { + edesc->desc.hdr1 =3D edesc->desc.hdr; + + dma_desc =3D dma_map_single(dev, &edesc->desc.hdr1, + TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); + + if (!prev_edesc) { + request->dma_desc =3D dma_desc; + goto next; + } + + /* Chain in any previous descriptors. */ + + prev_edesc->desc.next_desc =3D cpu_to_be32(dma_desc); + + dma_sync_single_for_device(dev, prev_dma_desc, TALITOS_DESC_SIZE, - DMA_BIDIRECTIONAL); + DMA_TO_DEVICE); + +next: + prev_edesc =3D edesc; + prev_dma_desc =3D dma_desc; + } } else { request->dma_desc =3D dma_map_single(dev, desc, TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); + request->desc_chain =3D NULL; } request->callback =3D callback; request->context =3D context; @@ -324,7 +351,8 @@ static int talitos_submit(struct device *dev, int ch, s= truct talitos_desc *desc, =20 static __be32 get_request_hdr(struct device *dev, struct talitos_request *= request, bool is_sec1) { - struct talitos_edesc *edesc; + struct talitos_edesc *prev_last, *last; + struct talitos_desc *desc; dma_addr_t dma_desc; =20 if (!is_sec1) { @@ -334,17 +362,22 @@ static __be32 get_request_hdr(struct device *dev, str= uct talitos_request *reques return request->desc->hdr; } =20 - if (!request->desc->next_desc) + if (list_is_singular(request->desc_chain)) { + desc =3D request->desc; dma_desc =3D request->dma_desc; - else - dma_desc =3D be32_to_cpu(request->desc->next_desc); + } else { + last =3D list_last_entry(request->desc_chain, + struct talitos_edesc, node); + prev_last =3D list_prev_entry(last, node); + + desc =3D &last->desc; + dma_desc =3D be32_to_cpu(prev_last->desc.next_desc); + } =20 dma_sync_single_for_cpu(dev, dma_desc, TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); =20 - edesc =3D container_of(request->desc, struct talitos_edesc, desc); - - return ((struct talitos_desc *)(edesc->buf + edesc->dma_len))->hdr1; + return desc->hdr1; } =20 /* @@ -354,6 +387,7 @@ static void flush_channel(struct device *dev, int ch, i= nt error, int reset_ch) { struct talitos_private *priv =3D dev_get_drvdata(dev); struct talitos_request *request, saved_req; + struct talitos_edesc *edesc; unsigned long flags; int tail, status; bool is_sec1 =3D has_ftr_sec1(priv); @@ -378,9 +412,23 @@ static void flush_channel(struct device *dev, int ch, = int error, int reset_ch) else status =3D error; =20 - dma_unmap_single(dev, request->dma_desc, - TALITOS_DESC_SIZE, - DMA_BIDIRECTIONAL); + if (is_sec1) { + dma_unmap_single(dev, request->dma_desc, + TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); + + list_for_each_entry(edesc, request->desc_chain, node) { + if (!edesc->desc.next_desc) + break; + + dma_unmap_single( + dev, be32_to_cpu(edesc->desc.next_desc), + TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); + } + } else { + dma_unmap_single(dev, request->dma_desc, + TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); + } =20 /* copy entries so we can call callback outside lock */ saved_req.desc =3D request->desc; @@ -475,8 +523,12 @@ DEF_TALITOS2_DONE(ch1_3, TALITOS2_ISR_CH_1_3_DONE) static __be32 current_desc_hdr(struct device *dev, int ch) { struct talitos_private *priv =3D dev_get_drvdata(dev); + bool is_sec1 =3D has_ftr_sec1(priv); + struct talitos_request *request; + struct talitos_edesc *edesc; int tail, iter; dma_addr_t cur_desc; + __be32 hdr =3D 0; =20 cur_desc =3D ((u64)in_be32(priv->chan[ch].reg + TALITOS_CDPR)) << 32; cur_desc |=3D in_be32(priv->chan[ch].reg + TALITOS_CDPR_LO); @@ -487,27 +539,31 @@ static __be32 current_desc_hdr(struct device *dev, in= t ch) } =20 tail =3D priv->chan[ch].tail; - iter =3D tail; - while (priv->chan[ch].fifo[iter].dma_desc !=3D cur_desc && - priv->chan[ch].fifo[iter].desc->next_desc !=3D cpu_to_be32(cur_des= c)) { - iter =3D (iter + 1) & (priv->fifo_len - 1); - if (iter =3D=3D tail) { - dev_err(dev, "couldn't locate current descriptor\n"); - return 0; + do { + request =3D &priv->chan[ch].fifo[iter]; + + if (request->dma_desc =3D=3D cur_desc) { + hdr =3D request->desc->hdr; + } else if (is_sec1) { + list_for_each_entry(edesc, request->desc_chain, node) { + if (edesc->desc.next_desc =3D=3D + cpu_to_be32(cur_desc)) + hdr =3D list_next_entry(edesc, node) + ->desc.hdr; + } } - } =20 - if (priv->chan[ch].fifo[iter].desc->next_desc =3D=3D cpu_to_be32(cur_desc= )) { - struct talitos_edesc *edesc; + if (hdr) + break; =20 - edesc =3D container_of(priv->chan[ch].fifo[iter].desc, - struct talitos_edesc, desc); - return ((struct talitos_desc *) - (edesc->buf + edesc->dma_len))->hdr; - } + iter =3D (iter + 1) & (priv->fifo_len - 1); + } while (iter !=3D tail); + + if (!hdr) + dev_err(dev, "couldn't locate current descriptor\n"); =20 - return priv->chan[ch].fifo[iter].desc->hdr; + return hdr; } =20 /* @@ -886,6 +942,7 @@ struct talitos_ahash_req_ctx { unsigned int nbuf; struct scatterlist bufsl[2]; struct scatterlist *psrc; + struct list_head desc_list; =20 struct scatterlist request_bufsl[2]; struct ahash_request *areq; @@ -1406,10 +1463,6 @@ static struct talitos_edesc *talitos_edesc_alloc(str= uct device *dev, dma_len =3D 0; } alloc_len +=3D icv_stashing ? authsize : 0; - - /* if its a ahash, add space for a second desc next to the first one */ - if (is_sec1 && !dst) - alloc_len +=3D sizeof(struct talitos_desc); alloc_len +=3D ivsize; =20 edesc =3D kmalloc(ALIGN(alloc_len, dma_get_cache_alignment()), flags); @@ -1421,6 +1474,9 @@ static struct talitos_edesc *talitos_edesc_alloc(stru= ct device *dev, } memset(&edesc->desc, 0, sizeof(edesc->desc)); =20 + if (is_sec1) + INIT_LIST_HEAD(&edesc->node); + edesc->src_nents =3D src_nents; edesc->dst_nents =3D dst_nents; edesc->iv_dma =3D iv_dma; @@ -1725,8 +1781,10 @@ static void common_nonsnoop_hash_unmap(struct device= *dev, struct talitos_private *priv =3D dev_get_drvdata(dev); bool is_sec1 =3D has_ftr_sec1(priv); struct talitos_desc *desc =3D &edesc->desc; - struct talitos_desc *desc2 =3D (struct talitos_desc *) - (edesc->buf + edesc->dma_len); + struct talitos_desc *desc2; + + if (desc->next_desc) + desc2 =3D &list_next_entry(edesc, node)->desc; =20 unmap_single_talitos_ptr(dev, &desc->ptr[5], DMA_FROM_DEVICE); if (desc->next_desc && @@ -1754,10 +1812,18 @@ static void common_nonsnoop_hash_unmap(struct devic= e *dev, if (edesc->dma_len) dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len, DMA_BIDIRECTIONAL); +} =20 - if (desc->next_desc) - dma_unmap_single(dev, be32_to_cpu(desc->next_desc), - TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); +static void ahash_free_desc_list_from(struct ahash_request *areq, + struct talitos_edesc *edesc) +{ + struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); + struct talitos_edesc *tmp; + + list_for_each_entry_safe_from(edesc, tmp, &req_ctx->desc_list, node) { + list_del(&edesc->node); + kfree(edesc); + } } =20 static void ahash_done(struct device *dev, @@ -1776,7 +1842,9 @@ static void ahash_done(struct device *dev, } common_nonsnoop_hash_unmap(dev, edesc, areq); =20 - kfree(edesc); + ahash_free_desc_list_from(areq, + list_first_entry(&req_ctx->desc_list, + struct talitos_edesc, node)); =20 if (err) { ahash_request_complete(areq, err); @@ -1892,14 +1960,22 @@ static int common_nonsnoop_hash(struct talitos_edes= c *edesc, talitos_handle_buggy_hash(ctx, edesc, &desc->ptr[3]); =20 if (is_sec1 && req_ctx->nbuf && length) { - struct talitos_desc *desc2 =3D (struct talitos_desc *) - (edesc->buf + edesc->dma_len); - dma_addr_t next_desc; + struct talitos_edesc *edesc2; + struct talitos_desc *desc2; + + edesc2 =3D kzalloc(sizeof(*edesc2), + areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? + GFP_KERNEL : + GFP_ATOMIC); + if (!edesc2) + return -ENOMEM; + + list_add_tail(&edesc2->node, &req_ctx->desc_list); + + desc2 =3D &edesc2->desc; =20 - memset(desc2, 0, sizeof(*desc2)); desc2->hdr =3D desc->hdr; desc2->hdr &=3D ~DESC_HDR_MODE0_MDEU_INIT; - desc2->hdr1 =3D desc2->hdr; desc->hdr &=3D ~DESC_HDR_MODE0_MDEU_PAD; desc->hdr |=3D DESC_HDR_MODE0_MDEU_CONT; desc->hdr &=3D ~DESC_HDR_DONE_NOTIFY; @@ -1923,10 +1999,6 @@ static int common_nonsnoop_hash(struct talitos_edesc= *edesc, req_ctx->hw_context_size, req_ctx->hw_context, DMA_FROM_DEVICE); - - next_desc =3D dma_map_single(dev, &desc2->hdr1, TALITOS_DESC_SIZE, - DMA_BIDIRECTIONAL); - desc->next_desc =3D cpu_to_be32(next_desc); } =20 if (sync_needed) @@ -2048,6 +2120,9 @@ static int ahash_process_req_one(struct ahash_request= *areq, unsigned int nbytes if (IS_ERR(edesc)) return PTR_ERR(edesc); =20 + INIT_LIST_HEAD(&req_ctx->desc_list); + list_add_tail(&edesc->node, &req_ctx->desc_list); + edesc->desc.hdr =3D ctx->desc_hdr_template; =20 /* On last one, request SEC to pad; otherwise continue */ diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h index 1a93ee355929..ac75c2ddecb9 100644 --- a/drivers/crypto/talitos.h +++ b/drivers/crypto/talitos.h @@ -49,6 +49,7 @@ struct talitos_desc { * @iv_dma: dma address of iv for checking continuity and link table * @dma_len: length of dma mapped link_tbl space * @dma_link_tbl: bus physical address of link_tbl/buf + * @node: node for descriptor chain (SEC1) * @desc: h/w descriptor * @link_tbl: input and output h/w link tables (if {src,dst}_nents > 1) (S= EC2) * @buf: input and output buffeur (if {src,dst}_nents > 1) (SEC1) @@ -63,6 +64,7 @@ struct talitos_edesc { dma_addr_t iv_dma; int dma_len; dma_addr_t dma_link_tbl; + struct list_head node; struct talitos_desc desc; union { DECLARE_FLEX_ARRAY(struct talitos_ptr, link_tbl); @@ -72,12 +74,14 @@ struct talitos_edesc { =20 /** * talitos_request - descriptor submission request + * @desc_chain: descriptor chain list (SEC1) * @desc: descriptor pointer (kernel virtual) * @dma_desc: descriptor's physical bus address * @callback: whom to call when descriptor processing is done * @context: caller context (optional) */ struct talitos_request { + struct list_head *desc_chain; struct talitos_desc *desc; dma_addr_t dma_desc; void (*callback) (struct device *dev, struct talitos_desc *desc, --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073184A2E35; Tue, 5 May 2026 17:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003637; cv=none; b=U6UQlHhqwNticpv+q9UQB539Krpjlj9jHXGPUWxpBwebScIQ06G56cULsKV61Z6mrHzi6m4mbTPv+yJCQS1roXhu7ZaWlBh347nsLUFC9d8ZQBO52kV/1aRH4+5wQU33ztJ0bgBj7spWs7x3wutiBSfu2/mOvtAWRKhBxalGygs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003637; c=relaxed/simple; bh=NISdsgI9JatB76MR09v/Eb2pVygURjKaC3Ap2XbahlI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XzSBJXcEY5haO53uF8QLGLXLoeMjaQUYjXP5/br2acGNQScb486NmBBIORq8h5L4MRz4/G1XG7/+qfGOzC4Etr0XkC+6xe5qrlDaH/CkhDnIoMuWsWaGvBqc/nj/MLIXwZOw3u6Ahv1LIDgto/hugXT+fLa7Jl+EqFlpUqpSCc8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=E/RnGFnB; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="E/RnGFnB" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 93726C5CD45; Tue, 5 May 2026 17:54:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A92736053C; Tue, 5 May 2026 17:53:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A8FEB11AD03AB; Tue, 5 May 2026 19:53:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003632; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=MEZqsuDQbbQ+QfwiLanmP4l2UhzdbO4iCh1W8/Tkplk=; b=E/RnGFnBZLpT+QccyXYtjr49gYXW3a+EeqNzNC5JQSgrbKCmmiGGXMQkB7J0Bajylo8vEw Zk9ZGpBPMBIwJ6dToOKwTpt1McxfsoBQfOwQzc07PAmfeoeWvDr/nqM3KMKF8iHVOJoW1e yS9ca2sJrlu2NX1fJhiZJfSm813Ht3VFieJfOXjrrDxt4WZH+xl01GL/hp6xX87n4yaenk 2N7qGUE43hN0R1riDVX4xkdXxuMunn6LbKncBJ4jHHgcLfYCaYUrRcFjteNp/wnRmF1ps1 r0KwwQv4A5vhk9zGKEOifjQsQCN+3m+Qi4gsP3ZD6pbaaA/2+vESDUZLqzH2Dg== From: Paul Louvel Date: Tue, 05 May 2026 19:53:04 +0200 Subject: [PATCH v2 03/12] crypto: talitos - move dma unmapping code in flush_channel() into a standalone dma_unmap_request() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-3-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=2441; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=NISdsgI9JatB76MR09v/Eb2pVygURjKaC3Ap2XbahlI=; b=gWTReQzsiTHShjmnIc/8JG4TZyFn0Ry0yzeg4yA0e9AAd30XDQJWGab9hPxaPUT83+ASCuRyJ JRx2+evlQb7CLVBVKj9PY38Jh3Hv7pfN9vQ+qhwtbRZGLKBXfiuVDr4 X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 Previously added code to flush_channel() in order to unmap an entire descriptor. Move that code into a standalone function to improve readability. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index d68d307c54f7..e26689bf7c9d 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -380,6 +380,29 @@ static __be32 get_request_hdr(struct device *dev, stru= ct talitos_request *reques return desc->hdr1; } =20 +static void dma_unmap_request(struct device *dev, + struct talitos_request *request, bool is_sec1) +{ + struct talitos_edesc *edesc; + + if (is_sec1) { + dma_unmap_single(dev, request->dma_desc, TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); + + list_for_each_entry(edesc, request->desc_chain, node) { + if (!edesc->desc.next_desc) + break; + + dma_unmap_single(dev, + be32_to_cpu(edesc->desc.next_desc), + TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); + } + } else { + dma_unmap_single(dev, request->dma_desc, TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); + } +} + /* * process what was done, notify callback of error if not */ @@ -387,7 +410,6 @@ static void flush_channel(struct device *dev, int ch, i= nt error, int reset_ch) { struct talitos_private *priv =3D dev_get_drvdata(dev); struct talitos_request *request, saved_req; - struct talitos_edesc *edesc; unsigned long flags; int tail, status; bool is_sec1 =3D has_ftr_sec1(priv); @@ -412,23 +434,7 @@ static void flush_channel(struct device *dev, int ch, = int error, int reset_ch) else status =3D error; =20 - if (is_sec1) { - dma_unmap_single(dev, request->dma_desc, - TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); - - list_for_each_entry(edesc, request->desc_chain, node) { - if (!edesc->desc.next_desc) - break; - - dma_unmap_single( - dev, be32_to_cpu(edesc->desc.next_desc), - TALITOS_DESC_SIZE, DMA_BIDIRECTIONAL); - } - } else { - dma_unmap_single(dev, request->dma_desc, - TALITOS_DESC_SIZE, - DMA_BIDIRECTIONAL); - } + dma_unmap_request(dev, request, is_sec1); =20 /* copy entries so we can call callback outside lock */ saved_req.desc =3D request->desc; --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0BE148C8C5; Tue, 5 May 2026 17:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003639; cv=none; b=jyWt9vlaqJgP/CyoUdWYEmQOQkkTQ116eF8eY2LkDRQhk/VRBlRvDUb4HV5kb/x5PdKvb6nt4KVdjuc2R/2WKt+SOA8WuG4HDehFvHiAJH2LBWFc9B1Hrf/LCexNcMsqy6Kq1thtmKsWwLiw/FiwkzCKJKsZCY4WxEo2nzIvZek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003639; c=relaxed/simple; bh=2HprfiJ0pisWR//NJMpSah5IqgwIGz1YNJLlOWkvG9M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jyQ/u6tv52rNOwqKgbsEhPnmFTyawNJisJyQJtsDnFgRDiHa61b7Z6uRidsWB1VJg8JtIm6MA1D1mBJjFxTcNadwQl+2r/s4SL0IVGsWVhgA7Dg5flMlVfN4UXTTyBdnTwuDdH2So2JJsZ4hbN0IwTRU3brbJHLv9C7kmCKx3xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=j7mcfpQN; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="j7mcfpQN" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 41366C5CD52; Tue, 5 May 2026 17:54:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 573F26053C; Tue, 5 May 2026 17:53:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 22BE811AD040F; Tue, 5 May 2026 19:53:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003634; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=FoC8tR9VPR8Ki1XrtOVKBVTKCTXbNjL0c7/3kI3kmHU=; b=j7mcfpQN7jZHrLFx98oEP4uvPoHlaVcyTxVKro8fIBlnD2yWSjHoykGJ9w1K4qaI2BOCbA 6Xa5QJXvMsnC8NeIyzwmy2+E6DkRy/JCJ84odm6KzFtjfgcYzveKIc7CDakyJe+MSYcw0G 6bJ5yFArVtJH+ewYR12n06XyjalO5oH61QR87cn0zCrvhV6YIskUDzb5g5OC/4e1ZZ86AY d9tiegsuJpTdS1WvRd0VhY0XhMiSlZslIOpNeRTmT/AwQTr4LYdvw+9mPllXJ2jxC18zdF /FV4dzIDNyTmVwhHu4QaCp0U+WXzNiWtw/i8furnU0hJAYOuC/RdzPtG9m8Hqw== From: Paul Louvel Date: Tue, 05 May 2026 19:53:05 +0200 Subject: [PATCH v2 04/12] crypto: talitos - move dma mapping code in talitos_submit() into a standalone dma_map_request() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-4-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=3486; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=2HprfiJ0pisWR//NJMpSah5IqgwIGz1YNJLlOWkvG9M=; b=29CIUBYQOQVX8MDt1numu7iV8eo+NfAQ71iNLQU0uuq+jrpS57+wumhSmgKX7I8LKvi/BHqeA 4WXDaxIQ+RPBzvvmz2e9iIW72LJwumd9oYJRtaqoUedDyN6b4NKMoS9 X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 Previously added code to talitos_submit() in order to map an entire descriptor chain. Move that code into a standalone function to improve readability. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 79 ++++++++++++++++++++++++++------------------= ---- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index e26689bf7c9d..3b1d8e34e86e 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -256,6 +256,48 @@ static int init_device(struct device *dev) return 0; } =20 +static void dma_map_request(struct device *dev, struct talitos_request *re= quest, + struct talitos_desc *desc, bool is_sec1) +{ + struct talitos_edesc *edesc =3D + container_of(desc, struct talitos_edesc, desc); + dma_addr_t dma_desc, prev_dma_desc; + struct talitos_edesc *prev_edesc =3D NULL; + + if (is_sec1) { + request->desc_chain =3D edesc->node.prev; + + list_for_each_entry(edesc, request->desc_chain, node) { + edesc->desc.hdr1 =3D edesc->desc.hdr; + + dma_desc =3D dma_map_single(dev, &edesc->desc.hdr1, + TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); + + if (!prev_edesc) { + request->dma_desc =3D dma_desc; + goto next; + } + + /* Chain in any previous descriptors. */ + + prev_edesc->desc.next_desc =3D cpu_to_be32(dma_desc); + + dma_sync_single_for_device(dev, prev_dma_desc, + TALITOS_DESC_SIZE, + DMA_TO_DEVICE); + +next: + prev_edesc =3D edesc; + prev_dma_desc =3D dma_desc; + } + } else { + request->dma_desc =3D dma_map_single(dev, desc, TALITOS_DESC_SIZE, + DMA_BIDIRECTIONAL); + request->desc_chain =3D NULL; + } +} + /** * talitos_submit - submits a descriptor to the device for processing * @dev: the SEC device to be used @@ -274,10 +316,7 @@ static int talitos_submit(struct device *dev, int ch, = struct talitos_desc *desc, void *context, int error), void *context) { - struct talitos_edesc *edesc =3D container_of(desc, struct talitos_edesc, = desc); struct talitos_private *priv =3D dev_get_drvdata(dev); - dma_addr_t dma_desc, prev_dma_desc; - struct talitos_edesc *prev_edesc =3D NULL; struct talitos_request *request; unsigned long flags; int head; @@ -295,39 +334,7 @@ static int talitos_submit(struct device *dev, int ch, = struct talitos_desc *desc, request =3D &priv->chan[ch].fifo[head]; =20 /* map descriptor and save caller data */ - if (is_sec1) { - request->desc_chain =3D edesc->node.prev; - - list_for_each_entry(edesc, request->desc_chain, node) { - edesc->desc.hdr1 =3D edesc->desc.hdr; - - dma_desc =3D dma_map_single(dev, &edesc->desc.hdr1, - TALITOS_DESC_SIZE, - DMA_BIDIRECTIONAL); - - if (!prev_edesc) { - request->dma_desc =3D dma_desc; - goto next; - } - - /* Chain in any previous descriptors. */ - - prev_edesc->desc.next_desc =3D cpu_to_be32(dma_desc); - - dma_sync_single_for_device(dev, prev_dma_desc, - TALITOS_DESC_SIZE, - DMA_TO_DEVICE); - -next: - prev_edesc =3D edesc; - prev_dma_desc =3D dma_desc; - } - } else { - request->dma_desc =3D dma_map_single(dev, desc, - TALITOS_DESC_SIZE, - DMA_BIDIRECTIONAL); - request->desc_chain =3D NULL; - } + dma_map_request(dev, request, desc, is_sec1); request->callback =3D callback; request->context =3D context; =20 --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4EF54A33F7; Tue, 5 May 2026 17:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003639; cv=none; b=rAJfiXA2zc6D3e8EYQsn4tOCW4EwrHldRfyI+icMNqiiwbBMlatZcge7OJ+O3MmAic5aN93VhswXPv8k0S+ipz3qKJ2PAxaxp38E8+femm0Q8AB2935GXBEcyMMdvLu87JqpdklwLNQMz2+vRaMVlQwakE1wFC6QsSv0r2cMnM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003639; c=relaxed/simple; bh=OU8s8Mn9Mh8SMIUN160tl0JUdDlsU4lzL+J/GKX/XQo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GuJrgt6WvKAdpbZIJ32F+VpOjlruwaH07wIY8j5mKfWn8Qr4f+o7sbYqxfb2xC25jyWEgRLER0lB8hO0RE4+qFecYyMg+oeZNRpqn1rvUvyOaraqX9WAvH0CoGAuboJkRp+CC1rQAtQ2BWwqFiwXybkInLpLCsYxYc/GL1DsIYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=j9DZDVYY; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="j9DZDVYY" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 914F1C5CD54; Tue, 5 May 2026 17:54:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A73766053C; Tue, 5 May 2026 17:53:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AFDD711AD0410; Tue, 5 May 2026 19:53:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003635; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=VsN8MfEuE8p6zLNmSoD+xNBvkyYo5ArGJBL6xUhd3gc=; b=j9DZDVYYrYeDsIDszINU6Glk5Brmi3dFnx2YGJwfwCXmM1V0PjAs+307i4nnTcRSGcrvTk bO59AJNZKhYg9pLvuC/EncE5WzwsTF56BU7myRWCm788yPxMcCPkdiyLqWl9+EazE0mx71 pApHw7azS/L34EHgVyOx8T/pDb2hiBgh9Ucux1sWlp6I588X27MslV5dpjqV2FnaVqup40 gyzLY+Q44v1uEJyMKA4PQTfsYEprak6PTr/wgoawS5Ajg484p7Fuei2UKsiTUZpFvFEPJS JoMWwUR+2s+03FcNJiXXv5Ji8WEcVlSGolN5HV9AzPBMhMmX3rN4iA2fVVCz5w== From: Paul Louvel Date: Tue, 05 May 2026 19:53:06 +0200 Subject: [PATCH v2 05/12] crypto: talitos - move code in current_desc_hdr() into a standalone function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-5-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=2129; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=OU8s8Mn9Mh8SMIUN160tl0JUdDlsU4lzL+J/GKX/XQo=; b=+yhdobtZECj4yuE/xllOGmPDGJvJQ5DZXqLISLOdWiDepm7vnxw0V9sGyptAI2eDQe/WJpxIp OeQxN81qCtTCKiuCpXTN9hNIrRcI7Lhxii1AbF9NIsFSj7pifIWJ2rE X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 Previously added code in current_desc_hdr() in order to add support for searching an offending descriptor inside a descriptor chain. Move that code into a standalone function to improve readability. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 3b1d8e34e86e..376e21e06056 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -530,6 +530,23 @@ DEF_TALITOS2_DONE(ch0, TALITOS2_ISR_CH_0_DONE) DEF_TALITOS2_DONE(ch0_2, TALITOS2_ISR_CH_0_2_DONE) DEF_TALITOS2_DONE(ch1_3, TALITOS2_ISR_CH_1_3_DONE) =20 +static __be32 search_desc_hdr_in_request(struct talitos_request *request, + dma_addr_t cur_desc, bool is_sec1) +{ + struct talitos_edesc *edesc; + + if (request->dma_desc =3D=3D cur_desc) { + return request->desc->hdr; + } else if (is_sec1) { + list_for_each_entry(edesc, request->desc_chain, node) { + if (edesc->desc.next_desc =3D=3D cpu_to_be32(cur_desc)) + return list_next_entry(edesc, node)->desc.hdr; + } + } + + return 0; +} + /* * locate current (offending) descriptor */ @@ -538,7 +555,6 @@ static __be32 current_desc_hdr(struct device *dev, int = ch) struct talitos_private *priv =3D dev_get_drvdata(dev); bool is_sec1 =3D has_ftr_sec1(priv); struct talitos_request *request; - struct talitos_edesc *edesc; int tail, iter; dma_addr_t cur_desc; __be32 hdr =3D 0; @@ -556,17 +572,7 @@ static __be32 current_desc_hdr(struct device *dev, int= ch) do { request =3D &priv->chan[ch].fifo[iter]; =20 - if (request->dma_desc =3D=3D cur_desc) { - hdr =3D request->desc->hdr; - } else if (is_sec1) { - list_for_each_entry(edesc, request->desc_chain, node) { - if (edesc->desc.next_desc =3D=3D - cpu_to_be32(cur_desc)) - hdr =3D list_next_entry(edesc, node) - ->desc.hdr; - } - } - + hdr =3D search_desc_hdr_in_request(request, cur_desc, is_sec1); if (hdr) break; =20 --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B33F24A33F5; Tue, 5 May 2026 17:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003643; cv=none; b=MgFlzrGhfl5SG7CNkqYUYgNIX8gDMG1mtgGS+ivE7pTB4G1NJylGCrN1aaHEMbIyOxK62QMLsGh2Q8uc4qOwhR7oxswZm8+YWwXwCYeozBnukVUAVf0fkgMYzIYzOWvTlrfe/TJZaM3PTI0SqRRtF9CJID6Ay/53tr//jSMYRX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003643; c=relaxed/simple; bh=lUwaoZyOhwWcNlKyO9UaTsMvhhRZsx9trVQWggLqEug=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tR598EnYSEwH/kRlr9tbFfLUAtihrL0YS/wV2pa+F5RF6pkG63Nh2eSxAu6JLvBfDrBxct2t9mricjP1fga7XJbey12p1f4AmQQYlh+CREzRwY/zh0f3lcvl2oXgcvOZHCrgZfNGwJ4f8EbwRUZxaUGxO/gbuANFWCdENfkxxvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=hzCRQ2KA; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="hzCRQ2KA" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 48C424E42BD8; Tue, 5 May 2026 17:53:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1E7996053C; Tue, 5 May 2026 17:53:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 25A1D11AD03AB; Tue, 5 May 2026 19:53:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003637; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=m4tTkWuF5cQhPVTVJOXFS3q1CI0YIsrvC+jPdRl7Wts=; b=hzCRQ2KAfEjfeIi2VJVUYcf+iNot3Ubxzfzg5n2kGwnAztoopxqS1iMQYH9kJFMCHqyAwS dHbgXu3mUNpH3NxIL3VyEjOW6PmT+Fq17VBmQ9V+bBg5Aib8UGZgBvYjY8yeKjYlYjOiUH aSM7oFZ3ambM1+gQhF704FgOJQgIswQVSJue4xFQuUzFisMF2ejKc6zQtMez9LbEASXReh RG5ZlSJmRSjCldYdaNoSlaIkPHjtDyRPyNGLE0ll/HBQhO5D5LXXLvDdNq5x6X2LnEFHxT JlxIt/+vPwrS91H+F4A6dzBS4tTQ0xEiwfluAoNPTe8/Xu9TNd8hDc57/HM20g== From: Paul Louvel Date: Tue, 05 May 2026 19:53:07 +0200 Subject: [PATCH v2 06/12] crypto: talitos/hash - prepare SEC1 descriptor chaining, remove additional descriptor Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-6-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=6769; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=lUwaoZyOhwWcNlKyO9UaTsMvhhRZsx9trVQWggLqEug=; b=XUN7C0yLVmtsKCAh/BXdLEKFtp/ftbzNTHRP4YfNKibFXWtSihDQaf7fDM1EO8wtd1+d4UUpN y+72DPXGSSNBaGKPAmipN/8GvQcuFLuuxuXemSWtclfS78AdPqExfV7 X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 Currently, when SEC1 has buffered data (nbuf !=3D 0), the ahash code creates an additional descriptor on the fly inside common_nonsnoop_hash() to handle the remainder of the data. This approach is incompatible with the arbitrary-length descriptor chaining that follows. Remove the "additional descriptor" logic from common_nonsnoop_hash() and common_nonsnoop_hash_unmap(). Also remove the nbytes adjustment for SEC1 in ahash_edesc_alloc() that subtracted nbuf. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 100 +++----------------------------------------= ---- 1 file changed, 6 insertions(+), 94 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 376e21e06056..1f47424b93c7 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1800,15 +1800,9 @@ static void common_nonsnoop_hash_unmap(struct device= *dev, struct talitos_private *priv =3D dev_get_drvdata(dev); bool is_sec1 =3D has_ftr_sec1(priv); struct talitos_desc *desc =3D &edesc->desc; - struct talitos_desc *desc2; - - if (desc->next_desc) - desc2 =3D &list_next_entry(edesc, node)->desc; =20 unmap_single_talitos_ptr(dev, &desc->ptr[5], DMA_FROM_DEVICE); - if (desc->next_desc && - desc->ptr[5].ptr !=3D desc2->ptr[5].ptr) - unmap_single_talitos_ptr(dev, &desc2->ptr[5], DMA_FROM_DEVICE); + if (req_ctx->last_desc) memcpy(areq->result, req_ctx->hw_context, crypto_ahash_digestsize(tfm)); @@ -1820,13 +1814,6 @@ static void common_nonsnoop_hash_unmap(struct device= *dev, if (from_talitos_ptr_len(&desc->ptr[1], is_sec1)) unmap_single_talitos_ptr(dev, &desc->ptr[1], DMA_TO_DEVICE); - else if (desc->next_desc) - unmap_single_talitos_ptr(dev, &desc2->ptr[1], - DMA_TO_DEVICE); - - if (is_sec1 && req_ctx->nbuf) - unmap_single_talitos_ptr(dev, &desc->ptr[3], - DMA_TO_DEVICE); =20 if (edesc->dma_len) dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len, @@ -1937,9 +1924,6 @@ static int common_nonsnoop_hash(struct talitos_edesc = *edesc, to_talitos_ptr(&desc->ptr[2], ctx->dma_key, ctx->keylen, is_sec1); =20 - if (is_sec1 && req_ctx->nbuf) - length -=3D req_ctx->nbuf; - sg_count =3D edesc->src_nents ?: 1; if (is_sec1 && sg_count > 1) sg_copy_to_buffer(req_ctx->psrc, sg_count, edesc->buf, length); @@ -1949,16 +1933,10 @@ static int common_nonsnoop_hash(struct talitos_edes= c *edesc, /* * data in */ - if (is_sec1 && req_ctx->nbuf) { - map_single_talitos_ptr(dev, &desc->ptr[3], req_ctx->nbuf, - req_ctx->buf[req_ctx->buf_idx], - DMA_TO_DEVICE); - } else { - sg_count =3D talitos_sg_map(dev, req_ctx->psrc, length, edesc, - &desc->ptr[3], sg_count, 0, 0); - if (sg_count > 1) - sync_needed =3D true; - } + sg_count =3D talitos_sg_map(dev, req_ctx->psrc, length, edesc, + &desc->ptr[3], sg_count, 0, 0); + if (sg_count > 1) + sync_needed =3D true; =20 /* fifth DWORD empty */ =20 @@ -1978,48 +1956,6 @@ static int common_nonsnoop_hash(struct talitos_edesc= *edesc, if (is_sec1 && from_talitos_ptr_len(&desc->ptr[3], true) =3D=3D 0) talitos_handle_buggy_hash(ctx, edesc, &desc->ptr[3]); =20 - if (is_sec1 && req_ctx->nbuf && length) { - struct talitos_edesc *edesc2; - struct talitos_desc *desc2; - - edesc2 =3D kzalloc(sizeof(*edesc2), - areq->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? - GFP_KERNEL : - GFP_ATOMIC); - if (!edesc2) - return -ENOMEM; - - list_add_tail(&edesc2->node, &req_ctx->desc_list); - - desc2 =3D &edesc2->desc; - - desc2->hdr =3D desc->hdr; - desc2->hdr &=3D ~DESC_HDR_MODE0_MDEU_INIT; - desc->hdr &=3D ~DESC_HDR_MODE0_MDEU_PAD; - desc->hdr |=3D DESC_HDR_MODE0_MDEU_CONT; - desc->hdr &=3D ~DESC_HDR_DONE_NOTIFY; - - if (desc->ptr[1].ptr) - copy_talitos_ptr(&desc2->ptr[1], &desc->ptr[1], - is_sec1); - else - map_single_talitos_ptr_nosync(dev, &desc2->ptr[1], - req_ctx->hw_context_size, - req_ctx->hw_context, - DMA_TO_DEVICE); - copy_talitos_ptr(&desc2->ptr[2], &desc->ptr[2], is_sec1); - sg_count =3D talitos_sg_map(dev, req_ctx->psrc, length, edesc, - &desc2->ptr[3], sg_count, 0, 0); - if (sg_count > 1) - sync_needed =3D true; - copy_talitos_ptr(&desc2->ptr[5], &desc->ptr[5], is_sec1); - if (req_ctx->last_desc) - map_single_talitos_ptr_nosync(dev, &desc->ptr[5], - req_ctx->hw_context_size, - req_ctx->hw_context, - DMA_FROM_DEVICE); - } - if (sync_needed) dma_sync_single_for_device(dev, edesc->dma_link_tbl, edesc->dma_len, DMA_BIDIRECTIONAL); @@ -2038,11 +1974,6 @@ static struct talitos_edesc *ahash_edesc_alloc(struc= t ahash_request *areq, struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); struct talitos_ctx *ctx =3D crypto_ahash_ctx(tfm); struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); - struct talitos_private *priv =3D dev_get_drvdata(ctx->dev); - bool is_sec1 =3D has_ftr_sec1(priv); - - if (is_sec1) - nbytes -=3D req_ctx->nbuf; =20 return talitos_edesc_alloc(ctx->dev, req_ctx->psrc, NULL, NULL, 0, nbytes, 0, 0, 0, areq->base.flags, false); @@ -2061,8 +1992,6 @@ static int ahash_process_req_one(struct ahash_request= *areq, unsigned int nbytes unsigned int nsg; int nents; struct device *dev =3D ctx->dev; - struct talitos_private *priv =3D dev_get_drvdata(dev); - bool is_sec1 =3D has_ftr_sec1(priv); u8 *ctx_buf =3D req_ctx->buf[req_ctx->buf_idx]; =20 if (!req_ctx->last_desc && (nbytes + req_ctx->nbuf <=3D blocksize)) { @@ -2094,30 +2023,13 @@ static int ahash_process_req_one(struct ahash_reque= st *areq, unsigned int nbytes } =20 /* Chain in any previously buffered data */ - if (!is_sec1 && req_ctx->nbuf) { + if (req_ctx->nbuf) { nsg =3D (req_ctx->nbuf < nbytes_to_hash) ? 2 : 1; sg_init_table(req_ctx->bufsl, nsg); sg_set_buf(req_ctx->bufsl, ctx_buf, req_ctx->nbuf); if (nsg > 1) sg_chain(req_ctx->bufsl, 2, req_ctx->request_sl); req_ctx->psrc =3D req_ctx->bufsl; - } else if (is_sec1 && req_ctx->nbuf && req_ctx->nbuf < blocksize) { - int offset; - - if (nbytes_to_hash > blocksize) - offset =3D blocksize - req_ctx->nbuf; - else - offset =3D nbytes_to_hash - req_ctx->nbuf; - nents =3D sg_nents_for_len(req_ctx->request_sl, offset); - if (nents < 0) { - dev_err(dev, "Invalid number of src SG.\n"); - return nents; - } - sg_copy_to_buffer(req_ctx->request_sl, nents, - ctx_buf + req_ctx->nbuf, offset); - req_ctx->nbuf +=3D offset; - req_ctx->psrc =3D scatterwalk_ffwd(req_ctx->bufsl, req_ctx->request_sl, - offset); } else req_ctx->psrc =3D req_ctx->request_sl; =20 --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A0D24A340F for ; Tue, 5 May 2026 17:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003646; cv=none; b=VYPbd1phkaMB26c4Z3w/gPWQwtmZd+YS4WVvy6pMEYrcpGlehs5RmnYsIpTD89F17QdDk+0rmsgJ4NnthagSyh42cRJ6ycGEJbljhdOcp4cvYHYLSWPd/yfbQ4QvY8J9y+DNq8LcdCIruP3kvhlGehdzKKCMShqw4nTgEabuneo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003646; c=relaxed/simple; bh=OMYxZs9XE8R8nLGQ/7IlFs0u83h+dEbGq7xq0kUbR1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B63h1RxvnP1UHOlKFKxezeW6/MfF+ScA/BxOh+xvsJpyCP/j18dmZHgQLc7d+7ljwstRkDPyKvXO+nhuXAG7UqHM69IYdrT6aRT7XFiV8rj2gzRkyAiFQ7NEV1HUHIRUXqyxBKiMcj6Qgq9/xA5GeqpnPjlfJNbCr1nbz+Aqq4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=j76ZclqC; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="j76ZclqC" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id D6D6E1A3529; Tue, 5 May 2026 17:53:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AC1CB6053C; Tue, 5 May 2026 17:53:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8AF6811AD0412; Tue, 5 May 2026 19:53:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003638; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Ym+CkLUj3hotoqhZyVQhRlReEdrG4pvxZ0e/b3zAjT4=; b=j76ZclqCHnWp5MqM2Qk/xiGEENlhLETTRDcQM286hmk6EneuyykdCsn0ecJ7bLmtz/+3NA 5lCG0m2JvoA2ttRUaFlDvrfuPQ+0IihYkEgnA8ExhviOGxrCEcTXXKLbKzSv566czpHNtk 93bomXQNZOckPH1f9/FqV9Af1UxcY9Zh7WoHo2DssYAZbKttLvPiod/p/kYqdHotZ+eRga C5iE96BOAhgTP/N233QndR7ihH0M8y5K+B/xVZxWcjdM9hS/jXf+PxrOTIIPm7YyFfbwjr UNB6aPu7vUfryzBAEN4Tw0X0ZQToXPH6c1Zsh1pNQB32PjYDxK7O4NsV5HTFiQ== From: Paul Louvel Date: Tue, 05 May 2026 19:53:08 +0200 Subject: [PATCH v2 07/12] crypto: talitos/hash - use descriptor chaining for SEC1 instead of workqueue Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-7-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=13626; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=OMYxZs9XE8R8nLGQ/7IlFs0u83h+dEbGq7xq0kUbR1U=; b=+92BFWnEu90v3lJrA1TLFVuzhsMx+HRYTPhVMUuCnyS7wY0YlsgqWyuEpwnKCsS2P2Q35TxhJ EE8PMA4XCQpACRN2k+ql551nxUoRGWr7jQz6mKGMt+YRyWfe5bMTRvj X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 Rework the SEC1 ahash implementation to build a chain of hardware descriptors, replacing the previous approach of submitting one descriptor at a time via a workqueue, introduced by commit 655ef638a2bc ("crypto: talitos - fix SEC1 32k ahash request limitation"). Introduce ahash_process_req_prepare() which iterates over the request data, allocating enough descriptors to cover the entire ahash request. The new fields (bufsl, src, first, last) are added to talitos_edesc for this purpose. common_nonsnoop_hash() no longer calls talitos_submit(); it only maps and sets up the descriptor. Submission is now done by the caller after the chain is built. ahash_free_desc_list_from() takes over calling common_nonsnoop_hash_unmap() for each descriptor during cleanup. Compared to the workqueue based solution, request are slightly faster since there is no more scheduling latency induced by the workqueue, and only one interrupt is generated by the device at the end of a chain. Commit 655ef638a2bc ("crypto: talitos - fix SEC1 32k ahash request limitation") : $ /usr/libexec/libkcapi/sha256sum ./test_5M.bin 013c5609d63c... ./test_5M.bin real 0m 0.41s user 0m 0.01s sys 0m 0.07s Now : $ /usr/libexec/libkcapi/sha256sum ./test_5M.bin 013c5609d63c... ./test_5M.bin real 0m 0.37s user 0m 0.00s sys 0m 0.20s Tested on a system with an MPC885 SoC featuring the SEC1 Lite. The increase in sys time is due to the fact that commit 37b5e8897eb5 ("crypto: talitos - chain in buffered data for ahash on SEC1") can no longer be applied. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 168 ++++++++++++++++++++++++++++++-------------= ---- drivers/crypto/talitos.h | 10 +++ 2 files changed, 118 insertions(+), 60 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 1f47424b93c7..450f81fc0137 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1803,12 +1803,13 @@ static void common_nonsnoop_hash_unmap(struct devic= e *dev, =20 unmap_single_talitos_ptr(dev, &desc->ptr[5], DMA_FROM_DEVICE); =20 - if (req_ctx->last_desc) + if (edesc->last && req_ctx->last_request) memcpy(areq->result, req_ctx->hw_context, crypto_ahash_digestsize(tfm)); =20 - if (req_ctx->psrc) - talitos_sg_unmap(dev, edesc, req_ctx->psrc, NULL, 0, 0); + if (edesc->src) + talitos_sg_unmap(dev, edesc, edesc->src, NULL, 0, 0); + =20 /* When using hashctx-in, must unmap it. */ if (from_talitos_ptr_len(&desc->ptr[1], is_sec1)) @@ -1823,11 +1824,13 @@ static void common_nonsnoop_hash_unmap(struct devic= e *dev, static void ahash_free_desc_list_from(struct ahash_request *areq, struct talitos_edesc *edesc) { + struct talitos_ctx *ctx =3D crypto_ahash_ctx(crypto_ahash_reqtfm(areq)); struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); struct talitos_edesc *tmp; =20 list_for_each_entry_safe_from(edesc, tmp, &req_ctx->desc_list, node) { list_del(&edesc->node); + common_nonsnoop_hash_unmap(ctx->dev, edesc, areq); kfree(edesc); } } @@ -1837,8 +1840,6 @@ static void ahash_done(struct device *dev, int err) { struct ahash_request *areq =3D context; - struct talitos_edesc *edesc =3D - container_of(desc, struct talitos_edesc, desc); struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); =20 if (!req_ctx->last_desc && req_ctx->to_hash_later) { @@ -1846,16 +1847,14 @@ static void ahash_done(struct device *dev, req_ctx->buf_idx =3D (req_ctx->buf_idx + 1) & 1; req_ctx->nbuf =3D req_ctx->to_hash_later; } - common_nonsnoop_hash_unmap(dev, edesc, areq); =20 ahash_free_desc_list_from(areq, list_first_entry(&req_ctx->desc_list, struct talitos_edesc, node)); =20 - if (err) { - ahash_request_complete(areq, err); - return; - } + ahash_request_complete(areq, err); + + return; =20 req_ctx->remaining_ahash_request_bytes -=3D req_ctx->current_ahash_request_bytes; @@ -1889,18 +1888,15 @@ static void talitos_handle_buggy_hash(struct talito= s_ctx *ctx, (char *)padded_hash, DMA_TO_DEVICE); } =20 -static int common_nonsnoop_hash(struct talitos_edesc *edesc, - struct ahash_request *areq, unsigned int length, - void (*callback) (struct device *dev, - struct talitos_desc *desc, - void *context, int error)) +static void common_nonsnoop_hash(struct talitos_edesc *edesc, + struct ahash_request *areq, + unsigned int length) { struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); struct talitos_ctx *ctx =3D crypto_ahash_ctx(tfm); struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); struct device *dev =3D ctx->dev; struct talitos_desc *desc =3D &edesc->desc; - int ret; bool sync_needed =3D false; struct talitos_private *priv =3D dev_get_drvdata(dev); bool is_sec1 =3D has_ftr_sec1(priv); @@ -1909,7 +1905,7 @@ static int common_nonsnoop_hash(struct talitos_edesc = *edesc, /* first DWORD empty */ =20 /* hash context in */ - if (!req_ctx->first_desc || req_ctx->swinit) { + if (!edesc->first || !req_ctx->first_desc || req_ctx->swinit) { map_single_talitos_ptr_nosync(dev, &desc->ptr[1], req_ctx->hw_context_size, req_ctx->hw_context, @@ -1926,22 +1922,22 @@ static int common_nonsnoop_hash(struct talitos_edes= c *edesc, =20 sg_count =3D edesc->src_nents ?: 1; if (is_sec1 && sg_count > 1) - sg_copy_to_buffer(req_ctx->psrc, sg_count, edesc->buf, length); + sg_copy_to_buffer(edesc->src, sg_count, edesc->buf, length); else if (length) - sg_count =3D dma_map_sg(dev, req_ctx->psrc, sg_count, - DMA_TO_DEVICE); + sg_count =3D dma_map_sg(dev, edesc->src, sg_count, DMA_TO_DEVICE); + /* * data in */ - sg_count =3D talitos_sg_map(dev, req_ctx->psrc, length, edesc, - &desc->ptr[3], sg_count, 0, 0); + sg_count =3D talitos_sg_map(dev, edesc->src, length, edesc, &desc->ptr[3], + sg_count, 0, 0); if (sg_count > 1) sync_needed =3D true; =20 /* fifth DWORD empty */ =20 /* hash/HMAC out -or- hash context out */ - if (req_ctx->last_desc) + if (edesc->last && req_ctx->last_request) map_single_talitos_ptr(dev, &desc->ptr[5], crypto_ahash_digestsize(tfm), req_ctx->hw_context, DMA_FROM_DEVICE); @@ -1959,26 +1955,91 @@ static int common_nonsnoop_hash(struct talitos_edes= c *edesc, if (sync_needed) dma_sync_single_for_device(dev, edesc->dma_link_tbl, edesc->dma_len, DMA_BIDIRECTIONAL); - - ret =3D talitos_submit(dev, ctx->ch, desc, callback, areq); - if (ret !=3D -EINPROGRESS) { - common_nonsnoop_hash_unmap(dev, edesc, areq); - kfree(edesc); - } - return ret; } =20 static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq, + struct scatterlist *src, unsigned int nbytes) { struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); struct talitos_ctx *ctx =3D crypto_ahash_ctx(tfm); - struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); =20 - return talitos_edesc_alloc(ctx->dev, req_ctx->psrc, NULL, NULL, 0, + return talitos_edesc_alloc(ctx->dev, src, NULL, NULL, 0, nbytes, 0, 0, 0, areq->base.flags, false); } =20 +static int ahash_process_req_prepare(struct ahash_request *areq, + unsigned int nbytes, + unsigned int blocksize, bool is_sec1) +{ + struct talitos_ctx *ctx =3D crypto_ahash_ctx(crypto_ahash_reqtfm(areq)); + struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); + size_t desc_max =3D is_sec1 ? TALITOS1_MAX_DATA_LEN : SIZE_MAX; + struct talitos_edesc *edesc; + struct scatterlist tmp[2]; + size_t to_hash_this_desc; + struct scatterlist *src; + size_t offset =3D 0; + + INIT_LIST_HEAD(&req_ctx->desc_list); + do { + src =3D scatterwalk_ffwd(tmp, req_ctx->psrc, offset); + + to_hash_this_desc =3D + min(nbytes, ALIGN_DOWN(desc_max, blocksize)); + + /* Allocate extended descriptor */ + edesc =3D ahash_edesc_alloc(areq, src, to_hash_this_desc); + if (IS_ERR(edesc)) { + if (!list_empty(&req_ctx->desc_list)) { + edesc =3D list_first_entry(&req_ctx->desc_list, + struct talitos_edesc, + node); + ahash_free_desc_list_from(areq, edesc); + } + + return PTR_ERR(edesc); + } + + edesc->src =3D + scatterwalk_ffwd(edesc->bufsl, req_ctx->psrc, offset); + edesc->desc.hdr =3D ctx->desc_hdr_template; + edesc->first =3D offset =3D=3D 0; + edesc->last =3D nbytes - to_hash_this_desc =3D=3D 0; + + /* On last one, request SEC to pad; otherwise continue */ + if (req_ctx->last_request && edesc->last) + edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_PAD; + else + edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_CONT; + + /* request SEC to INIT hash. */ + if (req_ctx->first_desc && edesc->first && !req_ctx->swinit) + edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_INIT; + + /* + * When the tfm context has a keylen, it's an HMAC. + * A first or last (ie. not middle) descriptor must request HMAC. + */ + if (ctx->keylen && ((req_ctx->first_desc && edesc->first) || + (req_ctx->last_request && edesc->last))) + edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_HMAC; + + /* clear the DN bit */ + if (is_sec1 && !edesc->last) + edesc->desc.hdr &=3D ~DESC_HDR_DONE_NOTIFY; + + list_add_tail(&edesc->node, &req_ctx->desc_list); + + common_nonsnoop_hash(edesc, areq, to_hash_this_desc); + + offset +=3D to_hash_this_desc; + nbytes -=3D to_hash_this_desc; + } while (nbytes); + + return 0; +} + static int ahash_process_req_one(struct ahash_request *areq, unsigned int = nbytes) { struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); @@ -1987,14 +2048,16 @@ static int ahash_process_req_one(struct ahash_reque= st *areq, unsigned int nbytes struct talitos_edesc *edesc; unsigned int blocksize =3D crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); + bool is_sec1 =3D has_ftr_sec1(dev_get_drvdata(ctx->dev)); unsigned int nbytes_to_hash; unsigned int to_hash_later; unsigned int nsg; int nents; struct device *dev =3D ctx->dev; u8 *ctx_buf =3D req_ctx->buf[req_ctx->buf_idx]; + int ret; =20 - if (!req_ctx->last_desc && (nbytes + req_ctx->nbuf <=3D blocksize)) { + if (!req_ctx->last_request && (nbytes + req_ctx->nbuf <=3D blocksize)) { /* Buffer up to one whole block */ nents =3D sg_nents_for_len(req_ctx->request_sl, nbytes); if (nents < 0) { @@ -2011,7 +2074,7 @@ static int ahash_process_req_one(struct ahash_request= *areq, unsigned int nbytes nbytes_to_hash =3D nbytes + req_ctx->nbuf; to_hash_later =3D nbytes_to_hash & (blocksize - 1); =20 - if (req_ctx->last_desc) + if (req_ctx->last_request) to_hash_later =3D 0; else if (to_hash_later) /* There is a partial block. Hash the full block(s) now */ @@ -2046,33 +2109,19 @@ static int ahash_process_req_one(struct ahash_reque= st *areq, unsigned int nbytes } req_ctx->to_hash_later =3D to_hash_later; =20 - /* Allocate extended descriptor */ - edesc =3D ahash_edesc_alloc(req_ctx->areq, nbytes_to_hash); - if (IS_ERR(edesc)) - return PTR_ERR(edesc); - - INIT_LIST_HEAD(&req_ctx->desc_list); - list_add_tail(&edesc->node, &req_ctx->desc_list); - - edesc->desc.hdr =3D ctx->desc_hdr_template; - - /* On last one, request SEC to pad; otherwise continue */ - if (req_ctx->last_desc) - edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_PAD; - else - edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_CONT; + ret =3D ahash_process_req_prepare(areq, nbytes_to_hash, blocksize, + is_sec1); + if (ret) + return ret; =20 - /* request SEC to INIT hash. */ - if (req_ctx->first_desc && !req_ctx->swinit) - edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_INIT; + edesc =3D list_first_entry(&req_ctx->desc_list, struct talitos_edesc, + node); =20 - /* When the tfm context has a keylen, it's an HMAC. - * A first or last (ie. not middle) descriptor must request HMAC. - */ - if (ctx->keylen && (req_ctx->first_desc || req_ctx->last_desc)) - edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_HMAC; + ret =3D talitos_submit(dev, ctx->ch, &edesc->desc, ahash_done, areq); + if (ret !=3D -EINPROGRESS) + ahash_free_desc_list_from(areq, edesc); =20 - return common_nonsnoop_hash(edesc, req_ctx->areq, nbytes_to_hash, ahash_d= one); + return ret; } =20 static void sec1_ahash_process_remaining(struct work_struct *work) @@ -2124,8 +2173,7 @@ static int ahash_process_req(struct ahash_request *ar= eq, unsigned int nbytes) =20 req_ctx->current_ahash_request_bytes =3D nbytes; =20 - return ahash_process_req_one(req_ctx->areq, - req_ctx->current_ahash_request_bytes); + return ahash_process_req_one(req_ctx->areq, areq->nbytes); } =20 static int ahash_init(struct ahash_request *areq) diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h index ac75c2ddecb9..efba34458b12 100644 --- a/drivers/crypto/talitos.h +++ b/drivers/crypto/talitos.h @@ -44,6 +44,11 @@ struct talitos_desc { =20 /* * talitos_edesc - s/w-extended descriptor + * @bufsl: scatterlist buffer + * @src: pointer to input scatterlist + * @first: first descriptor of a chain + * @last: last descriptor of a chain + * * @src_nents: number of segments in input scatterlist * @dst_nents: number of segments in output scatterlist * @iv_dma: dma address of iv for checking continuity and link table @@ -59,6 +64,11 @@ struct talitos_desc { * of link_tbl data */ struct talitos_edesc { + struct scatterlist bufsl[2]; + struct scatterlist *src; + int first; + int last; + int src_nents; int dst_nents; dma_addr_t iv_dma; --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAC654B8DCA for ; Tue, 5 May 2026 17:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003646; cv=none; b=YtNlj049pBFTXYBCHsku1M6C0afhMx06xYtZMSuTqeWZAc/Z2PnrTqMNwWHqRhwg7zY0lPGQMmr3o3WEPOkjbkV6XwC0nu8rrqZ1fw6/mouRm08HTTVFlq0RU188T4di1NawFNSXVeBfB6w63AYhMfY9w1ed062A+PlBTsa2Gco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003646; c=relaxed/simple; bh=QQNglrBCqsvBA+JE0KFjWjQktiFPfjkJoe1FpsUhSEU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WmQqaOqZcc5DLw5QHLlxkc7U5++QL8WL5myK6iYTDu7AzRzdH9AsB0qm5GKpkOFQ7F8OmH9tEH36Z0JXBrRSSpIeDjsKWRzDKYQaLW5xfU4+o3Rq26GfrYJTDz2Cg31kXp940EPllqGdNH2gXPnBNIZ1okH3J5s+FcFhsRWTc5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=yvabvQiu; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="yvabvQiu" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id BD2EE4E42BD9; Tue, 5 May 2026 17:54:01 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 92ABE6053C; Tue, 5 May 2026 17:54:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1450A11AD0413; Tue, 5 May 2026 19:53:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003640; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=J7zPqnMSs9mlwkc+wn4TtW5erdxQn/42Qf6QhWQcUg0=; b=yvabvQiuNu6CoKUVw0Jnu9+JcaBnOqGy1oNnNAIjBCTJf8REZzTX0WHZkWcyx00LX8l9im b9yXGQOz7aH6+pO9LKNJYkdj8na+D0gxSSYs6HVST9bm8cM0UGI4Doox09sbKxAcH+lPFw D0kkFiEWtG4KhbLtv1dVMZXyGcCg7neL/FJeVakLl2HMix1UGAWCj1vCs2fQkxyhSblbOV k1iWWM6jp1WP4c3JT7UdKZJ9psunlGzbRVFEg/kCFzcfoDMoa6TQ+v0XKkbjQtJ6NV5gwV bdNqhlOdoVa/aJWTE7JbD6u3o4WaZQixDYmKVYa9t+txQ/Ncf9jLwvc0xU/fsA== From: Paul Louvel Date: Tue, 05 May 2026 19:53:09 +0200 Subject: [PATCH v2 08/12] crypto: talitos/hash - drop workqueue mechanism for SEC1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-8-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=5520; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=QQNglrBCqsvBA+JE0KFjWjQktiFPfjkJoe1FpsUhSEU=; b=frMl8E9eE6soBMc/FK+4aWWzGpJRa5DOTTMZnfhbSj6hZtfbN0W7dHiG7fJkJngGWGpL4cw7z PfASXBk3GkMAei4YEhxJEIH0YESCV297oPBuSGyAcYGIlWq1P5vUh0p X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 Now that SEC1 hash uses hardware descriptor chaining instead of a workqueue to process requests exceeding TALITOS1_MAX_DATA_LEN, the workqueue code is no longer needed. Remove sec1_ahash_process_remaining(), the related fields from talitos_ahash_req_ctx (request_bufsl, areq, request_sl, remaining_ahash_request_bytes, current_ahash_request_bytes, sec1_ahash_process_remaining), the dead code in ahash_done(), and simplify ahash_process_req() to call ahash_process_req_one() directly with the original areq->src and areq->nbytes. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 81 +++++---------------------------------------= ---- 1 file changed, 7 insertions(+), 74 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 450f81fc0137..43c07d86f84c 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -962,13 +962,6 @@ struct talitos_ahash_req_ctx { struct scatterlist bufsl[2]; struct scatterlist *psrc; struct list_head desc_list; - - struct scatterlist request_bufsl[2]; - struct ahash_request *areq; - struct scatterlist *request_sl; - unsigned int remaining_ahash_request_bytes; - unsigned int current_ahash_request_bytes; - struct work_struct sec1_ahash_process_remaining; }; =20 struct talitos_export_state { @@ -1853,18 +1846,6 @@ static void ahash_done(struct device *dev, struct talitos_edesc, node)); =20 ahash_request_complete(areq, err); - - return; - - req_ctx->remaining_ahash_request_bytes -=3D - req_ctx->current_ahash_request_bytes; - - if (!req_ctx->remaining_ahash_request_bytes) { - ahash_request_complete(areq, 0); - return; - } - - schedule_work(&req_ctx->sec1_ahash_process_remaining); } =20 /* @@ -2059,12 +2040,12 @@ static int ahash_process_req_one(struct ahash_reque= st *areq, unsigned int nbytes =20 if (!req_ctx->last_request && (nbytes + req_ctx->nbuf <=3D blocksize)) { /* Buffer up to one whole block */ - nents =3D sg_nents_for_len(req_ctx->request_sl, nbytes); + nents =3D sg_nents_for_len(areq->src, nbytes); if (nents < 0) { dev_err(dev, "Invalid number of src SG.\n"); return nents; } - sg_copy_to_buffer(req_ctx->request_sl, nents, + sg_copy_to_buffer(areq->src, nents, ctx_buf + req_ctx->nbuf, nbytes); req_ctx->nbuf +=3D nbytes; return 0; @@ -2091,18 +2072,18 @@ static int ahash_process_req_one(struct ahash_reque= st *areq, unsigned int nbytes sg_init_table(req_ctx->bufsl, nsg); sg_set_buf(req_ctx->bufsl, ctx_buf, req_ctx->nbuf); if (nsg > 1) - sg_chain(req_ctx->bufsl, 2, req_ctx->request_sl); + sg_chain(req_ctx->bufsl, 2, areq->src); req_ctx->psrc =3D req_ctx->bufsl; } else - req_ctx->psrc =3D req_ctx->request_sl; + req_ctx->psrc =3D areq->src; =20 if (to_hash_later) { - nents =3D sg_nents_for_len(req_ctx->request_sl, nbytes); + nents =3D sg_nents_for_len(areq->src, nbytes); if (nents < 0) { dev_err(dev, "Invalid number of src SG.\n"); return nents; } - sg_pcopy_to_buffer(req_ctx->request_sl, nents, + sg_pcopy_to_buffer(areq->src, nents, req_ctx->buf[(req_ctx->buf_idx + 1) & 1], to_hash_later, nbytes - to_hash_later); @@ -2124,56 +2105,9 @@ static int ahash_process_req_one(struct ahash_reques= t *areq, unsigned int nbytes return ret; } =20 -static void sec1_ahash_process_remaining(struct work_struct *work) -{ - struct talitos_ahash_req_ctx *req_ctx =3D - container_of(work, struct talitos_ahash_req_ctx, - sec1_ahash_process_remaining); - int err =3D 0; - - req_ctx->request_sl =3D scatterwalk_ffwd(req_ctx->request_bufsl, - req_ctx->request_sl, TALITOS1_MAX_DATA_LEN); - - if (req_ctx->remaining_ahash_request_bytes > TALITOS1_MAX_DATA_LEN) - req_ctx->current_ahash_request_bytes =3D TALITOS1_MAX_DATA_LEN; - else { - req_ctx->current_ahash_request_bytes =3D - req_ctx->remaining_ahash_request_bytes; - - if (req_ctx->last_request) - req_ctx->last_desc =3D 1; - } - - err =3D ahash_process_req_one(req_ctx->areq, - req_ctx->current_ahash_request_bytes); - - if (err !=3D -EINPROGRESS) - ahash_request_complete(req_ctx->areq, err); -} - static int ahash_process_req(struct ahash_request *areq, unsigned int nbyt= es) { - struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); - struct talitos_ctx *ctx =3D crypto_ahash_ctx(tfm); - struct device *dev =3D ctx->dev; - struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); - struct talitos_private *priv =3D dev_get_drvdata(dev); - bool is_sec1 =3D has_ftr_sec1(priv); - - req_ctx->areq =3D areq; - req_ctx->request_sl =3D areq->src; - req_ctx->remaining_ahash_request_bytes =3D nbytes; - - if (is_sec1) { - if (nbytes > TALITOS1_MAX_DATA_LEN) - nbytes =3D TALITOS1_MAX_DATA_LEN; - else if (req_ctx->last_request) - req_ctx->last_desc =3D 1; - } - - req_ctx->current_ahash_request_bytes =3D nbytes; - - return ahash_process_req_one(req_ctx->areq, areq->nbytes); + return ahash_process_req_one(areq, nbytes); } =20 static int ahash_init(struct ahash_request *areq) @@ -2196,7 +2130,6 @@ static int ahash_init(struct ahash_request *areq) req_ctx->hw_context_size =3D size; req_ctx->last_request =3D 0; req_ctx->last_desc =3D 0; - INIT_WORK(&req_ctx->sec1_ahash_process_remaining, sec1_ahash_process_rema= ining); =20 dma =3D dma_map_single(dev, req_ctx->hw_context, req_ctx->hw_context_size, DMA_TO_DEVICE); --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6A1D4ADD9D for ; Tue, 5 May 2026 17:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003647; cv=none; b=Kt+Daxs905OHI9oHQjUcxOdnn1itD0q9FRWQ5bDgrf3TyVNru96zP9O5oVJ49p6WCTsKsbzFezjKWNVck6k2ByAH3vyAifXdHO/vzEjFe6/Vo4vr4yTWMRqNJRCqC/Fr4TNLoH9pJ9rShzMcmK6g5nynF0GmSu/QkNTjCoTw41o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003647; c=relaxed/simple; bh=oL30Ms07i9TocHsSg6o/a5zVuK54dJ/ehi5tPzja7dg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NZa9hXtybZ1/aMVCdc2hD5Fw/mX0ebe46EJi4urzfYgig6ys6VFYEUmkcBPLyOpxps/1e1XHeSkZo6P4GAnstFXBP1FlmKHAb17BNqj+rmZ7ge+jIGzXhy+8z9L7ozYR8c7w2SogMK68QfpjyXXccEFiPnNzIHXZFD4nfoIfk34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=o1caQRcZ; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="o1caQRcZ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 120F61A352B; Tue, 5 May 2026 17:54:03 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D51016053C; Tue, 5 May 2026 17:54:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C5A6D11AD041B; Tue, 5 May 2026 19:54:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003642; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ynI54andb8JG6XMNDugqFX+BPJDMZ0WUSGpCceccGT4=; b=o1caQRcZVW9VBo972s+tc6N4FYf7zmg5vqMWOiIps+QOrjWGSWeqcUlyCsu0ydR33o0otW V3H5JrZX+27YAUEAGG6dR6PH8AvhOHUr1iLU5rH9KzWGUNeakvZg2Hl2WHWmnwxfr5cN4F dSe+dfyZb4g8mlHUMlqd+IL0EWOUvW6zpWsArJXBxPvVIYm9lRezVGSB0AMHDn0Q7LE0Qo xC3W/sg3K7fp6YVqCzZjjbBrxoQnx0PmDLep1SGpAqRyNwNYqht6fIaX+Kd2vqNQIlhBqO 37yWOHsoOgjE3RtdYK1+8j6xinANaF540VL+KqGAQyUtov/1jVW1nFZg0OhUbA== From: Paul Louvel Date: Tue, 05 May 2026 19:53:10 +0200 Subject: [PATCH v2 09/12] crypto: talitos/hash - rename first_desc/last_desc to first_request/last_request Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-9-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=4876; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=oL30Ms07i9TocHsSg6o/a5zVuK54dJ/ehi5tPzja7dg=; b=m90Y7YSt0b/0mgbXkpOjrFxWOVmzCDcPiNGZPuJGI+7quEMliz0EFTLMBEpLfjR7be3wjryzb je97FrTGNlnAh8JYgVnGOijNiBz8Hte3Nlz+aPggbSIy3KvE7DKcPwh X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 In talitos_ahash_req_ctx and talitos_export_state, the fields first_desc and last_desc describe request-level (not descriptor-level) state. Rename them to first_request and last_request for clarity. last_desc is also removed from talitos_ahash_req_ctx as it is no longer used. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 43c07d86f84c..4fad4e862405 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -954,8 +954,7 @@ struct talitos_ahash_req_ctx { u8 buf[2][HASH_MAX_BLOCK_SIZE]; int buf_idx; unsigned int swinit; - unsigned int first_desc; - unsigned int last_desc; + unsigned int first_request; unsigned int last_request; unsigned int to_hash_later; unsigned int nbuf; @@ -968,8 +967,8 @@ struct talitos_export_state { u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)]; u8 buf[HASH_MAX_BLOCK_SIZE]; unsigned int swinit; - unsigned int first_desc; - unsigned int last_desc; + unsigned int first_request; + unsigned int last_request; unsigned int to_hash_later; unsigned int nbuf; }; @@ -1835,7 +1834,7 @@ static void ahash_done(struct device *dev, struct ahash_request *areq =3D context; struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); =20 - if (!req_ctx->last_desc && req_ctx->to_hash_later) { + if (!req_ctx->last_request && req_ctx->to_hash_later) { /* Position any partial block for next update/final/finup */ req_ctx->buf_idx =3D (req_ctx->buf_idx + 1) & 1; req_ctx->nbuf =3D req_ctx->to_hash_later; @@ -1886,7 +1885,7 @@ static void common_nonsnoop_hash(struct talitos_edesc= *edesc, /* first DWORD empty */ =20 /* hash context in */ - if (!edesc->first || !req_ctx->first_desc || req_ctx->swinit) { + if (!edesc->first || !req_ctx->first_request || req_ctx->swinit) { map_single_talitos_ptr_nosync(dev, &desc->ptr[1], req_ctx->hw_context_size, req_ctx->hw_context, @@ -1894,7 +1893,7 @@ static void common_nonsnoop_hash(struct talitos_edesc= *edesc, req_ctx->swinit =3D 0; } /* Indicate next op is not the first. */ - req_ctx->first_desc =3D 0; + req_ctx->first_request =3D 0; =20 /* HMAC key */ if (ctx->keylen) @@ -1995,14 +1994,14 @@ static int ahash_process_req_prepare(struct ahash_r= equest *areq, edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_CONT; =20 /* request SEC to INIT hash. */ - if (req_ctx->first_desc && edesc->first && !req_ctx->swinit) + if (req_ctx->first_request && edesc->first && !req_ctx->swinit) edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_INIT; =20 /* * When the tfm context has a keylen, it's an HMAC. * A first or last (ie. not middle) descriptor must request HMAC. */ - if (ctx->keylen && ((req_ctx->first_desc && edesc->first) || + if (ctx->keylen && ((req_ctx->first_request && edesc->first) || (req_ctx->last_request && edesc->last))) edesc->desc.hdr |=3D DESC_HDR_MODE0_MDEU_HMAC; =20 @@ -2122,14 +2121,13 @@ static int ahash_init(struct ahash_request *areq) /* Initialize the context */ req_ctx->buf_idx =3D 0; req_ctx->nbuf =3D 0; - req_ctx->first_desc =3D 1; /* first_desc indicates h/w must init its cont= ext */ + req_ctx->first_request =3D 1; req_ctx->swinit =3D 0; /* assume h/w init of context */ size =3D (crypto_ahash_digestsize(tfm) <=3D SHA256_DIGEST_SIZE) ? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256 : TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512; req_ctx->hw_context_size =3D size; req_ctx->last_request =3D 0; - req_ctx->last_desc =3D 0; =20 dma =3D dma_map_single(dev, req_ctx->hw_context, req_ctx->hw_context_size, DMA_TO_DEVICE); @@ -2221,8 +2219,8 @@ static int ahash_export(struct ahash_request *areq, v= oid *out) req_ctx->hw_context_size); memcpy(export->buf, req_ctx->buf[req_ctx->buf_idx], req_ctx->nbuf); export->swinit =3D req_ctx->swinit; - export->first_desc =3D req_ctx->first_desc; - export->last_desc =3D req_ctx->last_desc; + export->first_request =3D req_ctx->first_request; + export->last_request =3D req_ctx->last_request; export->to_hash_later =3D req_ctx->to_hash_later; export->nbuf =3D req_ctx->nbuf; =20 @@ -2247,8 +2245,8 @@ static int ahash_import(struct ahash_request *areq, c= onst void *in) memcpy(req_ctx->hw_context, export->hw_context, size); memcpy(req_ctx->buf[0], export->buf, export->nbuf); req_ctx->swinit =3D export->swinit; - req_ctx->first_desc =3D export->first_desc; - req_ctx->last_desc =3D export->last_desc; + req_ctx->first_request =3D export->first_request; + req_ctx->last_request =3D export->last_request; req_ctx->to_hash_later =3D export->to_hash_later; req_ctx->nbuf =3D export->nbuf; =20 --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 464614B8DDD for ; Tue, 5 May 2026 17:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003648; cv=none; b=ShwAQi1hwY87qndA0UiFTSE0nVJXdhAOapML43QC2kDX4O219Ut0aqFWOHCG6J0TVmQzoYMV/b5nt/aDgaKnaL15GEpFxmyweRTR6dTNC0lOMKU+5AQavWPk+q4c267NQXJ+QSLQYLEWWXLMO1KesLfLJbTWb6LmaiuPcrNUOOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003648; c=relaxed/simple; bh=zQ7n1cO+oe/QJS0vhjvTNm0Pm5Gg9UkZrj6GnHdOReI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fHS8NToayGrrXVBAXFaTbsZuK4D8RrvvTUHlMZvlLsGK5F4ScmVIkxjwZ3HGlqhK0BDZ7lyg3NHOfH4SjweRsld9DvQBYEkTxvKJ9XrXSBY+ee42ZYWGE0tRgyZH9NwqGUCeZPKBzD0zlLlfqCIuRLktohpofXzu3r5VynwLKV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=UTaqYCiy; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UTaqYCiy" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id B25844E42BD8; Tue, 5 May 2026 17:54:04 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 824146053C; Tue, 5 May 2026 17:54:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5320711AD0415; Tue, 5 May 2026 19:54:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003643; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=yneBkbWvWU9ZpczZXjNql/bZTuQXaRLrSJZVfJv7sVA=; b=UTaqYCiybGh1vUYAVZnt7pesqB1W6QvWbF3s53Yp4GGw889aaRyGRU+sSD4KMh8n0MN9fu ETi3BwW2Zawj/z8mJJkSuRxgUwV7Di5Xh5QTxp9/l2Wy+Y2jJ/XJu+PwVIb4MnWcnd+kXg B1t9bt0Z26D5v4ofTYVoPW0VnF530M8imKyKUzaH8s8cPccANeRj/YHKiS+bSEUTlMGEoD 4+gPpJs2Vhi5pQwzcVv5Ffw0g7AtxxsFbhhTQiJ8fxPdUsPKhKmvDeeNHlWJKWGQgLycZZ LawAeUEnrkXy9WhV/1fZm7J1KsvI3DwVDBwD3SeIO+YluWbf+1uLAF5HvN3Tag== From: Paul Louvel Date: Tue, 05 May 2026 19:53:11 +0200 Subject: [PATCH v2 10/12] crypto: talitos/hash - remove useless wrapper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-10-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=1260; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=zQ7n1cO+oe/QJS0vhjvTNm0Pm5Gg9UkZrj6GnHdOReI=; b=5LA7OBr7bX3QfavYJV5Bu/5zadOvVRh/LtZz79KRoE4IcNWKAqQQzgizxX0ki6QC8+2BRmcfg uXt6dqUxlmAAjTsIUSce25G+Cptn/9lvq9ZZ0B7IJDuCdRf6uKQq9dB X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 ahash_process_req() was a wrapper used in commit 655ef638a2bc ("crypto: talitos - fix SEC1 32k ahash request limitation"). Rename Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 4fad4e862405..10181f5ee0ec 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2020,7 +2020,7 @@ static int ahash_process_req_prepare(struct ahash_req= uest *areq, return 0; } =20 -static int ahash_process_req_one(struct ahash_request *areq, unsigned int = nbytes) +static int ahash_process_req(struct ahash_request *areq, unsigned int nbyt= es) { struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); struct talitos_ctx *ctx =3D crypto_ahash_ctx(tfm); @@ -2104,11 +2104,6 @@ static int ahash_process_req_one(struct ahash_reques= t *areq, unsigned int nbytes return ret; } =20 -static int ahash_process_req(struct ahash_request *areq, unsigned int nbyt= es) -{ - return ahash_process_req_one(areq, nbytes); -} - static int ahash_init(struct ahash_request *areq) { struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9169E4B8DFA for ; Tue, 5 May 2026 17:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003650; cv=none; b=eugeshiuBaIdiSP24Ph5w+ZFvgkB2RkpO+Dhpyet4rjYxkMHruGjQRtwkGIkW0ctYIM0AkcENEfrnEHnMASPTY4N3C+0RF1jO2NN5UPzN6mdu2ILDXCRXG4yY5mlw0N0/eV86MDprDvSbgUrc8F7Ynha8BkFrejQ8Oo0p/MQab4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003650; c=relaxed/simple; bh=rYzBqDMpQHxsfA+dONNoX0tVKVs2dTdmHUIYbbGsfGU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WNOQ6UCJmFUi/w2gPV854jLi2QY+CY7hseW7NOYpGH4nvzPP4wDef0vjmfLNH1C3NqNzId5n89PuUqFOxvYrGp1rPbxfSqHovuiFBGKm0wne2lix4lRf/SbDFAxyQeTRd6YndjTip4ko5iVstfHA3ZViuURgNqH722CksmItLzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GTvhD+nW; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GTvhD+nW" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 31D791A352D; Tue, 5 May 2026 17:54:06 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 011A76053C; Tue, 5 May 2026 17:54:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E607311AD0417; Tue, 5 May 2026 19:54:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003645; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=JpOpkfzbgqwAqNbf+g4UBbxEQwK3GyfW/y3NthccvTA=; b=GTvhD+nWvXY+D8Pe20RP6uwoNQ3N1MClIt5o+lAiT8wN1GDRf7D2L+y1pxOhSd7EtaNDFw pvIQxQrYd62ORlpXTDvSlTP1Hct7jIOG5K/i6ox1G90+3qkxmnI03q/4qoOqa2lbN6tQjk vm6n9bIG7J64LueGcOLmlAX3djzvNr6aY/27gBbbWPAnMbTrLIto7se5V+YZFoJHltB7Dz R5OL10jpQkTe70M3vXVdOIe3h1ViwdINLljC7jkH1R+YjY4AL1y433uFQyHt9gcb8O9c8a vvkEajVbXqLeicsl/M7kygBYflrO32B8oIX/KGiBzZfIq6vnzqTHoXpHsPKzgA== From: Paul Louvel Date: Tue, 05 May 2026 19:53:12 +0200 Subject: [PATCH v2 11/12] crypto: talitos/hash - fix SEC2 64k - 1 ahash request limitation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-11-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=3090; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=rYzBqDMpQHxsfA+dONNoX0tVKVs2dTdmHUIYbbGsfGU=; b=dE4Y9u/IR78IoslRgljNfHFwadp3kQhXMnJHpTdEtd9+6Zh4LS80/ICeVgQHlF1NIUbKS11yE YT5EF05VpaDAhfTtssOdjVYjfqkttVVWavoKaDHgO5U+TKaUgOx/8vk X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 The problem described in commit 655ef638a2bc ("crypto: talitos - fix SEC1 32k ahash request limitation") also apply for the SEC2 hardware, but with a limitation of 64k - 1 bytes. Split ahash_done() into SEC1 and SEC2 paths: SEC1 continues to free the whole descriptor list at once, while SEC2 now iterates through descriptors one by one, submitting the next only after the previous completes, which is required since SEC2 cannot chain descriptors in hardware. Cc: stable@vger.kernel.org Fixes: c662b043cdca ("crypto: af_alg/hash: Support MSG_SPLICE_PAGES") Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 50 ++++++++++++++++++++++++++++++++++++++++----= ---- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 10181f5ee0ec..cdb6823d7038 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1833,18 +1833,51 @@ static void ahash_done(struct device *dev, { struct ahash_request *areq =3D context; struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); + struct crypto_ahash *tfm =3D crypto_ahash_reqtfm(areq); + bool is_sec1 =3D has_ftr_sec1(dev_get_drvdata(dev)); + struct talitos_ctx *ctx =3D crypto_ahash_ctx(tfm); + struct talitos_edesc *edesc, *next; + bool is_last; + + if (is_sec1) { + is_last =3D true; + ahash_free_desc_list_from(areq, + list_first_entry(&req_ctx->desc_list, + struct talitos_edesc, node)); + + ahash_request_complete(areq, err); + } else { + edesc =3D container_of(desc, struct talitos_edesc, desc); + is_last =3D edesc->last; + if (!is_last) + next =3D list_next_entry(edesc, node); =20 - if (!req_ctx->last_request && req_ctx->to_hash_later) { + list_del(&edesc->node); + common_nonsnoop_hash_unmap(dev, edesc, areq); + kfree(edesc); + + if (err) + goto out; + + if (!is_last) { + err =3D talitos_submit(dev, ctx->ch, &next->desc, + ahash_done, areq); + if (err !=3D -EINPROGRESS) + goto out; + return; + } + +out: + if (err && !is_last) + ahash_free_desc_list_from(areq, next); + ahash_request_complete(areq, err); + } + + if (!req_ctx->last_request && is_last && req_ctx->to_hash_later) { /* Position any partial block for next update/final/finup */ req_ctx->buf_idx =3D (req_ctx->buf_idx + 1) & 1; req_ctx->nbuf =3D req_ctx->to_hash_later; } - - ahash_free_desc_list_from(areq, - list_first_entry(&req_ctx->desc_list, - struct talitos_edesc, node)); - - ahash_request_complete(areq, err); } =20 /* @@ -1954,7 +1987,8 @@ static int ahash_process_req_prepare(struct ahash_req= uest *areq, { struct talitos_ctx *ctx =3D crypto_ahash_ctx(crypto_ahash_reqtfm(areq)); struct talitos_ahash_req_ctx *req_ctx =3D ahash_request_ctx(areq); - size_t desc_max =3D is_sec1 ? TALITOS1_MAX_DATA_LEN : SIZE_MAX; + size_t desc_max =3D is_sec1 ? TALITOS1_MAX_DATA_LEN : + TALITOS2_MAX_DATA_LEN; struct talitos_edesc *edesc; struct scatterlist tmp[2]; size_t to_hash_this_desc; --=20 2.53.0 From nobody Sat Jun 13 19:15:32 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3BED4BC017 for ; Tue, 5 May 2026 17:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003650; cv=none; b=JLjB3s9QF/IPMLt0tBN2ekcqCv3be+Tx3wxPqImX0PwwId2IJjSR1zu3bZgYVpvj9sCKE+AkR1AzVnK94eo77avGFTsZyCMZQImZNp6eE+3hwsXJFM/Ag9sDVMgzmrNmA0B1b71SHM1qh/ZKdE62FGSGd9trgbSp4cH5tHXH5a8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778003650; c=relaxed/simple; bh=cGFtgo0CIneYft26pq9frkKi1YpE+xAQE6MAWw9sMmU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jgiSWXvRX7/smQoOaBhHAv7JfImxMPW2SDVi01D3yrqikwC5bwxXCdFhstC2+4tRRMdReK1kmPkeYHqa05l05xEkwM6+xzbx6gU5DjuCF0JBCH2oZNiMjBDXF+sqGQmGW+soPZc3t1Gcm+JOPB3OfnIEvd3njmm9FMZ+qco4zgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=0JcXFFLp; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="0JcXFFLp" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 668A94E42BD6; Tue, 5 May 2026 17:54:07 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 35DC26053C; Tue, 5 May 2026 17:54:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5F6DD11AD0419; Tue, 5 May 2026 19:54:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778003646; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ZpnQUXWUq73ELudmYQPs1N2edbD7ZmXBu8vaxfEusmQ=; b=0JcXFFLpc2mcFKNtctLHftsQV8GLZMXeW3BH5nbpBsYwrT9LJEvj6w93TbbOuKG4PrTXOq YWT4HLYujC/lWpbIbX2jIwv6j4vhAOopjyjtjzTnjMlD2EfGI2nf6JhUrv1+6GA2zCGTu0 jxpQ2x1jd4QPIomYeftStrr+aQTgui2H/IoRqi3BKG4FYClVUVUytYpFQIn452TpP7nsnU 4LtPhVtmm9DQWyfOjRJHYOjecjbh8CFy/8Pa72a+CiwC54tO6rpz2PhBFGQYqJu8K0EWGg 0MmYPhSxNRJ1JHB2xIkvaYeGLYvtjUERqcyRRNl/pZklun5zYN3N+qojGdNvig== From: Paul Louvel Date: Tue, 05 May 2026 19:53:13 +0200 Subject: [PATCH v2 12/12] crypto: talitos - fix invalid submit_count initial value Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-12-5818064bd190@bootlin.com> References: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> In-Reply-To: <20260505-bootlin_test-7-1-rc1_sec_bugfix-v2-0-5818064bd190@bootlin.com> To: Herbert Xu , "David S. Miller" , Paolo Abeni , David Howells , Kim Phillips , Christophe Leroy Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Paul Louvel , stable@vger.kernel.org X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778003630; l=1086; i=paul.louvel@bootlin.com; s=20260313; h=from:subject:message-id; bh=cGFtgo0CIneYft26pq9frkKi1YpE+xAQE6MAWw9sMmU=; b=USC1Hgq/0B0WglVQceOviDvRDBQ/+0qy4t1foyQAu/Ywogb7wiQrvMzWlxjteAGBW3lhngkwK +D1QQ8mYjFfCtN0fjj2akX/ZO2H396hTKXAClDHLbsBzHASUmXF+pL1 X-Developer-Key: i=paul.louvel@bootlin.com; a=ed25519; pk=eLW50NT18UAvUT5cAcYf88zNbBCZDLFXuptpyLVhVIU= X-Last-TLS-Session-Version: TLSv1.3 The submit_count atomic counter is initialized to -(chfifo_len - 1), but since atomic_inc_not_zero() rejects increments when the value is zero, one FIFO slot is always wasted. With chfifo_len =3D 24, only 23 descriptors can be submitted before getting -EAGAIN in talitos_submit(). Fix by initializing submit_count to -chfifo_len so that the counter reaches zero only after all chfifo_len slots are occupied. Cc: stable@vger.kernel.org Fixes: 4b99262881213 ("crypto: talitos - align locks on cache lines") Signed-off-by: Paul Louvel --- drivers/crypto/talitos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index cdb6823d7038..6a5b0b053479 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -3566,7 +3566,7 @@ static int talitos_probe(struct platform_device *ofde= v) } =20 atomic_set(&priv->chan[i].submit_count, - -(priv->chfifo_len - 1)); + -priv->chfifo_len); } =20 dma_set_mask(dev, DMA_BIT_MASK(36)); --=20 2.53.0