summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mvebu
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2022-01-14 14:31:39 +0100
committerStefan Roese <sr@denx.de>2022-01-20 11:35:29 +0100
commitf830703f4284a0e28e7060b85e659c619a0d8e23 (patch)
tree0a1c5aa3801c913f0fa9b1d2f1e5566ea9d7370d /arch/arm/mach-mvebu
parent2e0429bcc1a9cf2c3b4cc0e8af7199f031a3b8e9 (diff)
downloadu-boot-f830703f4284a0e28e7060b85e659c619a0d8e23.tar.gz
u-boot-f830703f4284a0e28e7060b85e659c619a0d8e23.tar.bz2
u-boot-f830703f4284a0e28e7060b85e659c619a0d8e23.zip
arm: mvebu: Check that kwbimage blockid matches boot mode
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@kernel.org> Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'arch/arm/mach-mvebu')
-rw-r--r--arch/arm/mach-mvebu/spl.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index fe22951e16..62e4fe12d6 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -117,22 +117,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 (0x%x) 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 (0x%x) 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 (0x%x) in SDIO kwbimage\n",
+ mhdr->blockid);
return -EINVAL;
}
+#endif
spl_image->offset = mhdr->srcaddr;