Skip to content

Commit f4ab165

Browse files
committed
soc: ironside: add min and max values for update
The update will fail if the address is outside of this range. This failure might trigger a bad state where the device is non-trivial to recover. Signed-off-by: Håkon Amundsen <[email protected]>
1 parent 36bc2f3 commit f4ab165

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

samples/boards/nordic/nrf_ironside/update/src/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
1212

13+
BUILD_ASSERT(CONFIG_UPDATE_BLOB_ADDRESS >= IRONSIDE_UPDATE_MIN_ADDRESS);
14+
BUILD_ASSERT(CONFIG_UPDATE_BLOB_ADDRESS <= IRONSIDE_UPDATE_MAX_ADDRESS);
15+
1316
int main(void)
1417
{
1518
int err;

soc/nordic/ironside/include/nrf_ironside/update.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,27 @@
1818
#define IRONSIDE_UPDATE_ERROR_NOT_PERMITTED (1)
1919
/** Failed to write the update metadata to SICR. */
2020
#define IRONSIDE_UPDATE_ERROR_SICR_WRITE_FAILED (2)
21+
/** Update candidate is placed outside of valid range */
22+
#define IRONSIDE_UPDATE_ERROR_INVALID_ADDRESS (3)
2123

2224
/**
2325
* @}
2426
*/
2527

28+
/** Size of the update blob */
29+
#ifdef CONFIG_SOC_SERIES_NRF54HX
30+
#define IRONSIDE_UPDATE_BLOB_SIZE (160 * 1024)
31+
#elif CONFIG_SOC_SERIES_NRF92X
32+
#define IRONSIDE_UPDATE_BLOB_SIZE (160 * 1024)
33+
#else
34+
#error "Missing update blob size"
35+
#endif
36+
37+
/** Min address used for storing the update candidate */
38+
#define IRONSIDE_UPDATE_MIN_ADDRESS (0x0e100000)
39+
/** Max address used for storing the update candidate */
40+
#define IRONSIDE_UPDATE_MAX_ADDRESS (0x0e200000 - IRONSIDE_UPDATE_BLOB_SIZE)
41+
2642
/** Length of the update manifest in bytes */
2743
#define IRONSIDE_UPDATE_MANIFEST_LENGTH (256)
2844
/** Length of the update public key in bytes. */
@@ -62,6 +78,8 @@ struct ironside_update_blob {
6278
* @param update Pointer to update blob
6379
*
6480
* @retval 0 on a successful request (although the update itself may still fail).
81+
* @retval -IRONSIDE_UPDATE_ERROR_INVALID_ADDRESS if the address of the update is outside of the
82+
* accepted range.
6583
* @retval -IRONSIDE_UPDATE_ERROR_NOT_PERMITTED if missing access to the update candidate.
6684
* @retval -IRONSIDE_UPDATE_ERROR_SICR_WRITE_FAILED if writing update parameters to SICR failed.
6785
* @retval Positive error status if reported by IronSide call (see error codes in @ref call.h).

soc/nordic/ironside/update.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ int ironside_update(const struct ironside_update_blob *update)
1111
int err;
1212
struct ironside_call_buf *const buf = ironside_call_alloc();
1313

14+
if ((uintptr_t)update < IRONSIDE_UPDATE_MIN_ADDRESS ||
15+
(uintptr_t)update > IRONSIDE_UPDATE_MAX_ADDRESS) {
16+
return -IRONSIDE_UPDATE_ERROR_INVALID_ADDRESS;
17+
}
18+
1419
buf->id = IRONSIDE_CALL_ID_UPDATE_SERVICE_V0;
1520
buf->args[IRONSIDE_UPDATE_SERVICE_UPDATE_PTR_IDX] = (uintptr_t)update;
1621

0 commit comments

Comments
 (0)