summaryrefslogtreecommitdiff
path: root/meta-arm/meta-arm-bsp/recipes-security/trusted-services/corstone1000/0011-Setup-its-backend-as-openamp-rpc-using-secure-storag.patch
blob: 5803cc17dc9ca71e783bfd476e7fb469288bd4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
From 4240977f7c38950f5edb316bb08ae05cb7b99875 Mon Sep 17 00:00:00 2001
From: Satish Kumar <satish.kumar01@arm.com>
Date: Thu, 9 Dec 2021 14:11:06 +0000
Subject: [PATCH 11/20] Setup its backend as openamp rpc using secure storage
 ipc implementation.

Upstream-Status: Pending
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
---
 components/service/common/include/psa/sid.h   | 12 +++++-----
 .../secure_storage_ipc/secure_storage_ipc.c   | 20 ++++++++---------
 .../secure_storage_ipc/secure_storage_ipc.h   |  1 +
 .../se-proxy/common/service_proxy_factory.c   | 22 +++++++++++++------
 4 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/components/service/common/include/psa/sid.h b/components/service/common/include/psa/sid.h
index 833f5039425f..4a951d4a3502 100644
--- a/components/service/common/include/psa/sid.h
+++ b/components/service/common/include/psa/sid.h
@@ -20,12 +20,12 @@ extern "C" {
 /* Invalid UID */
 #define TFM_PS_INVALID_UID 0
 
-/* PS message types that distinguish PS services. */
-#define TFM_PS_SET                1001
-#define TFM_PS_GET                1002
-#define TFM_PS_GET_INFO           1003
-#define TFM_PS_REMOVE             1004
-#define TFM_PS_GET_SUPPORT        1005
+/* PS / ITS message types that distinguish PS services. */
+#define TFM_PS_ITS_SET                1001
+#define TFM_PS_ITS_GET                1002
+#define TFM_PS_ITS_GET_INFO           1003
+#define TFM_PS_ITS_REMOVE             1004
+#define TFM_PS_ITS_GET_SUPPORT        1005
 
 /******** TFM_SP_ITS ********/
 #define TFM_INTERNAL_TRUSTED_STORAGE_SERVICE_SID                   (0x00000070U)
diff --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
index bda442a61d5c..0e1b48c0d2e2 100644
--- 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
@@ -31,8 +31,8 @@ static psa_status_t secure_storage_ipc_set(void *context, uint32_t client_id,
 
 	ipc->client.rpc_status = TS_RPC_CALL_ACCEPTED;
 
-	psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
-			      TFM_PS_SET, in_vec, IOVEC_LEN(in_vec), NULL, 0);
+	psa_status = psa_call(caller, ipc->service_handle, TFM_PS_ITS_SET,
+			      in_vec, IOVEC_LEN(in_vec), NULL, 0);
 	if (psa_status < 0)
 		EMSG("ipc_set: psa_call failed: %d", psa_status);
 
@@ -65,8 +65,8 @@ static psa_status_t secure_storage_ipc_get(void *context,
 		return PSA_ERROR_INVALID_ARGUMENT;
 	}
 
-	psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
-			      TFM_PS_GET, in_vec, IOVEC_LEN(in_vec),
+	psa_status = psa_call(caller, ipc->service_handle,
+			      TFM_PS_ITS_GET, in_vec, IOVEC_LEN(in_vec),
 			      out_vec, IOVEC_LEN(out_vec));
 	if (psa_status == PSA_SUCCESS)
 		*p_data_length = out_vec[0].len;
@@ -92,8 +92,8 @@ static psa_status_t secure_storage_ipc_get_info(void *context,
 
 	(void)client_id;
 
-	psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
-			      TFM_PS_GET_INFO, in_vec,
+	psa_status = psa_call(caller, ipc->service_handle,
+			      TFM_PS_ITS_GET_INFO, in_vec,
 			      IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec));
 	if (psa_status != PSA_SUCCESS)
 		EMSG("ipc_get_info: failed to psa_call: %d", psa_status);
@@ -115,8 +115,8 @@ static psa_status_t secure_storage_ipc_remove(void *context,
 
 	(void)client_id;
 
-	psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
-			      TFM_PS_REMOVE, in_vec,
+	psa_status = psa_call(caller, ipc->service_handle,
+			      TFM_PS_ITS_REMOVE, in_vec,
 			      IOVEC_LEN(in_vec), NULL, 0);
 	if (psa_status != PSA_SUCCESS)
 		EMSG("ipc_remove: failed to psa_call: %d", psa_status);
@@ -169,8 +169,8 @@ static uint32_t secure_storage_get_support(void *context, uint32_t client_id)
 
 	(void)client_id;
 
-	psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
-			      TFM_PS_GET_SUPPORT, NULL, 0,
+	psa_status = psa_call(caller, ipc->service_handle,
+			      TFM_PS_ITS_GET_SUPPORT, NULL, 0,
 			      out_vec, IOVEC_LEN(out_vec));
 	if (psa_status != PSA_SUCCESS)
 		EMSG("ipc_get_support: failed to psa_call: %d", psa_status);
diff --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
index e8c1e8fd2f92..d9949f6a9305 100644
--- 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
@@ -21,6 +21,7 @@ struct secure_storage_ipc
 {
     struct storage_backend backend;
     struct service_client client;
+    int32_t service_handle;
 };
 
 /**
diff --git a/deployments/se-proxy/common/service_proxy_factory.c b/deployments/se-proxy/common/service_proxy_factory.c
index 4b8cceccbe4d..1110ac46bf8b 100644
--- a/deployments/se-proxy/common/service_proxy_factory.c
+++ b/deployments/se-proxy/common/service_proxy_factory.c
@@ -5,6 +5,7 @@
  */
 
 #include <stddef.h>
+#include <psa/sid.h>
 #include <rpc/common/endpoint/rpc_interface.h>
 #include <rpc/openamp/caller/sp/openamp_caller.h>
 #include <service/attestation/provider/attest_provider.h>
@@ -60,23 +61,30 @@ struct rpc_interface *ps_proxy_create(void)
 {
 	static struct secure_storage_provider ps_provider;
 	static struct secure_storage_ipc ps_backend;
-	static struct rpc_caller *storage_caller;
+	struct rpc_caller *storage_caller;
 	struct storage_backend *backend;
 
 	storage_caller = openamp_caller_init(&openamp);
 	if (!storage_caller)
 		return NULL;
 	backend = secure_storage_ipc_init(&ps_backend, &openamp.rpc_caller);
+	ps_backend.service_handle = TFM_PROTECTED_STORAGE_SERVICE_HANDLE;
 
 	return secure_storage_provider_init(&ps_provider, backend);
 }
 
 struct rpc_interface *its_proxy_create(void)
 {
-	static struct mock_store its_backend;
-	static struct secure_storage_provider its_provider;
-
-	struct storage_backend *backend = mock_store_init(&its_backend);
-
-	return secure_storage_provider_init(&its_provider, backend);
+        static struct secure_storage_provider its_provider;
+        static struct secure_storage_ipc its_backend;
+        struct rpc_caller *storage_caller;
+        struct storage_backend *backend;
+ 
+        storage_caller = openamp_caller_init(&openamp);
+        if (!storage_caller)
+        	return NULL;
+        backend = secure_storage_ipc_init(&its_backend, &openamp.rpc_caller);
+        its_backend.service_handle = TFM_INTERNAL_TRUSTED_STORAGE_SERVICE_HANDLE;
+ 
+        return secure_storage_provider_init(&its_provider, backend);
 }
-- 
2.38.1