GCC/Release: Compiler optimizes tfm_core_ns_ipc_request() too much
Open, Needs TriagePublic

Description

tfm_core_ns_ipc_request() in tfm_psa_api_client.c has an inline assembly block which calls SVC with the arguments inside a descriptor struct.
In GCC release the compiler optimizes the code (probably ignores the inline assembly code) and throws the part where the arguments are set inside the descriptor struct.
The result is that the descriptor is all zeroes and sent to the SVC via r0.

Eventually in the SVC handler tfm_psa_veneer_sanity_check() is called which returns TFM_ERROR_INVALID_PARAMETER (becasue desc_ptr->ns_caller is 0).

mikisch81 created this task.Tue, Feb 5, 7:58 AM
mikisch81 added a subscriber: KenLSoft.

A workaround for us which fixed this issue was setting the descriptor struct volatile:

volatile struct tfm_sfn_req_s desc;
struct tfm_sfn_req_s *desc_ptr = &desc;