Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plat-stm32: SCMI reset controllers on remoteproc are disabled on secure fmw loading #7106

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions core/arch/arm/plat-stm32mp1/scmi_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <drivers/rstctrl.h>
#include <drivers/scmi-msg.h>
#include <drivers/scmi.h>
#include <drivers/stm32_remoteproc.h>
#include <drivers/stm32_vrefbuf.h>
#include <drivers/stm32mp1_pmic.h>
#include <drivers/stm32mp1_pwr.h>
Expand Down Expand Up @@ -535,11 +536,14 @@ int32_t plat_scmi_rd_autonomous(unsigned int channel_id, unsigned int scmi_id,

if (!rd->rstctrl || !stm32mp_nsec_can_access_reset(rd->reset_id))
return SCMI_DENIED;
assert(rd->rstctrl);

#ifdef CFG_STM32MP15
/* Reset cycle on MCU hold boot is not supported */
if (rd->reset_id == MCU_HOLD_BOOT_R)
return SCMI_NOT_SUPPORTED;
/* Remoteproc driver may handle all MCU reset controllers */
if (rd->reset_id == MCU_R && stm32_rproc_is_secure(STM32_M4_RPROC_ID))
return SCMI_DENIED;
#endif

/* Supports only reset with context loss */
Expand Down Expand Up @@ -568,7 +572,13 @@ int32_t plat_scmi_rd_set_state(unsigned int channel_id, unsigned int scmi_id,

if (!rd->rstctrl || !stm32mp_nsec_can_access_reset(rd->reset_id))
return SCMI_DENIED;
assert(rd->rstctrl);

#ifdef CFG_STM32MP15
/* Remoteproc driver may handle all MCU reset controllers */
if ((rd->reset_id == MCU_R || rd->reset_id == MCU_HOLD_BOOT_R) &&
stm32_rproc_is_secure(STM32_M4_RPROC_ID))
return SCMI_DENIED;
#endif

if (assert_not_deassert) {
FMSG("SCMI reset %u set", scmi_id);
Expand Down
13 changes: 13 additions & 0 deletions core/drivers/remoteproc/stm32_remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct stm32_rproc_mem {
* @regions: memory regions used
* @mcu_rst: remote processor reset control
* @hold_boot: remote processor hold boot control
* @ns_loading: True if supports non-secure firmware loading, false otherwise
*/
struct stm32_rproc_instance {
const struct stm32_rproc_compat_data *cdata;
Expand All @@ -47,6 +48,7 @@ struct stm32_rproc_instance {
struct stm32_rproc_mem *regions;
struct rstctrl *mcu_rst;
struct rstctrl *hold_boot;
bool ns_loading;
};

/**
Expand All @@ -72,6 +74,16 @@ void *stm32_rproc_get(uint32_t rproc_id)
return rproc;
}

bool stm32_rproc_is_secure(uint32_t rproc_id)
{
struct stm32_rproc_instance *rproc = stm32_rproc_get(rproc_id);

if (rproc)
return !rproc->cdata->ns_loading;

return false;
}

TEE_Result stm32_rproc_start(uint32_t rproc_id)
{
struct stm32_rproc_instance *rproc = stm32_rproc_get(rproc_id);
Expand Down Expand Up @@ -400,6 +412,7 @@ static TEE_Result stm32_rproc_probe(const void *fdt, int node,

static const struct stm32_rproc_compat_data stm32_rproc_m4_compat = {
.rproc_id = STM32_M4_RPROC_ID,
.ns_loading = false,
};

static const struct dt_device_match stm32_rproc_match_table[] = {
Expand Down
10 changes: 10 additions & 0 deletions core/include/drivers/stm32_remoteproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ TEE_Result stm32_rproc_stop(uint32_t rproc_id);
*/
TEE_Result stm32_rproc_clean_up_memories(uint32_t rproc_id);

#ifdef CFG_STM32MP_REMOTEPROC
/* Return true is secure loading of remoteproc firmware is enabled */
bool stm32_rproc_is_secure(uint32_t rproc_id);
#else
static inline bool stm32_rproc_is_secure(uint32_t rproc_id __unused)
{
return false;
}
#endif

#endif /* __DRIVERS_STM32_REMOTEPROC_H */