From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AE733C0A02 for ; Thu, 9 Jul 2026 19:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783626060; cv=none; b=dWiGatwAzDXv9U0lH37ksiCkBBUxsNbn9BdnDEbIJbf1uKBZ5eZkZuRp9iZ7/LrIkETcNs4C1XDrqM40I0JwJN7rsFjmXMszzhiHYYga339U3qGWLqXI/vhj/iLw8Z58ZXHeaun3ejOSGeqQEOddeq4xJxV7/NlCIIAuiqQV0CU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783626060; c=relaxed/simple; bh=swuelVOiFXTo0uANhljDHF4uXg4AQbekEZ74LGQqfLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tR9npvABEOJAaiJXEIXjz9wIBirpWSqI1vWIXcHcF4CKE+XA9G5cjZQRhw80EUXG61IJFPk/KsTpPUGLjMYepn8yajVQdQ1XKnw/gZmUBfwrWvVCyzGch6cf7lslaoTVqysoWV7ExVn2cd1VdNlaFKgA0lUwyP7w8nZkdIOK1/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WLMkcVMn; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WLMkcVMn" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-47122683cf3so163586f8f.0 for ; Thu, 09 Jul 2026 12:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783626056; x=1784230856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pAMHd2nEth3mcfhB9jwZxNibBU59Ye3YjIZZKOw0cyg=; b=WLMkcVMn1kEAUAohgOwPKAHQ8CzmBKhHLPNZ1gvOMfzCvNSlNYkJKEZMg6guuNx0tp iND4+Vrk3BdpC4Vza12FZtxtejqd3w8FcBHCRJwJ8pvFSNqOPaKGpW/gJD4tGE00v3I5 fIbIiobqsUCjPM7FOWqNNvgrHjKrCCvXTXNR/QuOFf47pSaeUwrJHzcX83FvfVqa06uA KhDF2Hlkl5/stZoH4rIx2rvKvi02OQAAeqXaKaKElvBbfjXdfBu54WEUIizlg0i/WDk/ kBFr2/0bXfVhufnMII4MFNHT/rk7DFknlJlrIjx1vBBQOnB/t77KHJ/IuqruT9X/IGHi wWvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783626056; x=1784230856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=pAMHd2nEth3mcfhB9jwZxNibBU59Ye3YjIZZKOw0cyg=; b=BtLnW6S84/qm2jtKBA65ZLzPGbbUU53T1Bd82N4BRa8WGoLyJggj8sVqMPpOMMuwpF MoiPWelkkOASULAkdrDsSNWn3Yvdj7e0PBc3gu9YDwJfypt8bM59++nnIsLdZUbaCG03 qpWXUe9pdwpfPxHEApHggr+X+H9XrNN9/rh8MfH3y+u5+DrHiziDb6w7jh2Xy8sEliSY 4unT8rO5qdx7kT+FBwnPDh9qhjPbQxJTz1+rU0Rch8ALTFCMzfiSMjH4V2KAnlvbuGiH blWQhI7vxxreqBs309D/ejhHiSZmylEXHl7yhtjJ34WC6SVfSMrNTO23i/7C0vfugs8P JThQ== X-Forwarded-Encrypted: i=1; AHgh+RpIEVEbK6zCmn0zFt8wVWAcxkfHmSHjLoAeK3QYQF7toDR98cipYPUdZjBv8+gbNMc07LpGU5ndfTudtnw=@vger.kernel.org X-Gm-Message-State: AOJu0YzgbDoUbUuI9ZkHMGaTmLUJ3A5gRV9UlRBZOrrWiBQDnhz1YJD5 uQZcyIIITGaxE/9QcpmLrfDO5dtEde8FGKSUbV2VE+bhA0kJQP2SUJyc X-Gm-Gg: AfdE7cl8BdHIvb4kAXAsBI30p+t20hahhFciZ9NK/0muU4Jc4PDX2BvefkQWpNg1a3e 32YB0MqJKiPkXdk6OfHdi7+U7uHTWlPI1xXXWx7rEnwe6/f/9LOR3SRa6Aw7mezJrJFyZyCqXq9 rcK35IonGVCRF8bJivPGLkHqwqFjpYrBdcNd3Pn3E8CMfRkJX2MN7gasaxc3y9zTDDlNRI4tZWZ Yu/Q3H6Fec2iTMMX9HtKknPmA+lKz86eDlNvzQw+aqDFpQt52dFWZGm/Cna+/CtcwN9/1iRxt9+ ULa676tOME00mfWnvATRVIHMmPlBFP+gzL30RmvSggVHpHrkhnL/PGFsEoH1jJvMLAYtsqUggqZ dKlYGzouPU1nbZa86H7zsvar21ajZGr42ZFAPo4/HkOm5BhYxdZKxni4NhPpzwzrfv/EOyicsfy CVuwUmLWIQfssJL1rJmFlf7IpS X-Received: by 2002:a5d:5f54:0:b0:460:71e6:e3b with SMTP id ffacd0b85a97d-47df074cec1mr9172157f8f.27.1783626056405; Thu, 09 Jul 2026 12:40:56 -0700 (PDT) Received: from mini.main.internal ([2a02:908:c211:cd18:d9f3:ab2b:ac6e:fc84]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47aa0a558easm53986441f8f.27.2026.07.09.12.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 12:40:55 -0700 (PDT) From: Goetz Goerisch To: gregkh@linuxfoundation.org Cc: ggoerisch@gmail.com, herbert@gondor.apana.org.au, herve.codina@bootlin.com, linux-crypto@vger.kernel.org, miquel.raynal@bootlin.com, paul.louvel@bootlin.com, sashal@kernel.org, stable@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH 2/5] Revert "crypto: talitos - fix SEC1 32k ahash request limitation" Date: Thu, 9 Jul 2026 21:39:53 +0200 Message-ID: <20260709193956.15619-3-ggoerisch@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260709193956.15619-1-ggoerisch@gmail.com> References: <2026070912-pluck-bagful-2a71@gregkh> <20260709193956.15619-1-ggoerisch@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This reverts commit 00463d5f864ae28b7938d5acd0ddd800d5457e8b. Which was backported without applying upstream commit 9826d1d6ed5f86cb3d61610b3b1fe31e96a40418 first. Commit a1b80018b8cec27fc06a8b04a7f8b5f6cfe86eae was backported to 6.6.y with a866e2b1c65edaee2e1bb1024ee2c761ced335f8 It renames last to last_desc but misses one occurrence which leads to compile errors on mpc85xx drivers/crypto/talitos.c: In function 'ahash_digest': drivers/crypto/talitos.c:2204:16: error: 'struct talitos_ahash_req_ctx' has no member named 'last' 2204 | req_ctx->last = 1; | ^~~~ Instead of renaming req_ctx->last, commit 9826d1d6ed5f8 ("crypto: talitos - stop using crypto_ahash::init") should be applied. Ideally before commit 00463d5f864a ("crypto: talitos - fix SEC1 32k ahash request limitation") to avoid any compilation breakage and ensure correctness of the code. Reverting and applying in correct order. Link: https://lore.kernel.org/all/DIOA24QU02W5.2RSVK05RE7BJK@bootlin.com/ Signed-off-by: Goetz Goerisch --- drivers/crypto/talitos.c | 216 +++++++++++++-------------------------- 1 file changed, 69 insertions(+), 147 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index f78a44f99101..4ca4fbd227bc 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -12,7 +12,6 @@ * All rights reserved. */ -#include #include #include #include @@ -871,18 +870,10 @@ struct talitos_ahash_req_ctx { unsigned int swinit; unsigned int first; unsigned int last; - unsigned int last_request; unsigned int to_hash_later; unsigned int nbuf; struct scatterlist bufsl[2]; struct scatterlist *psrc; - - 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; }; struct talitos_export_state { @@ -1768,20 +1759,7 @@ static void ahash_done(struct device *dev, kfree(edesc); - if (err) { - ahash_request_complete(areq, err); - return; - } - - req_ctx->remaining_ahash_request_bytes -= - 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); + ahash_request_complete(areq, err); } /* @@ -1947,7 +1925,60 @@ static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq, nbytes, 0, 0, 0, areq->base.flags, false); } -static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes) +static int ahash_init(struct ahash_request *areq) +{ + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); + struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); + struct device *dev = ctx->dev; + struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); + unsigned int size; + dma_addr_t dma; + + /* Initialize the context */ + req_ctx->buf_idx = 0; + req_ctx->nbuf = 0; + req_ctx->first = 1; /* first indicates h/w must init its context */ + req_ctx->swinit = 0; /* assume h/w init of context */ + size = (crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE) + ? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256 + : TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512; + req_ctx->hw_context_size = size; + + dma = dma_map_single(dev, req_ctx->hw_context, req_ctx->hw_context_size, + DMA_TO_DEVICE); + dma_unmap_single(dev, dma, req_ctx->hw_context_size, DMA_TO_DEVICE); + + return 0; +} + +/* + * on h/w without explicit sha224 support, we initialize h/w context + * manually with sha224 constants, and tell it to run sha256. + */ +static int ahash_init_sha224_swinit(struct ahash_request *areq) +{ + struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); + + req_ctx->hw_context[0] = SHA224_H0; + req_ctx->hw_context[1] = SHA224_H1; + req_ctx->hw_context[2] = SHA224_H2; + req_ctx->hw_context[3] = SHA224_H3; + req_ctx->hw_context[4] = SHA224_H4; + req_ctx->hw_context[5] = SHA224_H5; + req_ctx->hw_context[6] = SHA224_H6; + req_ctx->hw_context[7] = SHA224_H7; + + /* init 64-bit count */ + req_ctx->hw_context[8] = 0; + req_ctx->hw_context[9] = 0; + + ahash_init(areq); + req_ctx->swinit = 1;/* prevent h/w initting context with sha256 values*/ + + return 0; +} + +static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); @@ -1966,12 +1997,12 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { /* Buffer up to one whole block */ - nents = sg_nents_for_len(req_ctx->request_sl, nbytes); + nents = 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 += nbytes; return 0; @@ -1998,7 +2029,7 @@ static int ahash_process_req_one(struct ahash_request *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 = req_ctx->bufsl; } else if (is_sec1 && req_ctx->nbuf && req_ctx->nbuf < blocksize) { int offset; @@ -2007,26 +2038,26 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes offset = blocksize - req_ctx->nbuf; else offset = nbytes_to_hash - req_ctx->nbuf; - nents = sg_nents_for_len(req_ctx->request_sl, offset); + nents = sg_nents_for_len(areq->src, offset); 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, offset); req_ctx->nbuf += offset; - req_ctx->psrc = scatterwalk_ffwd(req_ctx->bufsl, req_ctx->request_sl, + req_ctx->psrc = scatterwalk_ffwd(req_ctx->bufsl, areq->src, offset); } else - req_ctx->psrc = req_ctx->request_sl; + req_ctx->psrc = areq->src; if (to_hash_later) { - nents = sg_nents_for_len(req_ctx->request_sl, nbytes); + nents = 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); @@ -2034,7 +2065,7 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes req_ctx->to_hash_later = to_hash_later; /* Allocate extended descriptor */ - edesc = ahash_edesc_alloc(req_ctx->areq, nbytes_to_hash); + edesc = ahash_edesc_alloc(areq, nbytes_to_hash); if (IS_ERR(edesc)) return PTR_ERR(edesc); @@ -2056,123 +2087,14 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes if (ctx->keylen && (req_ctx->first || req_ctx->last)) edesc->desc.hdr |= DESC_HDR_MODE0_MDEU_HMAC; - return common_nonsnoop_hash(edesc, req_ctx->areq, nbytes_to_hash, ahash_done); -} - -static void sec1_ahash_process_remaining(struct work_struct *work) -{ - struct talitos_ahash_req_ctx *req_ctx = - container_of(work, struct talitos_ahash_req_ctx, - sec1_ahash_process_remaining); - int err = 0; - - req_ctx->request_sl = 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 = TALITOS1_MAX_DATA_LEN; - else { - req_ctx->current_ahash_request_bytes = - req_ctx->remaining_ahash_request_bytes; - - if (req_ctx->last_request) - req_ctx->last = 1; - } - - err = ahash_process_req_one(req_ctx->areq, - req_ctx->current_ahash_request_bytes); - - if (err != -EINPROGRESS) - ahash_request_complete(req_ctx->areq, err); -} - -static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) -{ - struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); - struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); - struct device *dev = ctx->dev; - struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - struct talitos_private *priv = dev_get_drvdata(dev); - bool is_sec1 = has_ftr_sec1(priv); - - req_ctx->areq = areq; - req_ctx->request_sl = areq->src; - req_ctx->remaining_ahash_request_bytes = nbytes; - - if (is_sec1) { - if (nbytes > TALITOS1_MAX_DATA_LEN) - nbytes = TALITOS1_MAX_DATA_LEN; - else if (req_ctx->last_request) - req_ctx->last = 1; - } - - req_ctx->current_ahash_request_bytes = nbytes; - - return ahash_process_req_one(req_ctx->areq, - req_ctx->current_ahash_request_bytes); -} - -static int ahash_init(struct ahash_request *areq) -{ - struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); - struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); - struct device *dev = ctx->dev; - struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - unsigned int size; - dma_addr_t dma; - - /* Initialize the context */ - req_ctx->buf_idx = 0; - req_ctx->nbuf = 0; - req_ctx->first = 1; /* first indicates h/w must init its context */ - req_ctx->swinit = 0; /* assume h/w init of context */ - size = (crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE) - ? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256 - : TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512; - req_ctx->hw_context_size = size; - req_ctx->last_request = 0; - req_ctx->last = 0; - INIT_WORK(&req_ctx->sec1_ahash_process_remaining, sec1_ahash_process_remaining); - - dma = dma_map_single(dev, req_ctx->hw_context, req_ctx->hw_context_size, - DMA_TO_DEVICE); - dma_unmap_single(dev, dma, req_ctx->hw_context_size, DMA_TO_DEVICE); - - return 0; -} - -/* - * on h/w without explicit sha224 support, we initialize h/w context - * manually with sha224 constants, and tell it to run sha256. - */ -static int ahash_init_sha224_swinit(struct ahash_request *areq) -{ - struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - - req_ctx->hw_context[0] = SHA224_H0; - req_ctx->hw_context[1] = SHA224_H1; - req_ctx->hw_context[2] = SHA224_H2; - req_ctx->hw_context[3] = SHA224_H3; - req_ctx->hw_context[4] = SHA224_H4; - req_ctx->hw_context[5] = SHA224_H5; - req_ctx->hw_context[6] = SHA224_H6; - req_ctx->hw_context[7] = SHA224_H7; - - /* init 64-bit count */ - req_ctx->hw_context[8] = 0; - req_ctx->hw_context[9] = 0; - - ahash_init(areq); - req_ctx->swinit = 1;/* prevent h/w initting context with sha256 values*/ - - return 0; + return common_nonsnoop_hash(edesc, areq, nbytes_to_hash, ahash_done); } static int ahash_update(struct ahash_request *areq) { struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - req_ctx->last_request = 0; + req_ctx->last = 0; return ahash_process_req(areq, areq->nbytes); } @@ -2181,7 +2103,7 @@ static int ahash_final(struct ahash_request *areq) { struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - req_ctx->last_request = 1; + req_ctx->last = 1; return ahash_process_req(areq, 0); } @@ -2190,7 +2112,7 @@ static int ahash_finup(struct ahash_request *areq) { struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - req_ctx->last_request = 1; + req_ctx->last = 1; return ahash_process_req(areq, areq->nbytes); } -- 2.55.0