diff options
author | Luo Ji <ji.luo@nxp.com> | 2018-06-20 18:04:16 +0800 |
---|---|---|
committer | Ji Luo <ji.luo@nxp.com> | 2018-08-21 09:44:32 +0800 |
commit | a3f5218d385f29aea10b99c65c029aea5fe7d725 (patch) | |
tree | e9ba98c59b7ae15623b931d9b6efe491794364b4 /common | |
parent | 982ff85bafd291d81cdb3f4965e85b55b9770929 (diff) |
[iot] Support rollback index protection at SPL stage
Bootloader image take fit format and the rollback index for bootloader
is stored at the "rbindex" node, SPL will read the rollback index for
bootloader and compare it with the one stored in RPMB. The stored
rollback index will be updated only when current slot pass the verify
and has been marked as successful.
Bug:109947126
Test: Rollback index protection feature works fine for imx8m.
Change-Id: Ic12db4571287fbcb99e5eba0127e0b09378fa5d6
Signed-off-by: Luo Ji <ji.luo@nxp.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/spl/spl_fit.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 9f3d4c96a4e..d9bb7d55a75 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -25,6 +25,10 @@ __weak ulong board_spl_fit_size_align(ulong size) return size; } +#ifdef CONFIG_DUAL_BOOTLOADER +extern int spl_fit_get_rbindex(const void *fit, int images); +#endif + /** * spl_fit_get_image_name(): By using the matching configuration subnode, * retrieve the name of an image, specified by a property name and an index @@ -388,6 +392,16 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, return -1; } +#ifdef CONFIG_DUAL_BOOTLOADER + int rbindex; + rbindex = spl_fit_get_rbindex(fit, images); + if (rbindex < 0) { + printf("Error! Can't get rollback index!\n"); + return -1; + } else + spl_image->rbindex = rbindex; +#endif + /* * Find the U-Boot image using the following search order: * - start at 'firmware' (e.g. an ARM Trusted Firmware) |