Skip to content

Commit c90f6c4

Browse files
57300nordicjm
authored andcommitted
nrf_security: IRONside call for PSA Crypto
Continuation of 1b2abb0. Swap out the IPC service integration for an IRONside call, with minimal refactoring. Signed-off-by: Grzegorz Swiderski <[email protected]>
1 parent 8512f01 commit c90f6c4

File tree

11 files changed

+30
-134
lines changed

11 files changed

+30
-134
lines changed

include/tfm/ironside/se/ipc_service.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ enum {
1717
IRONSIDE_SE_IPC_INDEX_IN_LEN,
1818
IRONSIDE_SE_IPC_INDEX_OUT_VEC,
1919
IRONSIDE_SE_IPC_INDEX_OUT_LEN,
20-
IRONSIDE_SE_IPC_INDEX_STATUS_PTR,
20+
IRONSIDE_SE_IPC_INDEX_STATUS,
2121
/* The last enum value is reserved for the size of the IPC buffer */
2222
IRONSIDE_SE_IPC_DATA_LEN
2323
};
2424

25+
/* IRONside call identifiers with implicit versions.
26+
*
27+
* With the initial "version 0", the service ABI is allowed to break until the
28+
* first public release of IRONside SE.
29+
*/
30+
#define IRONSIDE_CALL_ID_PSA_CRYPTO_V0 0
31+
2532
/* We are adding the source files for the TF-M crypto partition to the build.
2633
*
2734
* The crypto partition will include the file psa_manifest/sid.h and

samples/crypto/sha256/boards/nrf54h20dk_nrf54h20_cpuapp_iron.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
99

1010
# Enable PSA crypto from SSF client
1111
CONFIG_PSA_SSF_CRYPTO_CLIENT=y
12-
CONFIG_SSF_PSA_CRYPTO_SERVICE_ENABLED=y
1312

1413
# Mbedtls configuration
1514
CONFIG_MBEDTLS_ENABLE_HEAP=y

subsys/nrf_security/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ rsource "Kconfig.psa.nordic"
5555
config PSA_PROMPTLESS
5656
bool
5757

58-
config SSF_V_2
59-
bool
60-
default y if BOARD_NRF54H20DK_NRF54H20_CPUAPP_IRON
61-
prompt "temporary option until iron and SSFv2 is available"
62-
select MBOX
63-
select IPC_SERVICE
64-
6558
if NRF_SECURITY
6659

6760
config MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS

subsys/nrf_security/src/ssf_secdom/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
if(CONFIG_SSF_V_2)
7+
if(CONFIG_NRF_IRONSIDE_CALL)
88
zephyr_library()
99
zephyr_library_sources(
1010
# ironside_psa_ns_api.c provides psa_call. psa_call is invoked by
1111
# serialized functions from tfm_crypto_api.c and sends a message
1212
# over IPC.
1313
${CMAKE_CURRENT_LIST_DIR}/ironside_se_psa_ns_api.c
14-
# ironside_se_psa_ns_ipc.c provides an IPC service to ironside_se_psa_ns_api.c
15-
${CMAKE_CURRENT_LIST_DIR}/ironside_se_psa_ns_ipc.c
1614
# tfm_crypto_api.c provides and serializes the PSA Crypto API.
1715
${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/interface/src/tfm_crypto_api.c
1816
)

subsys/nrf_security/src/ssf_secdom/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ config PSA_SSF_CRYPTO_CLIENT
88
bool
99
prompt "PSA crypto provided through SSF"
1010
default y
11-
depends on (SSF_CLIENT || SSF_V_2) && SSF_PSA_CRYPTO_SERVICE_ENABLED
11+
depends on (SSF_CLIENT && SSF_PSA_CRYPTO_SERVICE_ENABLED) || SOC_NRF54H20_IRON
12+
select NRF_IRONSIDE_CALL if !SSF_CLIENT
1213

1314
if PSA_SSF_CRYPTO_CLIENT
1415

subsys/nrf_security/src/ssf_secdom/ironside_se_psa_ns_api.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
#include <zephyr/kernel.h>
1111
#include <zephyr/cache.h>
12+
#include <zephyr/drivers/firmware/nrf_ironside/call.h>
1213

1314
#include <psa/client.h>
1415
#include <psa/error.h>
1516

1617
#include <tfm/ironside/se/ipc_service.h>
1718

18-
#include "ironside_se_psa_ns_ipc.h"
1919
#include "bounce_buffers.h"
2020

2121
/* The correctness of the serialization depends on these asserts */
@@ -33,38 +33,26 @@ static psa_status_t psa_call_buffered_and_flushed(psa_handle_t handle, int32_t t
3333
/* We have no need for this at this time */
3434
ARG_UNUSED(type);
3535

36-
psa_status_t ipc_status = ironside_se_psa_ns_ipc_setup();
36+
struct ironside_call_buf *const buf = ironside_call_alloc();
3737

38-
if (ipc_status != PSA_SUCCESS) {
39-
return ipc_status;
40-
}
41-
42-
/* volatile and flushed because the cpusec core will usually
43-
* modify this variable
44-
*/
45-
psa_status_t volatile status = PSA_ERROR_COMMUNICATION_FAILURE;
46-
47-
sys_cache_data_flush_range((void *)&status, sizeof(status));
38+
buf->id = IRONSIDE_CALL_ID_PSA_CRYPTO_V0;
4839

49-
uint32_t ipc_service_buf[IRONSIDE_SE_IPC_DATA_LEN];
50-
51-
ipc_service_buf[IRONSIDE_SE_IPC_INDEX_HANDLE] =
40+
buf->args[IRONSIDE_SE_IPC_INDEX_HANDLE] =
5241
handle; /* i.e. TFM_CRYPTO_HANDLE defined to 0x40000100U */
53-
ipc_service_buf[IRONSIDE_SE_IPC_INDEX_IN_VEC] = (uint32_t)in_vec;
54-
ipc_service_buf[IRONSIDE_SE_IPC_INDEX_IN_LEN] = in_len;
55-
ipc_service_buf[IRONSIDE_SE_IPC_INDEX_OUT_VEC] = (uint32_t)out_vec;
56-
ipc_service_buf[IRONSIDE_SE_IPC_INDEX_OUT_LEN] = out_len;
57-
ipc_service_buf[IRONSIDE_SE_IPC_INDEX_STATUS_PTR] = (uint32_t)&status;
42+
buf->args[IRONSIDE_SE_IPC_INDEX_IN_VEC] = (uint32_t)in_vec;
43+
buf->args[IRONSIDE_SE_IPC_INDEX_IN_LEN] = in_len;
44+
buf->args[IRONSIDE_SE_IPC_INDEX_OUT_VEC] = (uint32_t)out_vec;
45+
buf->args[IRONSIDE_SE_IPC_INDEX_OUT_LEN] = out_len;
46+
47+
ironside_call_dispatch(buf);
5848

59-
int32_t ret = ironside_se_psa_ns_ipc_send(ipc_service_buf, sizeof(ipc_service_buf));
49+
psa_status_t status = PSA_ERROR_COMMUNICATION_FAILURE;
6050

61-
if (ret != sizeof(ipc_service_buf)) {
62-
return PSA_ERROR_COMMUNICATION_FAILURE;
51+
if (buf->status == IRONSIDE_CALL_STATUS_RSP_SUCCESS) {
52+
status = buf->args[IRONSIDE_SE_IPC_INDEX_STATUS];
6353
}
6454

65-
do {
66-
sys_cache_data_flush_and_invd_range((void *)&status, sizeof(status));
67-
} while (status == PSA_ERROR_COMMUNICATION_FAILURE);
55+
ironside_call_release(buf);
6856

6957
return status;
7058
}

subsys/nrf_security/src/ssf_secdom/ironside_se_psa_ns_ipc.c

Lines changed: 0 additions & 61 deletions
This file was deleted.

subsys/nrf_security/src/ssf_secdom/ironside_se_psa_ns_ipc.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

subsys/sdfw_services/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ rsource "services/Kconfig"
88

99
config SSF_CLIENT
1010
bool
11-
default (! SSF_V_2) && ($(dt_nodelabel_enabled_with_compat,cpusec_cpuapp_ipc,$(DT_COMPAT_ZEPHYR_IPC_ICMSG)) \
12-
|| $(dt_nodelabel_enabled_with_compat,cpusec_cpurad_ipc,$(DT_COMPAT_ZEPHYR_IPC_ICMSG)))
11+
def_bool $(dt_nodelabel_enabled_with_compat,cpusec_cpuapp_ipc,$(DT_COMPAT_ZEPHYR_IPC_ICMSG)) \
12+
|| $(dt_nodelabel_enabled_with_compat,cpusec_cpurad_ipc,$(DT_COMPAT_ZEPHYR_IPC_ICMSG))
13+
depends on !SOC_NRF54H20_IRON
1314

1415
config SDFW_SERVICES_ENABLED
1516
bool

subsys/sdfw_services/services/Kconfig.template.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
menuconfig SSF_$(service_name)_SERVICE_ENABLED
2323
bool "$(service_name_str) service"
2424
default y if $(service_default_enabled)
25-
depends on SDFW_SERVICES_ENABLED || SSF_V_2
25+
depends on SDFW_SERVICES_ENABLED
2626

2727
if SSF_$(service_name)_SERVICE_ENABLED
2828

0 commit comments

Comments
 (0)