aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-07-06 15:46:38 -0400
committerTom Rini <trini@konsulko.com>2020-07-06 15:46:38 -0400
commit6e7d7aa2e2062995c1cbc3af81cf40c04c50ad30 (patch)
tree3c560d567a76e9850e0195fb892d7e1fbaeed198 /common
parent2f5fbb5b39f7b67044dda5c35e4a4b31685a3109 (diff)
parent621e09cb3bf7e6d4fce9dd5e6de97e057adebc3a (diff)
downloadu-boot-6e7d7aa2e2062995c1cbc3af81cf40c04c50ad30.zip
u-boot-6e7d7aa2e2062995c1cbc3af81cf40c04c50ad30.tar.gz
u-boot-6e7d7aa2e2062995c1cbc3af81cf40c04c50ad30.tar.bz2
Merge branch 'next'
Merge all outstanding changes from the current next branch in now that we have released.
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig159
-rw-r--r--common/board_f.c2
-rw-r--r--common/board_r.c16
-rw-r--r--common/console.c7
-rw-r--r--common/hash.c83
-rw-r--r--common/image-fit.c9
-rw-r--r--common/image-sig.c26
-rw-r--r--common/spl/Kconfig52
-rw-r--r--common/spl/spl_opensbi.c5
9 files changed, 256 insertions, 103 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 2d86dd7..7872bc4 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -647,28 +647,12 @@ config LOG
discarded if not needed. Logging supports various categories and
levels of severity.
-config SPL_LOG
- bool "Enable logging support in SPL"
- depends on LOG
- help
- This enables support for logging of status and debug messages. These
- can be displayed on the console, recorded in a memory buffer, or
- discarded if not needed. Logging supports various categories and
- levels of severity.
-
-config TPL_LOG
- bool "Enable logging support in TPL"
- depends on LOG
- help
- This enables support for logging of status and debug messages. These
- can be displayed on the console, recorded in a memory buffer, or
- discarded if not needed. Logging supports various categories and
- levels of severity.
+if LOG
config LOG_MAX_LEVEL
int "Maximum log level to record"
- depends on LOG
- default 5
+ default 6
+ range 0 9
help
This selects the maximum log level that will be recorded. Any value
higher than this will be ignored. If possible log statements below
@@ -685,14 +669,15 @@ config LOG_MAX_LEVEL
8 - debug content
9 - debug hardware I/O
-config SPL_LOG_MAX_LEVEL
- int "Maximum log level to record in SPL"
- depends on SPL_LOG
- default 3
+config LOG_DEFAULT_LEVEL
+ int "Default logging level to display"
+ default LOG_MAX_LEVEL
+ range 0 LOG_MAX_LEVEL
help
- This selects the maximum log level that will be recorded. Any value
- higher than this will be ignored. If possible log statements below
- this level will be discarded at build time. Levels:
+ This is the default logging level set when U-Boot starts. It can
+ be adjusted later using the 'log level' command. Note that setting
+ this to a value above LOG_MAX_LEVEL will be ineffective, since the
+ higher levels are not compiled in to U-Boot.
0 - emergency
1 - alert
@@ -705,10 +690,38 @@ config SPL_LOG_MAX_LEVEL
8 - debug content
9 - debug hardware I/O
-config TPL_LOG_MAX_LEVEL
- int "Maximum log level to record in TPL"
- depends on TPL_LOG
+config LOG_CONSOLE
+ bool "Allow log output to the console"
+ default y
+ help
+ Enables a log driver which writes log records to the console.
+ Generally the console is the serial port or LCD display. Only the
+ log message is shown - other details like level, category, file and
+ line number are omitted.
+
+config LOG_SYSLOG
+ bool "Log output to syslog server"
+ depends on NET
+ help
+ Enables a log driver which broadcasts log records via UDP port 514
+ to syslog servers.
+
+config SPL_LOG
+ bool "Enable logging support in SPL"
+ depends on LOG
+ help
+ This enables support for logging of status and debug messages. These
+ can be displayed on the console, recorded in a memory buffer, or
+ discarded if not needed. Logging supports various categories and
+ levels of severity.
+
+if SPL_LOG
+
+config SPL_LOG_MAX_LEVEL
+ int "Maximum log level to record in SPL"
+ depends on SPL_LOG
default 3
+ range 0 9
help
This selects the maximum log level that will be recorded. Any value
higher than this will be ignored. If possible log statements below
@@ -725,14 +738,37 @@ config TPL_LOG_MAX_LEVEL
8 - debug content
9 - debug hardware I/O
-config LOG_DEFAULT_LEVEL
- int "Default logging level to display"
- default 6
+config SPL_LOG_CONSOLE
+ bool "Allow log output to the console in SPL"
+ default y
help
- This is the default logging level set when U-Boot starts. It can
- be adjusted later using the 'log level' command. Note that setting
- this to a value above LOG_MAX_LEVEL will be ineffective, since the
- higher levels are not compiled in to U-Boot.
+ Enables a log driver which writes log records to the console.
+ Generally the console is the serial port or LCD display. Only the
+ log message is shown - other details like level, category, file and
+ line number are omitted.
+
+endif
+
+config TPL_LOG
+ bool "Enable logging support in TPL"
+ depends on LOG
+ help
+ This enables support for logging of status and debug messages. These
+ can be displayed on the console, recorded in a memory buffer, or
+ discarded if not needed. Logging supports various categories and
+ levels of severity.
+
+if TPL_LOG
+
+config TPL_LOG_MAX_LEVEL
+ int "Maximum log level to record in TPL"
+ depends on TPL_LOG
+ default 3
+ range 0 9
+ help
+ This selects the maximum log level that will be recorded. Any value
+ higher than this will be ignored. If possible log statements below
+ this level will be discarded at build time. Levels:
0 - emergency
1 - alert
@@ -745,29 +781,8 @@ config LOG_DEFAULT_LEVEL
8 - debug content
9 - debug hardware I/O
-config LOG_CONSOLE
- bool "Allow log output to the console"
- depends on LOG
- default y
- help
- Enables a log driver which writes log records to the console.
- Generally the console is the serial port or LCD display. Only the
- log message is shown - other details like level, category, file and
- line number are omitted.
-
-config SPL_LOG_CONSOLE
- bool "Allow log output to the console in SPL"
- depends on SPL_LOG
- default y
- help
- Enables a log driver which writes log records to the console.
- Generally the console is the serial port or LCD display. Only the
- log message is shown - other details like level, category, file and
- line number are omitted.
-
config TPL_LOG_CONSOLE
bool "Allow log output to the console in TPL"
- depends on TPL_LOG
default y
help
Enables a log driver which writes log records to the console.
@@ -775,26 +790,10 @@ config TPL_LOG_CONSOLE
log message is shown - other details like level, category, file and
line number are omitted.
-config LOG_SYSLOG
- bool "Log output to syslog server"
- depends on LOG && NET
- help
- Enables a log driver which broadcasts log records via UDP port 514
- to syslog servers.
-
-config LOG_TEST
- bool "Provide a test for logging"
- depends on LOG && UNIT_TEST
- default y if SANDBOX
- help
- This enables a 'log test' command to test logging. It is normally
- executed from a pytest and simply outputs logging information
- in various different ways to test that the logging system works
- correctly with various settings.
+endif
config LOG_ERROR_RETURN
bool "Log all functions which return an error"
- depends on LOG
help
When an error is returned in U-Boot it is sometimes difficult to
figure out the root cause. For example, reading from SPI flash may
@@ -805,6 +804,18 @@ config LOG_ERROR_RETURN
You can add log_ret() to all functions which return an error code.
+config LOG_TEST
+ bool "Provide a test for logging"
+ depends on UNIT_TEST
+ default y if SANDBOX
+ help
+ This enables a 'log test' command to test logging. It is normally
+ executed from a pytest and simply outputs logging information
+ in various different ways to test that the logging system works
+ correctly with various settings.
+
+endif
+
endmenu
config SUPPORT_RAW_INITRD
diff --git a/common/board_f.c b/common/board_f.c
index 01194ea..dcad551 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -537,7 +537,7 @@ static int reserve_fdt(void)
* will be relocated with other data.
*/
if (gd->fdt_blob) {
- gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
+ gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob), 32);
gd->start_addr_sp = reserve_stack_aligned(gd->fdt_size);
gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
diff --git a/common/board_r.c b/common/board_r.c
index fa57fa9..5e92432 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -537,21 +537,7 @@ static int initr_ethaddr(void)
/* kept around for legacy kernels only ... ignore the next section */
eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr);
-#ifdef CONFIG_HAS_ETH1
- eth_env_get_enetaddr("eth1addr", bd->bi_enet1addr);
-#endif
-#ifdef CONFIG_HAS_ETH2
- eth_env_get_enetaddr("eth2addr", bd->bi_enet2addr);
-#endif
-#ifdef CONFIG_HAS_ETH3
- eth_env_get_enetaddr("eth3addr", bd->bi_enet3addr);
-#endif
-#ifdef CONFIG_HAS_ETH4
- eth_env_get_enetaddr("eth4addr", bd->bi_enet4addr);
-#endif
-#ifdef CONFIG_HAS_ETH5
- eth_env_get_enetaddr("eth5addr", bd->bi_enet5addr);
-#endif
+
return 0;
}
#endif /* CONFIG_CMD_NET */
diff --git a/common/console.c b/common/console.c
index 1deca3c..f149624 100644
--- a/common/console.c
+++ b/common/console.c
@@ -713,7 +713,7 @@ struct stdio_dev *search_device(int flags, const char *name)
dev = stdio_get_by_name(name);
#ifdef CONFIG_VIDCONSOLE_AS_LCD
- if (!dev && !strcmp(name, "lcd"))
+ if (!dev && !strcmp(name, CONFIG_VIDCONSOLE_AS_LCD))
dev = stdio_get_by_name("vidconsole");
#endif
@@ -897,8 +897,9 @@ done:
stdio_print_current_devices();
#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
#ifdef CONFIG_VIDCONSOLE_AS_LCD
- if (strstr(stdoutname, "lcd"))
- printf("Warning: Please change 'lcd' to 'vidconsole' in stdout/stderr environment vars\n");
+ if (strstr(stdoutname, CONFIG_VIDCONSOLE_AS_LCD))
+ printf("Warning: Please change '%s' to 'vidconsole' in stdout/stderr environment vars\n",
+ CONFIG_VIDCONSOLE_AS_LCD);
#endif
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
diff --git a/common/hash.c b/common/hash.c
index 8c00659..05238a8 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -31,6 +31,7 @@
#include <u-boot/crc.h>
#include <u-boot/sha1.h>
#include <u-boot/sha256.h>
+#include <u-boot/sha512.h>
#include <u-boot/md5.h>
#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
@@ -95,6 +96,63 @@ static int hash_finish_sha256(struct hash_algo *algo, void *ctx, void
}
#endif
+#if defined(CONFIG_SHA384)
+static int hash_init_sha384(struct hash_algo *algo, void **ctxp)
+{
+ sha512_context *ctx = malloc(sizeof(sha512_context));
+ sha384_starts(ctx);
+ *ctxp = ctx;
+ return 0;
+}
+
+static int hash_update_sha384(struct hash_algo *algo, void *ctx,
+ const void *buf, unsigned int size, int is_last)
+{
+ sha384_update((sha512_context *)ctx, buf, size);
+ return 0;
+}
+
+static int hash_finish_sha384(struct hash_algo *algo, void *ctx, void
+ *dest_buf, int size)
+{
+ if (size < algo->digest_size)
+ return -1;
+
+ sha384_finish((sha512_context *)ctx, dest_buf);
+ free(ctx);
+ return 0;
+}
+#endif
+
+#if defined(CONFIG_SHA512)
+static int hash_init_sha512(struct hash_algo *algo, void **ctxp)
+{
+ sha512_context *ctx = malloc(sizeof(sha512_context));
+ sha512_starts(ctx);
+ *ctxp = ctx;
+ return 0;
+}
+
+static int hash_update_sha512(struct hash_algo *algo, void *ctx,
+ const void *buf, unsigned int size, int is_last)
+{
+ sha512_update((sha512_context *)ctx, buf, size);
+ return 0;
+}
+
+static int hash_finish_sha512(struct hash_algo *algo, void *ctx, void
+ *dest_buf, int size)
+{
+ if (size < algo->digest_size)
+ return -1;
+
+ sha512_finish((sha512_context *)ctx, dest_buf);
+ free(ctx);
+ return 0;
+}
+#endif
+
+
static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp)
{
uint16_t *ctx = malloc(sizeof(uint16_t));
@@ -196,6 +254,28 @@ static struct hash_algo hash_algo[] = {
#endif
},
#endif
+#ifdef CONFIG_SHA384
+ {
+ .name = "sha384",
+ .digest_size = SHA384_SUM_LEN,
+ .chunk_size = CHUNKSZ_SHA384,
+ .hash_func_ws = sha384_csum_wd,
+ .hash_init = hash_init_sha384,
+ .hash_update = hash_update_sha384,
+ .hash_finish = hash_finish_sha384,
+ },
+#endif
+#ifdef CONFIG_SHA512
+ {
+ .name = "sha512",
+ .digest_size = SHA512_SUM_LEN,
+ .chunk_size = CHUNKSZ_SHA512,
+ .hash_func_ws = sha512_csum_wd,
+ .hash_init = hash_init_sha512,
+ .hash_update = hash_update_sha512,
+ .hash_finish = hash_finish_sha512,
+ },
+#endif
{
.name = "crc16-ccitt",
.digest_size = 2,
@@ -218,7 +298,8 @@ static struct hash_algo hash_algo[] = {
/* Try to minimize code size for boards that don't want much hashing */
#if defined(CONFIG_SHA256) || defined(CONFIG_CMD_SHA1SUM) || \
- defined(CONFIG_CRC32_VERIFY) || defined(CONFIG_CMD_HASH)
+ defined(CONFIG_CRC32_VERIFY) || defined(CONFIG_CMD_HASH) || \
+ defined(CONFIG_SHA384) || defined(CONFIG_SHA512)
#define multi_hash() 1
#else
#define multi_hash() 0
diff --git a/common/image-fit.c b/common/image-fit.c
index 1ece100..d54eff9 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -32,6 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
#include <u-boot/md5.h>
#include <u-boot/sha1.h>
#include <u-boot/sha256.h>
+#include <u-boot/sha512.h>
/*****************************************************************************/
/* New uImage format routines */
@@ -1206,6 +1207,14 @@ int calculate_hash(const void *data, int data_len, const char *algo,
sha256_csum_wd((unsigned char *)data, data_len,
(unsigned char *)value, CHUNKSZ_SHA256);
*value_len = SHA256_SUM_LEN;
+ } else if (IMAGE_ENABLE_SHA384 && strcmp(algo, "sha384") == 0) {
+ sha384_csum_wd((unsigned char *)data, data_len,
+ (unsigned char *)value, CHUNKSZ_SHA384);
+ *value_len = SHA384_SUM_LEN;
+ } else if (IMAGE_ENABLE_SHA512 && strcmp(algo, "sha512") == 0) {
+ sha512_csum_wd((unsigned char *)data, data_len,
+ (unsigned char *)value, CHUNKSZ_SHA512);
+ *value_len = SHA512_SUM_LEN;
} else if (IMAGE_ENABLE_MD5 && strcmp(algo, "md5") == 0) {
md5_wd((unsigned char *)data, data_len, value, CHUNKSZ_MD5);
*value_len = 16;
diff --git a/common/image-sig.c b/common/image-sig.c
index 498969d..f3c209a 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -40,7 +40,31 @@ struct checksum_algo checksum_algos[] = {
.calculate_sign = EVP_sha256,
#endif
.calculate = hash_calculate,
- }
+ },
+#ifdef CONFIG_SHA384
+ {
+ .name = "sha384",
+ .checksum_len = SHA384_SUM_LEN,
+ .der_len = SHA384_DER_LEN,
+ .der_prefix = sha384_der_prefix,
+#if IMAGE_ENABLE_SIGN
+ .calculate_sign = EVP_sha384,
+#endif
+ .calculate = hash_calculate,
+ },
+#endif
+#ifdef CONFIG_SHA512
+ {
+ .name = "sha512",
+ .checksum_len = SHA512_SUM_LEN,
+ .der_len = SHA512_DER_LEN,
+ .der_prefix = sha512_der_prefix,
+#if IMAGE_ENABLE_SIGN
+ .calculate_sign = EVP_sha512,
+#endif
+ .calculate = hash_calculate,
+ },
+#endif
};
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 8ece905..d09e52e 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -412,7 +412,7 @@ config SPL_MD5_SUPPORT
secure as it is possible (with a brute-force attack) to adjust the
image while still retaining the same MD5 hash value. For secure
applications where images may be changed maliciously, you should
- consider SHA1 or SHA256.
+ consider SHA256 or SHA384.
config SPL_SHA1_SUPPORT
bool "Support SHA1"
@@ -424,7 +424,7 @@ config SPL_SHA1_SUPPORT
image contents have not been corrupted or maliciously altered.
While SHA1 is fairly secure it is coming to the end of its life
due to the expanding computing power available to brute-force
- attacks. For more security, consider SHA256.
+ attacks. For more security, consider SHA256 or SHA384.
config SPL_SHA256_SUPPORT
bool "Support SHA256"
@@ -433,12 +433,28 @@ config SPL_SHA256_SUPPORT
help
Enable this to support SHA256 in FIT images within SPL. A SHA256
checksum is a 256-bit (32-byte) hash value used to check that the
- image contents have not been corrupted. SHA256 is recommended for
- use in secure applications since (as at 2016) there is no known
- feasible attack that could produce a 'collision' with differing
- input data. Use this for the highest security. Note that only the
- SHA256 variant is supported: SHA512 and others are not currently
- supported in U-Boot.
+ image contents have not been corrupted.
+
+config SPL_SHA384_SUPPORT
+ bool "Support SHA384"
+ depends on SPL_FIT
+ select SHA384
+ select SHA512_ALGO
+ help
+ Enable this to support SHA384 in FIT images within SPL. A SHA384
+ checksum is a 384-bit (48-byte) hash value used to check that the
+ image contents have not been corrupted. Use this for the highest
+ security.
+
+config SPL_SHA512_SUPPORT
+ bool "Support SHA512"
+ depends on SPL_FIT
+ select SHA512
+ select SHA512_ALGO
+ help
+ Enable this to support SHA512 in FIT images within SPL. A SHA512
+ checksum is a 512-bit (64-byte) hash value used to check that the
+ image contents have not been corrupted.
config SPL_FIT_IMAGE_TINY
bool "Remove functionality from SPL FIT loading to reduce size"
@@ -740,6 +756,11 @@ config SPL_DM_SPI
help
Enable support for SPI DM drivers in SPL.
+config SPL_DM_SPI_FLASH
+ bool "Support SPI DM FLASH drivers in SPL"
+ help
+ Enable support for SPI DM flash drivers in SPL.
+
endif
if SPL_UBI
config SPL_UBI_LOAD_BY_VOLNAME
@@ -1076,6 +1097,11 @@ config SPL_SPI_FLASH_SFDP_SUPPORT
SPI NOR flashes using Serial Flash Discoverable Parameters (SFDP)
tables as per JESD216 standard in SPL.
+config SPL_SPI_FLASH_MTD
+ bool "Support for SPI flash MTD drivers in SPL"
+ help
+ Enable support for SPI flash MTD drivers in SPL.
+
config SPL_SPI_LOAD
bool "Support loading from SPI flash"
help
@@ -1483,6 +1509,16 @@ config TPL_SPI_SUPPORT
Enable support for using SPI in TPL. See SPL_SPI_SUPPORT for
details.
+config TPL_DM_SPI
+ bool "Support SPI DM drivers in TPL"
+ help
+ Enable support for SPI DM drivers in TPL.
+
+config TPL_DM_SPI_FLASH
+ bool "Support SPI DM FLASH drivers in TPL"
+ help
+ Enable support for SPI DM flash drivers in TPL.
+
config TPL_YMODEM_SUPPORT
bool "Support loading using Ymodem"
depends on TPL_SERIAL_SUPPORT
diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index 14f335f..3440bc0 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -79,6 +79,11 @@ void spl_invoke_opensbi(struct spl_image_info *spl_image)
invalidate_icache_all();
#ifdef CONFIG_SPL_SMP
+ /* Initialize the IPI before we use it */
+ ret = riscv_init_ipi();
+ if (ret)
+ hang();
+
/*
* Start OpenSBI on all secondary harts and wait for acknowledgment.
*