[PATCH u-boot-marvell v3 3/9] arm: mvebu: Check that kwbimage blockid matches boot mode
Marek Behún
kabel at kernel.org
Tue Dec 14 14:22:16 CET 2021
From: Pali Rohár <pali at kernel.org>
Each boot mode has its own kwbimage specified by blockid. So check that
kwbimage is valid by blockid.
Signed-off-by: Pali Rohár <pali at kernel.org>
Signed-off-by: Marek Behún <marek.behun at nic.cz>
Reviewed-by: Stefan Roese <sr at denx.de>
---
arch/arm/mach-mvebu/spl.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 716217083b..4af52c626c 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -118,22 +118,39 @@ int spl_parse_board_header(struct spl_image_info *spl_image,
* (including SPL content) which is not included in U-Boot image_header.
*/
if (mhdr->version != 1 ||
- ((mhdr->headersz_msb << 16) | mhdr->headersz_lsb) < sizeof(*mhdr) ||
- (
+ ((mhdr->headersz_msb << 16) | mhdr->headersz_lsb) < sizeof(*mhdr)) {
+ printf("ERROR: Invalid kwbimage v1\n");
+ return -EINVAL;
+ }
+
#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
- mhdr->blockid != IBR_HDR_SPI_ID &&
+ if (bootdev->boot_device == BOOT_DEVICE_SPI &&
+ mhdr->blockid != IBR_HDR_SPI_ID) {
+ printf("ERROR: Wrong blockid (%u) in SPI kwbimage\n",
+ mhdr->blockid);
+ return -EINVAL;
+ }
#endif
+
#ifdef CONFIG_SPL_SATA
- mhdr->blockid != IBR_HDR_SATA_ID &&
+ if (bootdev->boot_device == BOOT_DEVICE_SATA &&
+ mhdr->blockid != IBR_HDR_SATA_ID) {
+ printf("ERROR: Wrong blockid (%u) in SATA kwbimage\n",
+ mhdr->blockid);
+ return -EINVAL;
+ }
#endif
+
#ifdef CONFIG_SPL_MMC
- mhdr->blockid != IBR_HDR_SDIO_ID &&
-#endif
- 1
- )) {
- printf("ERROR: Not valid SPI/NAND/SATA/SDIO kwbimage v1\n");
+ if ((bootdev->boot_device == BOOT_DEVICE_MMC1 ||
+ bootdev->boot_device == BOOT_DEVICE_MMC2 ||
+ bootdev->boot_device == BOOT_DEVICE_MMC2_2) &&
+ mhdr->blockid != IBR_HDR_SDIO_ID) {
+ printf("ERROR: Wrong blockid (%u) in SDIO kwbimage\n",
+ mhdr->blockid);
return -EINVAL;
}
+#endif
spl_image->offset = mhdr->srcaddr;
--
2.32.0
More information about the U-Boot
mailing list