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