From: Andrew Davis <afd@ti.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
<u-boot@lists.denx.de>
Cc: Andrew Davis <afd@ti.com>
Subject: [PATCH] arm: mach-k3: security: Use dma-mapping for cache ops
Date: Fri, 7 Oct 2022 12:12:29 -0500 [thread overview]
Message-ID: <20221007171229.31721-1-afd@ti.com> (raw)
This matches how this would be done in Linux and these functions
do the alignment for us which makes the code look cleaner.
Signed-off-by: Andrew Davis <afd@ti.com>
---
arch/arm/mach-k3/security.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-k3/security.c b/arch/arm/mach-k3/security.c
index d8d41ec515..092588f4b5 100644
--- a/arch/arm/mach-k3/security.c
+++ b/arch/arm/mach-k3/security.c
@@ -18,6 +18,7 @@
#include <mach/spl.h>
#include <spl.h>
#include <asm/arch/sys_proto.h>
+#include <linux/dma-mapping.h>
#include "common.h"
@@ -47,7 +48,6 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)
u32 image_size;
int ret;
- image_addr = (uintptr_t)*p_image;
image_size = *p_size;
if (!image_size)
@@ -80,13 +80,12 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)
return;
}
+ /* Clean out image so it can be seen by system firmware */
+ image_addr = dma_map_single(*p_image, *p_size, DMA_BIDIRECTIONAL);
+
debug("Authenticating image at address 0x%016llx\n", image_addr);
debug("Authenticating image of size %d bytes\n", image_size);
- flush_dcache_range((unsigned long)image_addr,
- ALIGN((unsigned long)image_addr + image_size,
- ARCH_DMA_MINALIGN));
-
/* Authenticate image */
ret = proc_ops->proc_auth_boot_image(ti_sci, &image_addr, &image_size);
if (ret) {
@@ -94,10 +93,9 @@ void ti_secure_image_post_process(void **p_image, size_t *p_size)
hang();
}
+ /* Invalidate any stale lines over data written by system firmware */
if (image_size)
- invalidate_dcache_range((unsigned long)image_addr,
- ALIGN((unsigned long)image_addr +
- image_size, ARCH_DMA_MINALIGN));
+ dma_unmap_single(image_addr, image_size, DMA_BIDIRECTIONAL);
/*
* The image_size returned may be 0 when the authentication process has
--
2.37.3
next reply other threads:[~2022-10-07 17:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 17:12 Andrew Davis [this message]
2022-10-18 22:15 ` [PATCH] arm: mach-k3: security: Use dma-mapping for cache ops Tom Rini
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=20221007171229.31721-1-afd@ti.com \
--to=afd@ti.com \
--cc=sjg@chromium.org \
--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