From ecaae801d63bc0549ca681608ba787d96faeb322 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Mon, 29 Jul 2019 07:23:19 +0200 Subject: autoboot: fix bug using with CAAM and AUTOBOOT_ENCRYPTION 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 --- common/autoboot.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/autoboot.c b/common/autoboot.c index 42fbd7614a8..7a91736a00f 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -71,8 +72,8 @@ static int passwd_abort_sha256(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; @@ -93,6 +94,9 @@ static int passwd_abort_sha256(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 @@ -101,8 +105,11 @@ static int passwd_abort_sha256(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(); @@ -116,6 +123,8 @@ static int passwd_abort_sha256(uint64_t etime) } } while (!abort && get_ticks() <= etime); + free(presskey); + free(sha); return abort; } -- cgit v1.2.3 From f254bd02a0754402feaed2e5ec5aba4c5f1512e1 Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Wed, 31 Jul 2019 19:59:08 +0300 Subject: avb: Fix build when CONFIG_OPTEE_TA_AVB is disabled When having only these AVB related configs enabled: CONFIG_AVB_VERIFY=y CONFIG_CMD_AVB=y CONFIG_LIBAVB=y build fails with next errors: common/avb_verify.c: In function 'read_persistent_value': common/avb_verify.c:867:6: warning: implicit declaration of function 'get_open_session' common/avb_verify.c:870:45: error: 'struct AvbOpsData' has no member named 'tee' common/avb_verify.c:894:7: warning: implicit declaration of function 'invoke_func' common/avb_verify.c: In function 'write_persistent_value': common/avb_verify.c:931:45: error: 'struct AvbOpsData' has no member named 'tee' Guard read_persistent_value() and write_persistent_value() functions by checking if CONFIG_OPTEE_TA_AVB is enabled (as those are only used in that case) to fix the build with mentioned configuration. Signed-off-by: Sam Protsenko Reviewed-by: Igor Opaniuk --- common/avb_verify.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/avb_verify.c b/common/avb_verify.c index 32034d927cf..36898a610f8 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -851,6 +851,7 @@ static AvbIOResult get_size_of_partition(AvbOps *ops, return AVB_IO_RESULT_OK; } +#ifdef CONFIG_OPTEE_TA_AVB static AvbIOResult read_persistent_value(AvbOps *ops, const char *name, size_t buffer_size, @@ -968,6 +969,8 @@ free_name: return rc; } +#endif + /** * ============================================================================ * AVB2.0 AvbOps alloc/initialisation/free -- cgit v1.2.3 From bf46be72163d90797d3ee5252395da69c6fc2e6b Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 2 Aug 2019 14:58:09 +0200 Subject: console: update silent tag after env load Update the "silent" property with the variable "silent" get from saved environment, it solves the issue when: - CONFIG_SILENT_CONSOLE and CONFIG_SYS_CONSOLE_IS_IN_ENV are activated - silent is not defined in default environment - silent is requested in saved environment with: > env set silent 1; env save On next reboot the console is not disabled as expected after relocation and the environment load from flash (the callback is not called when the INSERT is requested in the created hash table) Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- common/console.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'common') diff --git a/common/console.c b/common/console.c index 0b0dd76256c..7b45403bb3e 100644 --- a/common/console.c +++ b/common/console.c @@ -793,6 +793,9 @@ int console_init_r(void) int iomux_err = 0; #endif + /* update silent for env loaded from flash (initr_env) */ + console_update_silent(); + /* set default handlers at first */ gd->jt->getc = serial_getc; gd->jt->tstc = serial_tstc; @@ -884,6 +887,7 @@ int console_init_r(void) struct list_head *pos; struct stdio_dev *dev; + /* update silent for env loaded from flash (initr_env) */ console_update_silent(); #ifdef CONFIG_SPLASH_SCREEN -- cgit v1.2.3 From 13551b911416044dede2311935f34b29095c8dba Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 2 Aug 2019 14:58:10 +0200 Subject: console: execute flush on uart when silent is removed Avoid to flush buffer when silent console is activated as the console can be reactivate later, after relocation, when the env will be updated with the saved one. Solve issue (missing beginning of U-Boot trace) when: - CONFIG_SILENT_CONSOLE is activated - silent=1 is defined in default environment (CONFIG_EXTRA_ENV_SETTINGS) - silent is removed in saved environment with: > env delete silent; env save Only functional when PRE_CONSOLE_BUFFER is activated. Signed-off-by: Patrick Delaunay Signed-off-by: Patrice Chotard --- common/console.c | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/console.c b/common/console.c index 7b45403bb3e..d086feabb11 100644 --- a/common/console.c +++ b/common/console.c @@ -463,6 +463,11 @@ static void print_pre_console_buffer(int flushpoint) char buf_out[CONFIG_PRE_CON_BUF_SZ + 1]; char *buf_in; +#ifdef CONFIG_SILENT_CONSOLE + if (gd->flags & GD_FLG_SILENT) + return; +#endif + buf_in = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ); if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ) in = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ; @@ -511,8 +516,11 @@ void putc(const char c) membuff_putbyte(&gd->console_out, c); #endif #ifdef CONFIG_SILENT_CONSOLE - if (gd->flags & GD_FLG_SILENT) + if (gd->flags & GD_FLG_SILENT) { + if (!(gd->flags & GD_FLG_DEVINIT)) + pre_console_putc(c); return; + } #endif #ifdef CONFIG_DISABLE_CONSOLE @@ -559,8 +567,11 @@ void puts(const char *s) membuff_put(&gd->console_out, s, strlen(s)); #endif #ifdef CONFIG_SILENT_CONSOLE - if (gd->flags & GD_FLG_SILENT) + if (gd->flags & GD_FLG_SILENT) { + if (!(gd->flags & GD_FLG_DEVINIT)) + pre_console_puts(s); return; + } #endif #ifdef CONFIG_DISABLE_CONSOLE @@ -720,14 +731,22 @@ int console_assign(int file, const char *devname) return -1; } -static void console_update_silent(void) +/* return true if the 'silent' flag is removed */ +static bool console_update_silent(void) { #ifdef CONFIG_SILENT_CONSOLE - if (env_get("silent") != NULL) + if (env_get("silent")) { gd->flags |= GD_FLG_SILENT; - else + } else { + unsigned long flags = gd->flags; + gd->flags &= ~GD_FLG_SILENT; + + return !!(flags & GD_FLG_SILENT); + } #endif + + return false; } int console_announce_r(void) @@ -792,9 +811,13 @@ int console_init_r(void) #if CONFIG_IS_ENABLED(CONSOLE_MUX) int iomux_err = 0; #endif + int flushpoint; /* update silent for env loaded from flash (initr_env) */ - console_update_silent(); + if (console_update_silent()) + flushpoint = PRE_CONSOLE_FLUSHPOINT1_SERIAL; + else + flushpoint = PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL; /* set default handlers at first */ gd->jt->getc = serial_getc; @@ -872,7 +895,7 @@ done: if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) return 0; #endif - print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL); + print_pre_console_buffer(flushpoint); return 0; } @@ -886,9 +909,13 @@ int console_init_r(void) struct list_head *list = stdio_get_list(); struct list_head *pos; struct stdio_dev *dev; + int flushpoint; /* update silent for env loaded from flash (initr_env) */ - console_update_silent(); + if (console_update_silent()) + flushpoint = PRE_CONSOLE_FLUSHPOINT1_SERIAL; + else + flushpoint = PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL; #ifdef CONFIG_SPLASH_SCREEN /* @@ -951,7 +978,7 @@ int console_init_r(void) if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) return 0; #endif - print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL); + print_pre_console_buffer(flushpoint); return 0; } -- cgit v1.2.3 From bddd985734653c366c8da073650930fb2e9b5003 Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Fri, 2 Aug 2019 15:52:28 -0700 Subject: fit: Do not automatically decompress ramdisk images The Linux ramdisk should always be decompressed by the kernel itself, not by U-Boot. Therefore, the 'compression' node in the FIT image should always be set to "none" for ramdisk images, since the only point of using that node is if you want U-Boot to do the decompression itself. Yet some systems populate the node to the compression algorithm used by the kernel instead. This used to be ignored, but now that we support decompression of all image types it becomes a problem. Since ramdisks should never be decompressed by U-Boot anyway, this patch adds a special exception for them to avoid these issues. Still, setting the 'compression' node like that is wrong in the first place, so we still want to print out a warning so that third-party distributions doing this can notice and fix it. Signed-off-by: Julius Werner Reviewed-by: Heiko Schocher Tested-by: Heiko Schocher Reviewed-by: Simon Goldschmidt --- common/image-fit.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/image-fit.c b/common/image-fit.c index e346fed550e..5c63c769de2 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1998,10 +1998,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr, comp = IH_COMP_NONE; loadbuf = buf; /* Kernel images get decompressed later in bootm_load_os(). */ - if (!(image_type == IH_TYPE_KERNEL || - image_type == IH_TYPE_KERNEL_NOLOAD) && - !fit_image_get_comp(fit, noffset, &comp) && - comp != IH_COMP_NONE) { + if (!fit_image_get_comp(fit, noffset, &comp) && + comp != IH_COMP_NONE && + !(image_type == IH_TYPE_KERNEL || + image_type == IH_TYPE_KERNEL_NOLOAD || + image_type == IH_TYPE_RAMDISK)) { ulong max_decomp_len = len * 20; if (load == data) { loadbuf = malloc(max_decomp_len); @@ -2021,6 +2022,10 @@ int fit_image_load(bootm_headers_t *images, ulong addr, memcpy(loadbuf, buf, len); } + if (image_type == IH_TYPE_RAMDISK && comp != IH_COMP_NONE) + puts("WARNING: 'compression' nodes for ramdisks are deprecated," + " please fix your .its file!\n"); + /* verify that image data is a proper FDT blob */ if (image_type == IH_TYPE_FLATDT && fdt_check_header(loadbuf)) { puts("Subimage data is not a FDT"); -- cgit v1.2.3 From 24434adbd1c73b59bff3c42691e26cc52cdb262a Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Mon, 5 Aug 2019 20:11:03 +0300 Subject: common: image-android-dt: Fix logic in print fdt info routine Do not attempt to print fdt info if root node wasn't found. Signed-off-by: Sam Protsenko --- common/image-android-dt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/image-android-dt.c b/common/image-android-dt.c index 69168261793..a2d52df4a2a 100644 --- a/common/image-android-dt.c +++ b/common/image-android-dt.c @@ -78,17 +78,18 @@ static void android_dt_print_fdt_info(const struct fdt_header *fdt) { u32 fdt_size; int root_node_off; - const char *compatible = NULL; + const char *compatible; - fdt_size = fdt_totalsize(fdt); root_node_off = fdt_path_offset(fdt, "/"); if (root_node_off < 0) { printf("Error: Root node not found\n"); - } else { - compatible = fdt_getprop(fdt, root_node_off, "compatible", - NULL); + return; } + fdt_size = fdt_totalsize(fdt); + compatible = fdt_getprop(fdt, root_node_off, "compatible", + NULL); + printf(" (FDT)size = %d\n", fdt_size); printf(" (FDT)compatible = %s\n", compatible ? compatible : "(unknown)"); -- cgit v1.2.3