[PATCH u-boot-marvell 5/5] arm: mvebu: Check for kwbimage data checksum
Stefan Roese
sr at denx.de
Mon Nov 15 10:10:35 CET 2021
On 11/11/21 16:59, Marek Behún wrote:
> From: Pali Rohár <pali at kernel.org>
>
> Last 4 bytes of kwbimage boot image is checksum. Verify it via the new
> spl_check_board_image() function which is called by U-Boot SPL after
> loading kwbimage.
>
> Signed-off-by: Pali Rohár <pali at kernel.org>
> Signed-off-by: Marek Behún <marek.behun at nic.cz>
> ---
> arch/arm/mach-mvebu/spl.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index 662f430503..f0b84167b9 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -100,6 +100,34 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
> }
> #endif
>
> +static uint32_t checksum32(void *start, uint32_t len)
> +{
> + uint32_t csum = 0;
> + uint32_t *p = start;
Just curious: Doesn't checkpatch complain about using uint32_t instead
of u32?
Other than this:
Reviewed-by: Stefan Roese <sr at denx.de>
Thanks,
Stefan
> +
> + while (len > 0) {
> + csum += *p++;
> + len -= sizeof(uint32_t);
> + };
> +
> + return csum;
> +}
> +
> +int spl_check_board_image(struct spl_image_info *spl_image,
> + const struct spl_boot_device *bootdev)
> +{
> + uint32_t csum = *(uint32_t *)(spl_image->load_addr +
> + spl_image->size - 4);
> +
> + if (checksum32((void *)spl_image->load_addr,
> + spl_image->size - 4) != csum) {
> + printf("ERROR: Invalid data checksum in kwbimage\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> int spl_parse_board_header(struct spl_image_info *spl_image,
> const struct spl_boot_device *bootdev,
> const void *image_header, size_t size)
>
Viele Grüße,
Stefan Roese
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
More information about the U-Boot
mailing list