Skip to content

Commit

Permalink
drivers: stm32_rif: add stm32_rif_access_violation_action()
Browse files Browse the repository at this point in the history
This function should be used by peripherals capable on raising
access violation interrupts (SERC, IAC). The behavior of the platform
on such event is platform-specific. Therefore, its definition must be
done at platform level.

Also add CFG_STM32_PANIC_ON_IAC_EVENT and CFG_STM32_PANIC_ON_SERC_EVENT
to choose if the platform should panic upon receiving an IAC or a
SERC event.

Signed-off-by: Gatien Chevallier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
  • Loading branch information
GseoC authored and jforissier committed Aug 23, 2024
1 parent b374f48 commit 1c32a0e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
8 changes: 8 additions & 0 deletions core/arch/arm/plat-stm32mp2/conf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ ifeq ($(CFG_STM32MP25_RSTCTRL),y)
$(call force,CFG_DRIVERS_RSTCTRL,y)
$(call force,CFG_STM32_RSTCTRL,y)
endif

# Optional behavior upon receiving illegal access events
CFG_STM32_PANIC_ON_IAC_EVENT ?= y
ifeq ($(CFG_TEE_CORE_DEBUG),y)
CFG_STM32_PANIC_ON_SERC_EVENT ?= n
else
CFG_STM32_PANIC_ON_SERC_EVENT ?= y
endif
7 changes: 7 additions & 0 deletions core/arch/arm/plat-stm32mp2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <config.h>
#include <console.h>
#include <drivers/gic.h>
#include <drivers/stm32_rif.h>
#include <drivers/stm32_uart.h>
#include <initcall.h>
#include <kernel/boot.h>
Expand Down Expand Up @@ -149,3 +150,9 @@ void boot_secondary_init_intc(void)
{
gic_init_per_cpu();
}

#ifdef CFG_STM32_RIF
void stm32_rif_access_violation_action(void)
{
}
#endif /* CFG_STM32_RIF */
10 changes: 3 additions & 7 deletions core/drivers/firewall/stm32_iac.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ static TEE_Result stm32_iac_parse_fdt(const void *fdt, int node)
return TEE_SUCCESS;
}

static __noreturn void access_violation_action(void)
{
DMSG("Ooops...");
panic();
}

static enum itr_return stm32_iac_itr(struct itr_handler *h __unused)
{
struct iac_driver_data *ddata = iac_dev.ddata;
Expand Down Expand Up @@ -183,7 +177,9 @@ static enum itr_return stm32_iac_itr(struct itr_handler *h __unused)
}
}

access_violation_action();
stm32_rif_access_violation_action();
if (IS_ENABLED(CFG_STM32_PANIC_ON_IAC_EVENT))
panic();

return ITRR_HANDLED;
}
Expand Down
10 changes: 3 additions & 7 deletions core/drivers/firewall/stm32_serc.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ struct serc_device {

static struct serc_device serc_dev;

static __noreturn void access_violation_action(void)
{
DMSG("Ooops...");
panic();
}

static void stm32_serc_get_hwdata(void)
{
struct stm32_serc_platdata *pdata = &serc_dev.pdata;
Expand Down Expand Up @@ -179,7 +173,9 @@ static void stm32_serc_handle_ilac(void)
}
}

access_violation_action();
stm32_rif_access_violation_action();
if (IS_ENABLED(CFG_STM32_PANIC_ON_SERC_EVENT))
panic();
}

static enum itr_return stm32_serc_itr(struct itr_handler *h __unused)
Expand Down
10 changes: 10 additions & 0 deletions core/include/drivers/stm32_rif.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ TEE_Result stm32_rif_acquire_semaphore(vaddr_t addr,
*/
TEE_Result stm32_rif_release_semaphore(vaddr_t addr,
unsigned int nb_cid_supp);

/*
* The action to take upon an access violation depends on the platform.
* Therefore, it should be defined at platform level.
*/
void stm32_rif_access_violation_action(void);
#else
static inline bool stm32_rif_scid_ok(uint32_t cidcfgr, uint32_t scid_m,
uint32_t cid_to_check)
Expand Down Expand Up @@ -220,5 +226,9 @@ stm32_rif_release_semaphore(vaddr_t addr __unused,
{
return TEE_SUCCESS;
}

static inline void stm32_rif_access_violation_action(void)
{
}
#endif /* CFG_STM32_RIF */
#endif /* __DRIVERS_STM32_RIF_H */

0 comments on commit 1c32a0e

Please sign in to comment.