From df48ea221b53bc89dd4c1684366bcada953f354b Mon Sep 17 00:00:00 2001 From: Michele Sardo Date: Sat, 12 Jul 2025 19:27:17 +0200 Subject: [PATCH 1/3] arch: arm: coterx_m: Added some #include in fpu.h Added missing #include for used types uint32_t and bool in file fpu.h Signed-off-by: Michele Sardo --- include/zephyr/arch/arm/cortex_m/fpu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/zephyr/arch/arm/cortex_m/fpu.h b/include/zephyr/arch/arm/cortex_m/fpu.h index cf01fddf4f938..225a4005bb153 100644 --- a/include/zephyr/arch/arm/cortex_m/fpu.h +++ b/include/zephyr/arch/arm/cortex_m/fpu.h @@ -7,6 +7,9 @@ #ifndef ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_M_FPU_H_ #define ZEPHYR_INCLUDE_ARCH_ARM_CORTEX_M_FPU_H_ +#include +#include + struct fpu_ctx_full { uint32_t caller_saved[16]; uint32_t callee_saved[16]; From cc12f0ffe24103624d7358ad6a5924387b0dbaf1 Mon Sep 17 00:00:00 2001 From: Michele Sardo Date: Mon, 14 Jul 2025 22:50:28 +0200 Subject: [PATCH 2/3] arch: arm: cortex_m: Modifed FPU save and restore helpers z_arm_save_fp_context and z_arm_restore_fp_context save and restore fpu context regardless of the CONFIG_FPU_SHARING setting. This modification is required to support suspend to ram use cases where save and restore of FPU state is needed to ensure proper bahaviour after wakeup. Signed-off-by: Michele Sardo --- arch/arm/core/cortex_m/fpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/core/cortex_m/fpu.c b/arch/arm/core/cortex_m/fpu.c index b937d725c2834..0b8499afd6edc 100644 --- a/arch/arm/core/cortex_m/fpu.c +++ b/arch/arm/core/cortex_m/fpu.c @@ -16,7 +16,7 @@ void z_arm_save_fp_context(struct fpu_ctx_full *buffer) { -#if defined(CONFIG_FPU_SHARING) +#if defined(CONFIG_FPU) __ASSERT_NO_MSG(buffer != NULL); uint32_t CONTROL = __get_CONTROL(); @@ -44,7 +44,7 @@ void z_arm_save_fp_context(struct fpu_ctx_full *buffer) void z_arm_restore_fp_context(const struct fpu_ctx_full *buffer) { -#if defined(CONFIG_FPU_SHARING) +#if defined(CONFIG_FPU) if (buffer->ctx_saved) { /* Set FPCA first so it is set even if an interrupt happens * during restoration. From 4dd3bd688f01fdf707ba893ad8ead9ea6080f060 Mon Sep 17 00:00:00 2001 From: Michele Sardo Date: Mon, 14 Jul 2025 22:54:56 +0200 Subject: [PATCH 3/3] modules: trusted-firmware-m: Update in interface implementation Following changes to arch/arm/core/cortex_m/fpu.c, the dependency on CONFIG_FPU_SHARING is moved into this file. Signed-off-by: Michele Sardo --- modules/trusted-firmware-m/interface/interface.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/trusted-firmware-m/interface/interface.c b/modules/trusted-firmware-m/interface/interface.c index abff7efdc72f5..027985b9e9b99 100644 --- a/modules/trusted-firmware-m/interface/interface.c +++ b/modules/trusted-firmware-m/interface/interface.c @@ -53,13 +53,17 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn, #endif } +#if defined(CONFIG_FPU_SHARING) struct fpu_ctx_full context_buffer; z_arm_save_fp_context(&context_buffer); +#endif result = fn(arg0, arg1, arg2, arg3); +#if defined(CONFIG_FPU_SHARING) z_arm_restore_fp_context(&context_buffer); +#endif if (!isr_mode) { #if !defined(CONFIG_ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS)