U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: blemouzy.ml@gmail.com
Cc: u-boot@lists.denx.de, gaurav.jain@nxp.com, trini@konsulko.com,
	Benjamin Lemouzy <blemouzy@centralp.fr>
Subject: Re: [PATCH] crypto: fsl_hash: fix flush dcache alignment in caam_hash()
Date: Fri, 28 Feb 2025 12:17:56 +0800	[thread overview]
Message-ID: <20250228041756.GB30605@nxa18884-linux> (raw)
In-Reply-To: <20250221070501.19472-1-blemouzy@centralp.fr>

Hi Benjamin,

On Fri, Feb 21, 2025 at 08:05:01AM +0100, blemouzy.ml@gmail.com wrote:
>From: Benjamin Lemouzy <blemouzy@centralp.fr>
>
>Loading a FIT kernel image with hash hardware acceleration enabled
>(CONFIG_SHA_HW_ACCEL=y) displays the following CACHE warning:

Sorry for my lazyness, the following patch should be able to solve your issue.
I will prepare a PR soon.
https://patchwork.ozlabs.org/project/uboot/patch/1bd862e53b50825f6030bf9f212127c776fff881.camel@googlemail.com/

Thanks,
Peng
>
>    [...]
>    Trying 'kernel-1' kernel subimage
>    [...]
>    Verifying Hash Integrity ... sha256CACHE: Misaligned operation at
>range [16000128, 1673fae8]
>    [...]
>    Trying 'ramdisk-1' ramdisk subimage
>    [...]
>    Verifying Hash Integrity ... sha256CACHE: Misaligned operation at
>range [1676d6d4, 1737a5d4]
>    [...]
>    Trying 'fdt-imx6q-xxx.dtb' fdt subimage
>    [...]
>    Verifying Hash Integrity ... sha256CACHE: Misaligned operation at
>range [1673fbdc, 1674b0dc]
>    [...]
>
>This patch fixes it.
>
>Tested on:
>- i.MX 6 custom board
>- LS1021A custom board
>
>Signed-off-by: Benjamin Lemouzy <blemouzy@centralp.fr>
>---
> drivers/crypto/fsl/fsl_hash.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/crypto/fsl/fsl_hash.c b/drivers/crypto/fsl/fsl_hash.c
>index 79b32e2627..b721c86609 100644
>--- a/drivers/crypto/fsl/fsl_hash.c
>+++ b/drivers/crypto/fsl/fsl_hash.c
>@@ -183,6 +183,7 @@ int caam_hash(const unsigned char *pbuf, unsigned int buf_len,
> {
> 	int ret = 0;
> 	uint32_t *desc;
>+	unsigned long pbuf_aligned;
> 	unsigned int size;
> 
> 	desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
>@@ -191,8 +192,9 @@ int caam_hash(const unsigned char *pbuf, unsigned int buf_len,
> 		return -ENOMEM;
> 	}
> 
>-	size = ALIGN(buf_len, ARCH_DMA_MINALIGN);
>-	flush_dcache_range((unsigned long)pbuf, (unsigned long)pbuf + size);
>+	pbuf_aligned = ALIGN_DOWN((unsigned long)pbuf, ARCH_DMA_MINALIGN);
>+	size = ALIGN(buf_len + ((unsigned long)pbuf - pbuf_aligned), ARCH_DMA_MINALIGN);
>+	flush_dcache_range(pbuf_aligned, pbuf_aligned + size);
> 
> 	inline_cnstr_jobdesc_hash(desc, pbuf, buf_len, pout,
> 				  driver_hash[algo].alg_type,
>-- 
>2.43.0
>

  reply	other threads:[~2025-02-28  3:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21  7:05 [PATCH] crypto: fsl_hash: fix flush dcache alignment in caam_hash() blemouzy.ml
2025-02-28  4:17 ` Peng Fan [this message]
2025-02-28  8:00   ` Benjamin Lemouzy
2025-03-03  4:03     ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250228041756.GB30605@nxa18884-linux \
    --to=peng.fan@oss.nxp.com \
    --cc=blemouzy.ml@gmail.com \
    --cc=blemouzy@centralp.fr \
    --cc=gaurav.jain@nxp.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox