From 4d145f26dd06d9de0c2da3ff2c1f8be1ac9dbd2b Mon Sep 17 00:00:00 2001 From: Philippe Reynes Date: Fri, 11 Dec 2020 19:56:47 +0100 Subject: bootcount: allow to use this feature on TPL This commit add an option TPL_BOOTCOUNT_LIMIT to use bootcount on TPL. Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- common/spl/Kconfig | 9 ++++++++- common/spl/spl.c | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/spl/Kconfig b/common/spl/Kconfig index bdc229f9306..774541c02bc 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -186,7 +186,7 @@ config SPL_BOOTROM_SUPPORT config SPL_BOOTCOUNT_LIMIT bool "Support bootcount in SPL" - depends on SPL_ENV_SUPPORT + depends on SPL_ENV_SUPPORT && !TPL_BOOTCOUNT_LIMIT help On some boards, which use 'falcon' mode, it is necessary to check and increment the number of boot attempts. Such boards do not @@ -1382,6 +1382,13 @@ config TPL_BOARD_INIT spl_board_init() from board_init_r(). This function should be provided by the board. +config TPL_BOOTCOUNT_LIMIT + bool "Support bootcount in TPL" + depends on TPL_ENV_SUPPORT + help + If this option is enabled, the TPL will support bootcount. + For example, it may be useful to choose the device to boot. + config TPL_LDSCRIPT string "Linker script for the TPL stage" depends on TPL diff --git a/common/spl/spl.c b/common/spl/spl.c index 835c53deaa8..8b7374487d3 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -837,7 +837,9 @@ ulong spl_relocate_stack_gd(void) #endif } -#if defined(CONFIG_BOOTCOUNT_LIMIT) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT) +#if defined(CONFIG_BOOTCOUNT_LIMIT) && \ + ((!defined(CONFIG_TPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)) || \ + (defined(CONFIG_TPL_BUILD) && !defined(CONFIG_TPL_BOOTCOUNT_LIMIT))) void bootcount_store(ulong a) { } -- cgit v1.2.3 From 76c78a548144b69ecc3ed9cc2d670297983da6b1 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Mon, 11 Jan 2021 08:46:58 -0600 Subject: common: fit-sig: Fix error message in fit_config_verify_sig() In fit_config_verify_sig(), when no 'signature*' subnode exists in the configuration node, the fdt_for_each_subnode() loop is a no-op. Therefore, no error flags are set, and 'err_,sg' is not populated with an error string. This is incorrect behavior. Populate err_msg to indicate that no 'signature' is found, before entering the loop. The first call to fit_image_verify_sig() will override clear err_msg, or set it to a more specific message. Signed-off-by: Alexandru Gagniuc Reviewed-by: Simon Glass --- common/image-fit-sig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/image-fit-sig.c b/common/image-fit-sig.c index d39741e9058..31cc580941a 100644 --- a/common/image-fit-sig.c +++ b/common/image-fit-sig.c @@ -360,7 +360,7 @@ static int fit_config_verify_sig(const void *fit, int conf_noffset, const void *sig_blob, int sig_offset) { int noffset; - char *err_msg = ""; + char *err_msg = "No 'signature' subnode found"; int verified = 0; int ret; -- cgit v1.2.3 From 09d9ba9097ceb374f2802506c9e755fd8d5dd861 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 13 Jan 2021 20:29:42 -0700 Subject: spl: Add functions for next and previous phase It is useful to be able to figure out which phase we are loading next and which phase we came from. Add some functions to handle this as well as returning the name of a phase. This allows messages like "Booting to x" where x is the next phase. At present, TPL says 'Jumping to U-Boot' at the end, when in fact it is jumping to SPL. This is confusing, so use the new functions to correct this. Tests for this will come with an upcoming minor SPL test refactor. Signed-off-by: Simon Glass --- common/spl/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/spl/spl.c b/common/spl/spl.c index 8b7374487d3..8cb6f3d531f 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -734,7 +734,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug("Failed to stash bootstage: err=%d\n", ret); #endif - debug("loaded - jumping to U-Boot...\n"); + debug("loaded - jumping to %s...\n", spl_phase_name(spl_next_phase())); spl_board_prepare_for_boot(); jump_to_image_no_args(&spl_image); } -- cgit v1.2.3 From 9fe064646d2c9f3914cd5ceae51c34020aa77599 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 13 Jan 2021 20:29:43 -0700 Subject: bloblist: Support relocating to a larger space Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may want to add a lot more to it, such as ACPI tables. Add a way to expand the bloblist by relocating it in U-Boot proper, along with the other relocation activities. Signed-off-by: Simon Glass --- common/Kconfig | 10 ++++++++++ common/bloblist.c | 11 +++++++++++ common/board_f.c | 10 ++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/Kconfig b/common/Kconfig index d8982ba3776..45535e3501d 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -697,6 +697,16 @@ config BLOBLIST_ADDR Sets the address of the bloblist, set up by the first part of U-Boot which runs. Subsequent U-Boot stages typically use the same address. +config BLOBLIST_SIZE_RELOC + hex "Size of bloblist after relocation" + depends on BLOBLIST + default BLOBLIST_SIZE + help + Sets the size of the bloblist in bytes after relocation. Since U-Boot + has a lot more memory available then, it is possible to use a larger + size than the one set up by SPL. This bloblist is set up during the + relocation process. + endmenu source "common/spl/Kconfig" diff --git a/common/bloblist.c b/common/bloblist.c index 33b58623807..e32f551e27e 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -317,6 +317,15 @@ void bloblist_show_list(void) } } +void bloblist_reloc(void *to, uint to_size, void *from, uint from_size) +{ + struct bloblist_hdr *hdr; + + memcpy(to, from, from_size); + hdr = to; + hdr->size = to_size; +} + int bloblist_init(void) { bool expected; @@ -327,6 +336,8 @@ int bloblist_init(void) * that runs */ expected = !u_boot_first_phase(); + if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST)) + expected = false; if (expected) ret = bloblist_check(CONFIG_BLOBLIST_ADDR, CONFIG_BLOBLIST_SIZE); diff --git a/common/board_f.c b/common/board_f.c index ae3001bed1b..4327a43a33b 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -568,9 +568,10 @@ static int reserve_bloblist(void) { #ifdef CONFIG_BLOBLIST /* Align to a 4KB boundary for easier reading of addresses */ - gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - CONFIG_BLOBLIST_SIZE, - 0x1000); - gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE); + gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - + CONFIG_BLOBLIST_SIZE_RELOC, 0x1000); + gd->new_bloblist = map_sysmem(gd->start_addr_sp, + CONFIG_BLOBLIST_SIZE_RELOC); #endif return 0; @@ -658,7 +659,8 @@ static int reloc_bloblist(void) debug("Copying bloblist from %p to %p, size %x\n", gd->bloblist, gd->new_bloblist, size); - memcpy(gd->new_bloblist, gd->bloblist, size); + bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC, + gd->bloblist, size); gd->bloblist = gd->new_bloblist; } #endif -- cgit v1.2.3 From 02d7a53ce6e31dc8f9f45949209468c16a025638 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 13 Jan 2021 20:29:44 -0700 Subject: bloblist: Add missing tag names Add tag names for recently added types. Fixes: d2cb7a22da0 (x86: Allow putting some tables in the bloblist) Signed-off-by: Simon Glass --- common/bloblist.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common') diff --git a/common/bloblist.c b/common/bloblist.c index e32f551e27e..0e6448becbc 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -33,6 +33,12 @@ static const char *const tag_name[] = { [BLOBLISTT_SPL_HANDOFF] = "SPL hand-off", [BLOBLISTT_VBOOT_CTX] = "Chrome OS vboot context", [BLOBLISTT_VBOOT_HANDOFF] = "Chrome OS vboot hand-off", + [BLOBLISTT_ACPI_GNVS] = "ACPI GNVS", + [BLOBLISTT_INTEL_VBT] = "Intel Video-BIOS table", + [BLOBLISTT_TPM2_TCG_LOG] = "TPM v2 log space", + [BLOBLISTT_TCPA_LOG] = "TPM log space", + [BLOBLISTT_ACPI_TABLES] = "ACPI tables for x86", + [BLOBLISTT_SMBIOS_TABLES] = "SMBIOS tables for x86", }; const char *bloblist_tag_name(enum bloblist_tag_t tag) -- cgit v1.2.3 From e088f0c3d87005bd2bdf11d571e20f6232cc021f Mon Sep 17 00:00:00 2001 From: "Yuezhang.Mo@sony.com" Date: Fri, 15 Jan 2021 03:11:49 +0000 Subject: autoboot: fix illegal memory access when stop key and delay key are empty If both stop key and delay key are empty, the length of these keys is 0. The subtraction operation will cause the u_int type variable to overflow, will cause illegal memory access in key input loop. This commit fixes this bug by using int type instead of u_init. Acked-by: Heinrich Schuchardt --- common/autoboot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/autoboot.c b/common/autoboot.c index ddb6246be34..b025fd99a0b 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -164,9 +164,9 @@ static int passwd_abort_key(uint64_t etime) }; char presskey[MAX_DELAY_STOP_STR]; - u_int presskey_len = 0; - u_int presskey_max = 0; - u_int i; + int presskey_len = 0; + int presskey_max = 0; + int i; # ifdef CONFIG_AUTOBOOT_DELAY_STR if (delaykey[0].str == NULL) -- cgit v1.2.3