Skip to content

Commit

Permalink
[nrf noup] treewide: add NCS partition manager support
Browse files Browse the repository at this point in the history
fixup! [nrf noup] treewide: add NCS partition manager support

The comment correctly states that we should skip the check for image
1, but the code skips validation for all images except image 0.

Today it is only supported for two images, 0 and 1, but in the future
it is expected that there might be an image 2, so we refactor this
code to make it future-proof.

Also, the comment was confusing and misleading so it has been
re-written.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
  • Loading branch information
SebastianBoe authored and rlubos committed Dec 12, 2022
1 parent 78fd7ff commit 20f8d86
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2269,15 +2269,12 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)

#ifdef MCUBOOT_VALIDATE_PRIMARY_SLOT
#ifdef PM_S1_ADDRESS
/* Patch needed for NCS. If secure boot is enabled, then mcuboot
* will be stored in either partition S0 or S1. Image 1 primary
* will point to the 'other' Sx partition. Hence, image 1 primary
* does not contain a valid image until mcuboot has been upgraded.
* Note that B0 will perform validation of the active mcuboot image,
* so there is no security lost by skipping this check for image 1
* primary.
/* Patch needed for NCS. Image 1 primary is the currently
* executing MCUBoot image, and is therefore already trusted and
* does not need validation.
*/
if (BOOT_CURR_IMG(state) == 0)
bool image_needs_validation = BOOT_CURR_IMG(state) != 1;
if (image_needs_validation)
#endif
{
FIH_CALL(boot_validate_slot, fih_rc, state, BOOT_PRIMARY_SLOT, NULL);
Expand Down

0 comments on commit 20f8d86

Please sign in to comment.