All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] autoboot: fix bug using with CAAM and AUTOBOOT_ENCRYPTION
@ 2019-07-29  5:23 Heiko Schocher
  2019-08-08  3:16 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Heiko Schocher @ 2019-07-29  5:23 UTC (permalink / raw)
  To: u-boot

if  CONFIG_AUTOBOOT_KEYED, CONFIG_AUTOBOOT_ENCRYPTION and
CONFIG_AUTOBOOT_STOP_STR_SHA256 are enabled in conjunction
with CONFIG_SHA_HW_ACCEL and CONFIG_FSL_CAAM, we get the
Error when pressing a key while waiting for bootdelay:

Error: Address arguments are not aligned
CAAM was not setup properly or it is faulty

Reason is, that used variables are not cache aligned,
so malloc this variables cache aligned.

Probably this is also a bugfix for other hw accelerators
than CAAM.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
clean travis build:
https://travis-ci.org/hsdenx/u-boot-test/builds/563021871

Unfortunately, another error in above scenario pops up,
U-Boot crashes now, anybody used sha256 calculation
with CAAM and SHA_HW_ACCEL ?

Nevertheless, this fix is valid, and should be applied,
to get rid of runtime error message.


 common/autoboot.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/common/autoboot.c b/common/autoboot.c
index 94133eaeda..c69104e0e5 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -10,6 +10,7 @@
 #include <cli.h>
 #include <console.h>
 #include <fdtdec.h>
+#include <memalign.h>
 #include <menu.h>
 #include <post.h>
 #include <u-boot/sha256.h>
@@ -52,8 +53,8 @@ static int passwd_abort(uint64_t etime)
 {
 	const char *sha_env_str = env_get("bootstopkeysha256");
 	u8 sha_env[SHA256_SUM_LEN];
-	u8 sha[SHA256_SUM_LEN];
-	char presskey[MAX_DELAY_STOP_STR];
+	u8 *sha;
+	char *presskey;
 	const char *algo_name = "sha256";
 	u_int presskey_len = 0;
 	int abort = 0;
@@ -74,6 +75,9 @@ static int passwd_abort(uint64_t etime)
 		return 0;
 	}
 
+	presskey = malloc_cache_aligned(MAX_DELAY_STOP_STR);
+	sha = malloc_cache_aligned(SHA256_SUM_LEN);
+	size = SHA256_SUM_LEN;
 	/*
 	 * We don't know how long the stop-string is, so we need to
 	 * generate the sha256 hash upon each input character and
@@ -82,8 +86,11 @@ static int passwd_abort(uint64_t etime)
 	do {
 		if (tstc()) {
 			/* Check for input string overflow */
-			if (presskey_len >= MAX_DELAY_STOP_STR)
+			if (presskey_len >= MAX_DELAY_STOP_STR) {
+				free(presskey);
+				free(sha);
 				return 0;
+			}
 
 			presskey[presskey_len++] = getc();
 
@@ -97,6 +104,8 @@ static int passwd_abort(uint64_t etime)
 		}
 	} while (!abort && get_ticks() <= etime);
 
+	free(presskey);
+	free(sha);
 	return abort;
 }
 #else
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] autoboot: fix bug using with CAAM and AUTOBOOT_ENCRYPTION
  2019-07-29  5:23 [U-Boot] [PATCH] autoboot: fix bug using with CAAM and AUTOBOOT_ENCRYPTION Heiko Schocher
@ 2019-08-08  3:16 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2019-08-08  3:16 UTC (permalink / raw)
  To: u-boot

On Mon, Jul 29, 2019 at 07:23:19AM +0200, Heiko Schocher wrote:

> if  CONFIG_AUTOBOOT_KEYED, CONFIG_AUTOBOOT_ENCRYPTION and
> CONFIG_AUTOBOOT_STOP_STR_SHA256 are enabled in conjunction
> with CONFIG_SHA_HW_ACCEL and CONFIG_FSL_CAAM, we get the
> Error when pressing a key while waiting for bootdelay:
> 
> Error: Address arguments are not aligned
> CAAM was not setup properly or it is faulty
> 
> Reason is, that used variables are not cache aligned,
> so malloc this variables cache aligned.
> 
> Probably this is also a bugfix for other hw accelerators
> than CAAM.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190807/acfd98d7/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-08  3:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29  5:23 [U-Boot] [PATCH] autoboot: fix bug using with CAAM and AUTOBOOT_ENCRYPTION Heiko Schocher
2019-08-08  3:16 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.