Skip to content

Commit

Permalink
feat(st): disable authentication based on part_number
Browse files Browse the repository at this point in the history
STM32MP15xA and STM32MP15xD chip part numbers don't
support the secure boot.
All functions linked to secure boot must not be used
and signed binaries are not allowed on such chip.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Change-Id: I5b85f322f5eb3b64415e1819bd00fb2c99f20695
  • Loading branch information
ldebieve authored and Yann-lms committed Feb 1, 2022
1 parent 884a650 commit 49abdfd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions plat/st/common/include/stm32mp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ uint16_t stm32mp_get_boot_itf_selected(void);

bool stm32mp_is_single_core(void);
bool stm32mp_is_closed_device(void);
bool stm32mp_is_auth_supported(void);

/* Return the base address of the DDR controller */
uintptr_t stm32mp_ddrctrl_base(void);
Expand Down
5 changes: 5 additions & 0 deletions plat/st/common/stm32mp_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ int stm32mp_auth_image(boot_api_image_header_t *header, uintptr_t buffer)
INFO("Check signature on Open device\n");
}

if (auth_ops == NULL) {
ERROR("Device doesn't support image authentication\n");
return -EOPNOTSUPP;
}

ret = mmap_add_dynamic_region(STM32MP_ROM_BASE, STM32MP_ROM_BASE,
STM32MP_ROM_SIZE_2MB_ALIGNED, MT_CODE | MT_SECURE);
if (ret != 0) {
Expand Down
11 changes: 7 additions & 4 deletions plat/st/stm32mp1/bl2_plat_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,14 @@ void bl2_el3_plat_arch_setup(void)

stm32_iwdg_refresh();

stm32mp1_auth_ops.check_key = boot_context->bootrom_ecdsa_check_key;
stm32mp1_auth_ops.verify_signature =
boot_context->bootrom_ecdsa_verify_signature;
if (stm32mp_is_auth_supported()) {
stm32mp1_auth_ops.check_key =
boot_context->bootrom_ecdsa_check_key;
stm32mp1_auth_ops.verify_signature =
boot_context->bootrom_ecdsa_verify_signature;

stm32mp_init_auth(&stm32mp1_auth_ops);
stm32mp_init_auth(&stm32mp1_auth_ops);
}

stm32mp1_arch_security_setup();

Expand Down
21 changes: 21 additions & 0 deletions plat/st/stm32mp1/stm32mp1_private.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,27 @@ bool stm32mp_is_closed_device(void)
return (value & CFG0_CLOSED_DEVICE) == CFG0_CLOSED_DEVICE;
}

/* Return true when device supports secure boot */
bool stm32mp_is_auth_supported(void)
{
bool supported = false;

switch (get_part_number()) {
case STM32MP151C_PART_NB:
case STM32MP151F_PART_NB:
case STM32MP153C_PART_NB:
case STM32MP153F_PART_NB:
case STM32MP157C_PART_NB:
case STM32MP157F_PART_NB:
supported = true;
break;
default:
break;
}

return supported;
}

uint32_t stm32_iwdg_get_instance(uintptr_t base)
{
switch (base) {
Expand Down

0 comments on commit 49abdfd

Please sign in to comment.