blob: aa389d8bc01487d96a8772452f8b9315c5bee18f [file] [log] [blame]
Brad Bishopbec4ebc2022-08-03 09:55:16 -04001From 90006cecbbba58afee5f51e6bd72f7027a257b5e Mon Sep 17 00:00:00 2001
2From: Satish Kumar <satish.kumar01@arm.com>
3Date: Thu, 9 Dec 2021 14:11:06 +0000
4Subject: [PATCH] Setup its backend as openamp rpc using secure storage ipc
5 implementation.
6
7Signed-off-by: Rui Miguel Silva <rui.silva@arm.com>
8Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
9
10Upstream-Status: Pending [Not submitted to upstream yet]
11Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
12
13
14---
15 components/service/common/include/psa/sid.h | 12 +++++-----
16 .../secure_storage_ipc/secure_storage_ipc.c | 20 ++++++++---------
17 .../secure_storage_ipc/secure_storage_ipc.h | 1 +
18 .../se-proxy/opteesp/service_proxy_factory.c | 22 +++++++++++++------
19 4 files changed, 32 insertions(+), 23 deletions(-)
20
21diff --git a/components/service/common/include/psa/sid.h b/components/service/common/include/psa/sid.h
22index 833f5039..4a951d4a 100644
23--- a/components/service/common/include/psa/sid.h
24+++ b/components/service/common/include/psa/sid.h
25@@ -20,12 +20,12 @@ extern "C" {
26 /* Invalid UID */
27 #define TFM_PS_INVALID_UID 0
28
29-/* PS message types that distinguish PS services. */
30-#define TFM_PS_SET 1001
31-#define TFM_PS_GET 1002
32-#define TFM_PS_GET_INFO 1003
33-#define TFM_PS_REMOVE 1004
34-#define TFM_PS_GET_SUPPORT 1005
35+/* PS / ITS message types that distinguish PS services. */
36+#define TFM_PS_ITS_SET 1001
37+#define TFM_PS_ITS_GET 1002
38+#define TFM_PS_ITS_GET_INFO 1003
39+#define TFM_PS_ITS_REMOVE 1004
40+#define TFM_PS_ITS_GET_SUPPORT 1005
41
42 /******** TFM_SP_ITS ********/
43 #define TFM_INTERNAL_TRUSTED_STORAGE_SERVICE_SID (0x00000070U)
44diff --git a/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.c b/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.c
45index bda442a6..0e1b48c0 100644
46--- a/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.c
47+++ b/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.c
48@@ -31,8 +31,8 @@ static psa_status_t secure_storage_ipc_set(void *context, uint32_t client_id,
49
50 ipc->client.rpc_status = TS_RPC_CALL_ACCEPTED;
51
52- psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
53- TFM_PS_SET, in_vec, IOVEC_LEN(in_vec), NULL, 0);
54+ psa_status = psa_call(caller, ipc->service_handle, TFM_PS_ITS_SET,
55+ in_vec, IOVEC_LEN(in_vec), NULL, 0);
56 if (psa_status < 0)
57 EMSG("ipc_set: psa_call failed: %d", psa_status);
58
59@@ -65,8 +65,8 @@ static psa_status_t secure_storage_ipc_get(void *context,
60 return PSA_ERROR_INVALID_ARGUMENT;
61 }
62
63- psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
64- TFM_PS_GET, in_vec, IOVEC_LEN(in_vec),
65+ psa_status = psa_call(caller, ipc->service_handle,
66+ TFM_PS_ITS_GET, in_vec, IOVEC_LEN(in_vec),
67 out_vec, IOVEC_LEN(out_vec));
68 if (psa_status == PSA_SUCCESS)
69 *p_data_length = out_vec[0].len;
70@@ -92,8 +92,8 @@ static psa_status_t secure_storage_ipc_get_info(void *context,
71
72 (void)client_id;
73
74- psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
75- TFM_PS_GET_INFO, in_vec,
76+ psa_status = psa_call(caller, ipc->service_handle,
77+ TFM_PS_ITS_GET_INFO, in_vec,
78 IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec));
79 if (psa_status != PSA_SUCCESS)
80 EMSG("ipc_get_info: failed to psa_call: %d", psa_status);
81@@ -115,8 +115,8 @@ static psa_status_t secure_storage_ipc_remove(void *context,
82
83 (void)client_id;
84
85- psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
86- TFM_PS_REMOVE, in_vec,
87+ psa_status = psa_call(caller, ipc->service_handle,
88+ TFM_PS_ITS_REMOVE, in_vec,
89 IOVEC_LEN(in_vec), NULL, 0);
90 if (psa_status != PSA_SUCCESS)
91 EMSG("ipc_remove: failed to psa_call: %d", psa_status);
92@@ -169,8 +169,8 @@ static uint32_t secure_storage_get_support(void *context, uint32_t client_id)
93
94 (void)client_id;
95
96- psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
97- TFM_PS_GET_SUPPORT, NULL, 0,
98+ psa_status = psa_call(caller, ipc->service_handle,
99+ TFM_PS_ITS_GET_SUPPORT, NULL, 0,
100 out_vec, IOVEC_LEN(out_vec));
101 if (psa_status != PSA_SUCCESS)
102 EMSG("ipc_get_support: failed to psa_call: %d", psa_status);
103diff --git a/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.h b/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.h
104index e8c1e8fd..d9949f6a 100644
105--- a/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.h
106+++ b/components/service/secure_storage/backend/secure_storage_ipc/secure_storage_ipc.h
107@@ -21,6 +21,7 @@ struct secure_storage_ipc
108 {
109 struct storage_backend backend;
110 struct service_client client;
111+ int32_t service_handle;
112 };
113
114 /**
115diff --git a/deployments/se-proxy/opteesp/service_proxy_factory.c b/deployments/se-proxy/opteesp/service_proxy_factory.c
116index 4b8ccecc..1110ac46 100644
117--- a/deployments/se-proxy/opteesp/service_proxy_factory.c
118+++ b/deployments/se-proxy/opteesp/service_proxy_factory.c
119@@ -5,6 +5,7 @@
120 */
121
122 #include <stddef.h>
123+#include <psa/sid.h>
124 #include <rpc/common/endpoint/rpc_interface.h>
125 #include <rpc/openamp/caller/sp/openamp_caller.h>
126 #include <service/attestation/provider/attest_provider.h>
127@@ -60,23 +61,30 @@ struct rpc_interface *ps_proxy_create(void)
128 {
129 static struct secure_storage_provider ps_provider;
130 static struct secure_storage_ipc ps_backend;
131- static struct rpc_caller *storage_caller;
132+ struct rpc_caller *storage_caller;
133 struct storage_backend *backend;
134
135 storage_caller = openamp_caller_init(&openamp);
136 if (!storage_caller)
137 return NULL;
138 backend = secure_storage_ipc_init(&ps_backend, &openamp.rpc_caller);
139+ ps_backend.service_handle = TFM_PROTECTED_STORAGE_SERVICE_HANDLE;
140
141 return secure_storage_provider_init(&ps_provider, backend);
142 }
143
144 struct rpc_interface *its_proxy_create(void)
145 {
146- static struct mock_store its_backend;
147- static struct secure_storage_provider its_provider;
148-
149- struct storage_backend *backend = mock_store_init(&its_backend);
150-
151- return secure_storage_provider_init(&its_provider, backend);
152+ static struct secure_storage_provider its_provider;
153+ static struct secure_storage_ipc its_backend;
154+ struct rpc_caller *storage_caller;
155+ struct storage_backend *backend;
156+
157+ storage_caller = openamp_caller_init(&openamp);
158+ if (!storage_caller)
159+ return NULL;
160+ backend = secure_storage_ipc_init(&its_backend, &openamp.rpc_caller);
161+ its_backend.service_handle = TFM_INTERNAL_TRUSTED_STORAGE_SERVICE_HANDLE;
162+
163+ return secure_storage_provider_init(&its_provider, backend);
164 }