Skip to content

Commit 20f8d86

Browse files
SebastianBoerlubos
authored andcommitted
[nrf noup] treewide: add NCS partition manager support
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 <[email protected]>
1 parent 78fd7ff commit 20f8d86

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

boot/bootutil/src/loader.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,15 +2269,12 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
22692269

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

0 commit comments

Comments
 (0)