From 259c34df294fecd1a40823e9a40f18f737a80d3e Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Tue, 4 Feb 2025 11:27:08 +0100 Subject: [PATCH] core: arm: boot: enable native interrupts before initcalls Enable native interrupts on Arm architectures when executing initcalls (early,service,driver,final). This change allows drivers to leverage interrupts during OP-TEE core initialization, as for example detecting a firewall access violation when it occurs. Before this change, OP-TEE needed to complete its initialization and return the secure monitor for secure interrupts to be handled. Note that when CFG_NS_VIRTUALIZATION is enabled, initcalls called from virt_on_stdcall() is not changed here since they are executing from a standard call entry hence with native and foreign interrupts already default unmasked. Signed-off-by: Etienne Carriere Reviewed-by: Jens Wiklander --- core/arch/arm/kernel/boot.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/arch/arm/kernel/boot.c b/core/arch/arm/kernel/boot.c index fed45015bc6..49412b5b9d1 100644 --- a/core/arch/arm/kernel/boot.c +++ b/core/arch/arm/kernel/boot.c @@ -1069,8 +1069,14 @@ void __weak boot_init_primary_late(unsigned long fdt __unused, boot_primary_init_intc(); init_vfp_nsec(); - if (!IS_ENABLED(CFG_NS_VIRTUALIZATION)) + if (!IS_ENABLED(CFG_NS_VIRTUALIZATION)) { + /* Unmask native interrupts during driver initcalls */ + thread_set_exceptions(thread_get_exceptions() & + ~THREAD_EXCP_NATIVE_INTR); init_tee_runtime(); + thread_set_exceptions(thread_get_exceptions() | + THREAD_EXCP_NATIVE_INTR); + } } /* @@ -1082,10 +1088,19 @@ void __weak boot_init_primary_final(void) if (!IS_ENABLED(CFG_WITH_PAGER)) boot_mem_release_tmp_alloc(); + /* Unmask native interrupts during init/finalcalls */ + thread_set_exceptions(thread_get_exceptions() & + ~THREAD_EXCP_NATIVE_INTR); + if (!IS_ENABLED(CFG_NS_VIRTUALIZATION)) call_driver_initcalls(); + call_finalcalls(); + IMSG("Primary CPU switching to normal world boot"); + + thread_set_exceptions(thread_get_exceptions() | + THREAD_EXCP_NATIVE_INTR); } static void init_secondary_helper(unsigned long nsec_entry)