Initial commit
This commit is contained in:
+376
@@ -0,0 +1,376 @@
|
||||
From a965129153a0cca340535fe2cf99dbfef9b557da Mon Sep 17 00:00:00 2001
|
||||
From: Julian Hall <julian.hall@arm.com>
|
||||
Date: Tue, 12 Oct 2021 15:45:41 +0100
|
||||
Subject: [PATCH 1/6] Add stub capsule update service components
|
||||
|
||||
To facilitate development of a capsule update service provider,
|
||||
stub components are added to provide a starting point for an
|
||||
implementation. The capsule update service provider is integrated
|
||||
into the se-proxy/common deployment.
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
|
||||
Signed-off-by: Julian Hall <julian.hall@arm.com>
|
||||
Change-Id: I0d4049bb4de5af7ca80806403301692507085d28
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
.../backend/capsule_update_backend.h | 24 ++++
|
||||
.../provider/capsule_update_provider.c | 133 ++++++++++++++++++
|
||||
.../provider/capsule_update_provider.h | 51 +++++++
|
||||
.../capsule_update/provider/component.cmake | 13 ++
|
||||
.../se-proxy/infra/corstone1000/infra.cmake | 1 +
|
||||
deployments/se-proxy/se_proxy_interfaces.h | 9 +-
|
||||
.../capsule_update/capsule_update_proto.h | 13 ++
|
||||
protocols/service/capsule_update/opcodes.h | 17 +++
|
||||
protocols/service/capsule_update/parameters.h | 15 ++
|
||||
9 files changed, 272 insertions(+), 4 deletions(-)
|
||||
create mode 100644 components/service/capsule_update/backend/capsule_update_backend.h
|
||||
create mode 100644 components/service/capsule_update/provider/capsule_update_provider.c
|
||||
create mode 100644 components/service/capsule_update/provider/capsule_update_provider.h
|
||||
create mode 100644 components/service/capsule_update/provider/component.cmake
|
||||
create mode 100644 protocols/service/capsule_update/capsule_update_proto.h
|
||||
create mode 100644 protocols/service/capsule_update/opcodes.h
|
||||
create mode 100644 protocols/service/capsule_update/parameters.h
|
||||
|
||||
diff --git a/components/service/capsule_update/backend/capsule_update_backend.h b/components/service/capsule_update/backend/capsule_update_backend.h
|
||||
new file mode 100644
|
||||
index 000000000000..f3144ff1d7d5
|
||||
--- /dev/null
|
||||
+++ b/components/service/capsule_update/backend/capsule_update_backend.h
|
||||
@@ -0,0 +1,24 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#ifndef CAPSULE_UPDATE_BACKEND_H
|
||||
+#define CAPSULE_UPDATE_BACKEND_H
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
+/**
|
||||
+ * Defines the common capsule update backend interface. Concrete backends
|
||||
+ * implement this interface for different types of platform.
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+} /* extern "C" */
|
||||
+#endif
|
||||
+
|
||||
+#endif /* CAPSULE_UPDATE_BACKEND_H */
|
||||
diff --git a/components/service/capsule_update/provider/capsule_update_provider.c b/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
new file mode 100644
|
||||
index 000000000000..e133753f8560
|
||||
--- /dev/null
|
||||
+++ b/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
@@ -0,0 +1,133 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#include <psa/client.h>
|
||||
+#include <psa/sid.h>
|
||||
+#include <trace.h>
|
||||
+
|
||||
+#include <protocols/service/capsule_update/capsule_update_proto.h>
|
||||
+#include <protocols/rpc/common/packed-c/status.h>
|
||||
+#include "capsule_update_provider.h"
|
||||
+
|
||||
+
|
||||
+#define CAPSULE_UPDATE_REQUEST (0x1)
|
||||
+#define KERNEL_STARTED_EVENT (0x2)
|
||||
+
|
||||
+enum corstone1000_ioctl_id_t {
|
||||
+ IOCTL_CORSTONE1000_FWU_FLASH_IMAGES = 0,
|
||||
+ IOCTL_CORSTONE1000_FWU_HOST_ACK,
|
||||
+};
|
||||
+
|
||||
+/* Service request handlers */
|
||||
+static rpc_status_t update_capsule_handler(void *context, struct call_req *req);
|
||||
+static rpc_status_t boot_confirmed_handler(void *context, struct call_req *req);
|
||||
+
|
||||
+/* Handler mapping table for service */
|
||||
+static const struct service_handler handler_table[] = {
|
||||
+ {CAPSULE_UPDATE_OPCODE_UPDATE_CAPSULE, update_capsule_handler},
|
||||
+ {CAPSULE_UPDATE_OPCODE_BOOT_CONFIRMED, boot_confirmed_handler}
|
||||
+};
|
||||
+
|
||||
+struct rpc_interface *capsule_update_provider_init(
|
||||
+ struct capsule_update_provider *context)
|
||||
+{
|
||||
+ struct rpc_interface *rpc_interface = NULL;
|
||||
+
|
||||
+ if (context) {
|
||||
+
|
||||
+ service_provider_init(
|
||||
+ &context->base_provider,
|
||||
+ context,
|
||||
+ handler_table,
|
||||
+ sizeof(handler_table)/sizeof(struct service_handler));
|
||||
+
|
||||
+ rpc_interface = service_provider_get_rpc_interface(&context->base_provider);
|
||||
+ }
|
||||
+
|
||||
+ return rpc_interface;
|
||||
+}
|
||||
+
|
||||
+void capsule_update_provider_deinit(struct capsule_update_provider *context)
|
||||
+{
|
||||
+ (void)context;
|
||||
+}
|
||||
+
|
||||
+static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller)
|
||||
+{
|
||||
+ uint32_t ioctl_id;
|
||||
+ psa_handle_t handle;
|
||||
+ rpc_status_t rpc_status = TS_RPC_CALL_ACCEPTED;
|
||||
+
|
||||
+ struct psa_invec in_vec[] = {
|
||||
+ { .base = &ioctl_id, .len = sizeof(ioctl_id) }
|
||||
+ };
|
||||
+
|
||||
+ if(!caller) {
|
||||
+ EMSG("event_handler rpc_caller is NULL");
|
||||
+ rpc_status = TS_RPC_ERROR_RESOURCE_FAILURE;
|
||||
+ return rpc_status;
|
||||
+ }
|
||||
+
|
||||
+ IMSG("event handler opcode %x", opcode);
|
||||
+ switch(opcode) {
|
||||
+ case CAPSULE_UPDATE_REQUEST:
|
||||
+ /* Openamp call with IOCTL for firmware update*/
|
||||
+ ioctl_id = IOCTL_CORSTONE1000_FWU_FLASH_IMAGES;
|
||||
+ handle = psa_connect(caller, TFM_SP_PLATFORM_IOCTL_SID,
|
||||
+ TFM_SP_PLATFORM_IOCTL_VERSION);
|
||||
+ if (handle <= 0) {
|
||||
+ EMSG("%s Invalid handle", __func__);
|
||||
+ rpc_status = TS_RPC_ERROR_INVALID_PARAMETER;
|
||||
+ return rpc_status;
|
||||
+ }
|
||||
+ psa_call(caller,handle, PSA_IPC_CALL,
|
||||
+ in_vec,IOVEC_LEN(in_vec), NULL, 0);
|
||||
+ break;
|
||||
+
|
||||
+ case KERNEL_STARTED_EVENT:
|
||||
+ ioctl_id = IOCTL_CORSTONE1000_FWU_HOST_ACK;
|
||||
+ /*openamp call with IOCTL for kernel start*/
|
||||
+ handle = psa_connect(caller, TFM_SP_PLATFORM_IOCTL_SID,
|
||||
+ TFM_SP_PLATFORM_IOCTL_VERSION);
|
||||
+ if (handle <= 0) {
|
||||
+ EMSG("%s Invalid handle", __func__);
|
||||
+ rpc_status = TS_RPC_ERROR_INVALID_PARAMETER;
|
||||
+ return rpc_status;
|
||||
+ }
|
||||
+ psa_call(caller,handle, PSA_IPC_CALL,
|
||||
+ in_vec,IOVEC_LEN(in_vec), NULL, 0);
|
||||
+ break;
|
||||
+ default:
|
||||
+ EMSG("%s unsupported opcode", __func__);
|
||||
+ rpc_status = TS_RPC_ERROR_INVALID_PARAMETER;
|
||||
+ return rpc_status;
|
||||
+ }
|
||||
+ return rpc_status;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static rpc_status_t update_capsule_handler(void *context, struct call_req *req)
|
||||
+{
|
||||
+ struct capsule_update_provider *this_instance = (struct capsule_update_provider*)context;
|
||||
+ struct rpc_caller *caller = this_instance->client.caller;
|
||||
+ uint32_t opcode = req->opcode;
|
||||
+ rpc_status_t rpc_status = TS_RPC_ERROR_NOT_READY;
|
||||
+
|
||||
+ rpc_status = event_handler(opcode, caller);
|
||||
+ return rpc_status;
|
||||
+}
|
||||
+
|
||||
+static rpc_status_t boot_confirmed_handler(void *context, struct call_req *req)
|
||||
+{
|
||||
+ struct capsule_update_provider *this_instance = (struct capsule_update_provider*)context;
|
||||
+ struct rpc_caller *caller = this_instance->client.caller;
|
||||
+ uint32_t opcode = req->opcode;
|
||||
+ rpc_status_t rpc_status = TS_RPC_ERROR_NOT_READY;
|
||||
+
|
||||
+ rpc_status = event_handler(opcode, caller);
|
||||
+
|
||||
+ return rpc_status;
|
||||
+}
|
||||
diff --git a/components/service/capsule_update/provider/capsule_update_provider.h b/components/service/capsule_update/provider/capsule_update_provider.h
|
||||
new file mode 100644
|
||||
index 000000000000..3de49854ea90
|
||||
--- /dev/null
|
||||
+++ b/components/service/capsule_update/provider/capsule_update_provider.h
|
||||
@@ -0,0 +1,51 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#ifndef CAPSULE_UPDATE_PROVIDER_H
|
||||
+#define CAPSULE_UPDATE_PROVIDER_H
|
||||
+
|
||||
+#include <rpc/common/endpoint/rpc_interface.h>
|
||||
+#include <service/common/provider/service_provider.h>
|
||||
+#include <service/common/client/service_client.h>
|
||||
+#include <service/capsule_update/backend/capsule_update_backend.h>
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
+/**
|
||||
+ * The capsule_update_provider is a service provider that accepts update capsule
|
||||
+ * requests and delegates them to a suitable backend that applies the update.
|
||||
+ */
|
||||
+struct capsule_update_provider
|
||||
+{
|
||||
+ struct service_provider base_provider;
|
||||
+ struct service_client client;
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * \brief Initialize an instance of the capsule update service provider
|
||||
+ *
|
||||
+ * @param[in] context The instance to initialize
|
||||
+ *
|
||||
+ * \return An rpc_interface or NULL on failure
|
||||
+ */
|
||||
+struct rpc_interface *capsule_update_provider_init(
|
||||
+ struct capsule_update_provider *context);
|
||||
+
|
||||
+/**
|
||||
+ * \brief Cleans up when the instance is no longer needed
|
||||
+ *
|
||||
+ * \param[in] context The instance to de-initialize
|
||||
+ */
|
||||
+void capsule_update_provider_deinit(
|
||||
+ struct capsule_update_provider *context);
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+} /* extern "C" */
|
||||
+#endif
|
||||
+
|
||||
+#endif /* CAPSULE_UPDATE_PROVIDER_H */
|
||||
diff --git a/components/service/capsule_update/provider/component.cmake b/components/service/capsule_update/provider/component.cmake
|
||||
new file mode 100644
|
||||
index 000000000000..1d412eb234d9
|
||||
--- /dev/null
|
||||
+++ b/components/service/capsule_update/provider/component.cmake
|
||||
@@ -0,0 +1,13 @@
|
||||
+#-------------------------------------------------------------------------------
|
||||
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+#
|
||||
+# SPDX-License-Identifier: BSD-3-Clause
|
||||
+#
|
||||
+#-------------------------------------------------------------------------------
|
||||
+if (NOT DEFINED TGT)
|
||||
+ message(FATAL_ERROR "mandatory parameter TGT is not defined.")
|
||||
+endif()
|
||||
+
|
||||
+target_sources(${TGT} PRIVATE
|
||||
+ "${CMAKE_CURRENT_LIST_DIR}/capsule_update_provider.c"
|
||||
+ )
|
||||
diff --git a/deployments/se-proxy/infra/corstone1000/infra.cmake b/deployments/se-proxy/infra/corstone1000/infra.cmake
|
||||
index 4e7e2bd58028..e60b5400617f 100644
|
||||
--- a/deployments/se-proxy/infra/corstone1000/infra.cmake
|
||||
+++ b/deployments/se-proxy/infra/corstone1000/infra.cmake
|
||||
@@ -21,6 +21,7 @@ add_components(TARGET "se-proxy"
|
||||
"components/service/attestation/key_mngr/local"
|
||||
"components/service/attestation/reporter/psa_ipc"
|
||||
"components/service/crypto/backend/psa_ipc"
|
||||
+ "components/service/capsule_update/provider"
|
||||
"components/service/secure_storage/backend/secure_storage_ipc"
|
||||
)
|
||||
|
||||
diff --git a/deployments/se-proxy/se_proxy_interfaces.h b/deployments/se-proxy/se_proxy_interfaces.h
|
||||
index 48908f846990..3d4a7c204785 100644
|
||||
--- a/deployments/se-proxy/se_proxy_interfaces.h
|
||||
+++ b/deployments/se-proxy/se_proxy_interfaces.h
|
||||
@@ -8,9 +8,10 @@
|
||||
#define SE_PROXY_INTERFACES_H
|
||||
|
||||
/* Interface IDs from service endpoints available from an se-proxy deployment */
|
||||
-#define SE_PROXY_INTERFACE_ID_ITS (0)
|
||||
-#define SE_PROXY_INTERFACE_ID_PS (1)
|
||||
-#define SE_PROXY_INTERFACE_ID_CRYPTO (2)
|
||||
-#define SE_PROXY_INTERFACE_ID_ATTEST (3)
|
||||
+#define SE_PROXY_INTERFACE_ID_ITS (0)
|
||||
+#define SE_PROXY_INTERFACE_ID_PS (1)
|
||||
+#define SE_PROXY_INTERFACE_ID_CRYPTO (2)
|
||||
+#define SE_PROXY_INTERFACE_ID_ATTEST (3)
|
||||
+#define SE_PROXY_INTERFACE_ID_CAPSULE_UPDATE (4)
|
||||
|
||||
#endif /* SE_PROXY_INTERFACES_H */
|
||||
diff --git a/protocols/service/capsule_update/capsule_update_proto.h b/protocols/service/capsule_update/capsule_update_proto.h
|
||||
new file mode 100644
|
||||
index 000000000000..8f326cd387fb
|
||||
--- /dev/null
|
||||
+++ b/protocols/service/capsule_update/capsule_update_proto.h
|
||||
@@ -0,0 +1,13 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#ifndef CAPSULE_UPDATE_PROTO_H
|
||||
+#define CAPSULE_UPDATE_PROTO_H
|
||||
+
|
||||
+#include <protocols/service/capsule_update/opcodes.h>
|
||||
+#include <protocols/service/capsule_update/parameters.h>
|
||||
+
|
||||
+#endif /* CAPSULE_UPDATE_PROTO_H */
|
||||
diff --git a/protocols/service/capsule_update/opcodes.h b/protocols/service/capsule_update/opcodes.h
|
||||
new file mode 100644
|
||||
index 000000000000..8185a0902378
|
||||
--- /dev/null
|
||||
+++ b/protocols/service/capsule_update/opcodes.h
|
||||
@@ -0,0 +1,17 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#ifndef CAPSULE_UPDATE_OPCODES_H
|
||||
+#define CAPSULE_UPDATE_OPCODES_H
|
||||
+
|
||||
+/**
|
||||
+ * Opcode definitions for the capsule update service
|
||||
+ */
|
||||
+
|
||||
+#define CAPSULE_UPDATE_OPCODE_UPDATE_CAPSULE 1
|
||||
+#define CAPSULE_UPDATE_OPCODE_BOOT_CONFIRMED 2
|
||||
+
|
||||
+#endif /* CAPSULE_UPDATE_OPCODES_H */
|
||||
diff --git a/protocols/service/capsule_update/parameters.h b/protocols/service/capsule_update/parameters.h
|
||||
new file mode 100644
|
||||
index 000000000000..285d924186be
|
||||
--- /dev/null
|
||||
+++ b/protocols/service/capsule_update/parameters.h
|
||||
@@ -0,0 +1,15 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#ifndef CAPSULE_UPDATE_PARAMETERS_H
|
||||
+#define CAPSULE_UPDATE_PARAMETERS_H
|
||||
+
|
||||
+/**
|
||||
+ * Operation parameter definitions for the capsule update service access protocol.
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+#endif /* CAPSULE_UPDATE_PARAMETERS_H */
|
||||
--
|
||||
2.40.0
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
From 51a7024967187644011c5043ef0f733cf81b26be Mon Sep 17 00:00:00 2001
|
||||
From: Satish Kumar <satish.kumar01@arm.com>
|
||||
Date: Mon, 14 Feb 2022 08:22:25 +0000
|
||||
Subject: [PATCH 2/6] Fixes in AEAD for psa-arch test 54 and 58.
|
||||
|
||||
Upstream-Status: Pending [Not submitted to upstream yet]
|
||||
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
|
||||
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
.../crypto/client/caller/packed-c/crypto_caller_aead.h | 1 +
|
||||
components/service/crypto/include/psa/crypto_sizes.h | 2 +-
|
||||
.../crypto/provider/extension/aead/aead_provider.c | 8 ++++++--
|
||||
.../extension/aead/serializer/aead_provider_serializer.h | 1 +
|
||||
.../packed-c/packedc_aead_provider_serializer.c | 2 ++
|
||||
protocols/service/crypto/packed-c/aead.h | 1 +
|
||||
6 files changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/components/service/crypto/client/caller/packed-c/crypto_caller_aead.h b/components/service/crypto/client/caller/packed-c/crypto_caller_aead.h
|
||||
index c4ffb20cf7f8..a91f66c14008 100644
|
||||
--- a/components/service/crypto/client/caller/packed-c/crypto_caller_aead.h
|
||||
+++ b/components/service/crypto/client/caller/packed-c/crypto_caller_aead.h
|
||||
@@ -309,6 +309,7 @@ static inline psa_status_t crypto_caller_aead_update(struct service_client *cont
|
||||
size_t req_len = req_fixed_len;
|
||||
|
||||
*output_length = 0;
|
||||
+ req_msg.output_size = output_size;
|
||||
req_msg.op_handle = op_handle;
|
||||
|
||||
/* Mandatory input data parameter */
|
||||
diff --git a/components/service/crypto/include/psa/crypto_sizes.h b/components/service/crypto/include/psa/crypto_sizes.h
|
||||
index 30aa102da581..130d27295878 100644
|
||||
--- a/components/service/crypto/include/psa/crypto_sizes.h
|
||||
+++ b/components/service/crypto/include/psa/crypto_sizes.h
|
||||
@@ -351,7 +351,7 @@
|
||||
* just the largest size that may be generated by
|
||||
* #psa_aead_generate_nonce().
|
||||
*/
|
||||
-#define PSA_AEAD_NONCE_MAX_SIZE 12
|
||||
+#define PSA_AEAD_NONCE_MAX_SIZE 16
|
||||
|
||||
/** A sufficient output buffer size for psa_aead_update().
|
||||
*
|
||||
diff --git a/components/service/crypto/provider/extension/aead/aead_provider.c b/components/service/crypto/provider/extension/aead/aead_provider.c
|
||||
index 14a25436b3f6..6b144db821de 100644
|
||||
--- a/components/service/crypto/provider/extension/aead/aead_provider.c
|
||||
+++ b/components/service/crypto/provider/extension/aead/aead_provider.c
|
||||
@@ -283,10 +283,11 @@ static rpc_status_t aead_update_handler(void *context, struct call_req *req)
|
||||
uint32_t op_handle;
|
||||
const uint8_t *input;
|
||||
size_t input_len;
|
||||
+ uint32_t recv_output_size;
|
||||
|
||||
if (serializer)
|
||||
rpc_status = serializer->deserialize_aead_update_req(req_buf, &op_handle,
|
||||
- &input, &input_len);
|
||||
+ &recv_output_size, &input, &input_len);
|
||||
|
||||
if (rpc_status == TS_RPC_CALL_ACCEPTED) {
|
||||
|
||||
@@ -300,9 +301,12 @@ static rpc_status_t aead_update_handler(void *context, struct call_req *req)
|
||||
if (crypto_context) {
|
||||
|
||||
size_t output_len = 0;
|
||||
- size_t output_size = PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(input_len);
|
||||
+ size_t output_size = PSA_AEAD_UPDATE_OUTPUT_MAX_SIZE(24);
|
||||
uint8_t *output = malloc(output_size);
|
||||
|
||||
+ if (recv_output_size < output_size) {
|
||||
+ output_size = recv_output_size;
|
||||
+ }
|
||||
if (output) {
|
||||
|
||||
psa_status = psa_aead_update(&crypto_context->op.aead,
|
||||
diff --git a/components/service/crypto/provider/extension/aead/serializer/aead_provider_serializer.h b/components/service/crypto/provider/extension/aead/serializer/aead_provider_serializer.h
|
||||
index bb1a2a97e4b7..0156aaba3fe3 100644
|
||||
--- a/components/service/crypto/provider/extension/aead/serializer/aead_provider_serializer.h
|
||||
+++ b/components/service/crypto/provider/extension/aead/serializer/aead_provider_serializer.h
|
||||
@@ -51,6 +51,7 @@ struct aead_provider_serializer {
|
||||
/* Operation: aead_update */
|
||||
rpc_status_t (*deserialize_aead_update_req)(const struct call_param_buf *req_buf,
|
||||
uint32_t *op_handle,
|
||||
+ uint32_t *output_size,
|
||||
const uint8_t **input, size_t *input_len);
|
||||
|
||||
rpc_status_t (*serialize_aead_update_resp)(struct call_param_buf *resp_buf,
|
||||
diff --git a/components/service/crypto/provider/extension/aead/serializer/packed-c/packedc_aead_provider_serializer.c b/components/service/crypto/provider/extension/aead/serializer/packed-c/packedc_aead_provider_serializer.c
|
||||
index 6f00b3e3f6f1..45c739abcbb4 100644
|
||||
--- a/components/service/crypto/provider/extension/aead/serializer/packed-c/packedc_aead_provider_serializer.c
|
||||
+++ b/components/service/crypto/provider/extension/aead/serializer/packed-c/packedc_aead_provider_serializer.c
|
||||
@@ -192,6 +192,7 @@ static rpc_status_t deserialize_aead_update_ad_req(const struct call_param_buf *
|
||||
/* Operation: aead_update */
|
||||
static rpc_status_t deserialize_aead_update_req(const struct call_param_buf *req_buf,
|
||||
uint32_t *op_handle,
|
||||
+ uint32_t *output_size,
|
||||
const uint8_t **input, size_t *input_len)
|
||||
{
|
||||
rpc_status_t rpc_status = TS_RPC_ERROR_INVALID_REQ_BODY;
|
||||
@@ -208,6 +209,7 @@ static rpc_status_t deserialize_aead_update_req(const struct call_param_buf *req
|
||||
memcpy(&recv_msg, req_buf->data, expected_fixed_len);
|
||||
|
||||
*op_handle = recv_msg.op_handle;
|
||||
+ *output_size = recv_msg.output_size;
|
||||
|
||||
tlv_const_iterator_begin(&req_iter,
|
||||
(uint8_t*)req_buf->data + expected_fixed_len,
|
||||
diff --git a/protocols/service/crypto/packed-c/aead.h b/protocols/service/crypto/packed-c/aead.h
|
||||
index 0be266b52403..435fd3b523ce 100644
|
||||
--- a/protocols/service/crypto/packed-c/aead.h
|
||||
+++ b/protocols/service/crypto/packed-c/aead.h
|
||||
@@ -98,6 +98,7 @@ enum
|
||||
struct __attribute__ ((__packed__)) ts_crypto_aead_update_in
|
||||
{
|
||||
uint32_t op_handle;
|
||||
+ uint32_t output_size;
|
||||
};
|
||||
|
||||
/* Variable length input parameter tags */
|
||||
--
|
||||
2.40.0
|
||||
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
From 5c8ac10337ac853d8a82992fb6e1d91b122b99d2 Mon Sep 17 00:00:00 2001
|
||||
From: Satish Kumar <satish.kumar01@arm.com>
|
||||
Date: Fri, 8 Jul 2022 09:48:06 +0100
|
||||
Subject: [PATCH 3/6] FMP Support in Corstone1000.
|
||||
|
||||
The FMP support is used by u-boot to pupolate ESRT information
|
||||
for the kernel.
|
||||
|
||||
The solution is platform specific and needs to be revisted.
|
||||
|
||||
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
|
||||
|
||||
Upstream-Status: Inappropriate [The solution is platform specific and needs to be revisted]
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
.../provider/capsule_update_provider.c | 5 +
|
||||
.../capsule_update/provider/component.cmake | 1 +
|
||||
.../provider/corstone1000_fmp_service.c | 307 ++++++++++++++++++
|
||||
.../provider/corstone1000_fmp_service.h | 26 ++
|
||||
4 files changed, 339 insertions(+)
|
||||
create mode 100644 components/service/capsule_update/provider/corstone1000_fmp_service.c
|
||||
create mode 100644 components/service/capsule_update/provider/corstone1000_fmp_service.h
|
||||
|
||||
diff --git a/components/service/capsule_update/provider/capsule_update_provider.c b/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
index e133753f8560..991a2235cd73 100644
|
||||
--- a/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
+++ b/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <protocols/service/capsule_update/capsule_update_proto.h>
|
||||
#include <protocols/rpc/common/packed-c/status.h>
|
||||
#include "capsule_update_provider.h"
|
||||
+#include "corstone1000_fmp_service.h"
|
||||
|
||||
|
||||
#define CAPSULE_UPDATE_REQUEST (0x1)
|
||||
@@ -47,6 +48,8 @@ struct rpc_interface *capsule_update_provider_init(
|
||||
rpc_interface = service_provider_get_rpc_interface(&context->base_provider);
|
||||
}
|
||||
|
||||
+ provision_fmp_variables_metadata(context->client.caller);
|
||||
+
|
||||
return rpc_interface;
|
||||
}
|
||||
|
||||
@@ -85,6 +88,7 @@ static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller)
|
||||
}
|
||||
psa_call(caller,handle, PSA_IPC_CALL,
|
||||
in_vec,IOVEC_LEN(in_vec), NULL, 0);
|
||||
+ set_fmp_image_info(caller, handle);
|
||||
break;
|
||||
|
||||
case KERNEL_STARTED_EVENT:
|
||||
@@ -99,6 +103,7 @@ static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller)
|
||||
}
|
||||
psa_call(caller,handle, PSA_IPC_CALL,
|
||||
in_vec,IOVEC_LEN(in_vec), NULL, 0);
|
||||
+ set_fmp_image_info(caller, handle);
|
||||
break;
|
||||
default:
|
||||
EMSG("%s unsupported opcode", __func__);
|
||||
diff --git a/components/service/capsule_update/provider/component.cmake b/components/service/capsule_update/provider/component.cmake
|
||||
index 1d412eb234d9..6b0601494938 100644
|
||||
--- a/components/service/capsule_update/provider/component.cmake
|
||||
+++ b/components/service/capsule_update/provider/component.cmake
|
||||
@@ -10,4 +10,5 @@ endif()
|
||||
|
||||
target_sources(${TGT} PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/capsule_update_provider.c"
|
||||
+ "${CMAKE_CURRENT_LIST_DIR}/corstone1000_fmp_service.c"
|
||||
)
|
||||
diff --git a/components/service/capsule_update/provider/corstone1000_fmp_service.c b/components/service/capsule_update/provider/corstone1000_fmp_service.c
|
||||
new file mode 100644
|
||||
index 000000000000..6a7a47a7ed99
|
||||
--- /dev/null
|
||||
+++ b/components/service/capsule_update/provider/corstone1000_fmp_service.c
|
||||
@@ -0,0 +1,307 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#include "corstone1000_fmp_service.h"
|
||||
+#include <psa/client.h>
|
||||
+#include <psa/sid.h>
|
||||
+#include <psa/storage_common.h>
|
||||
+#include <trace.h>
|
||||
+
|
||||
+#include <service/smm_variable/backend/variable_index.h>
|
||||
+
|
||||
+#define VARIABLE_INDEX_STORAGE_UID (0x787)
|
||||
+
|
||||
+/**
|
||||
+ * Variable attributes
|
||||
+ */
|
||||
+#define EFI_VARIABLE_NON_VOLATILE (0x00000001)
|
||||
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS (0x00000002)
|
||||
+#define EFI_VARIABLE_RUNTIME_ACCESS (0x00000004)
|
||||
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD (0x00000008)
|
||||
+#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS (0x00000010)
|
||||
+#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS (0x00000020)
|
||||
+#define EFI_VARIABLE_APPEND_WRITE (0x00000040)
|
||||
+#define EFI_VARIABLE_MASK \
|
||||
+ (EFI_VARIABLE_NON_VOLATILE | \
|
||||
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | \
|
||||
+ EFI_VARIABLE_RUNTIME_ACCESS | \
|
||||
+ EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
|
||||
+ EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
|
||||
+ EFI_VARIABLE_APPEND_WRITE)
|
||||
+
|
||||
+#define FMP_VARIABLES_COUNT 6
|
||||
+
|
||||
+static struct variable_metadata fmp_variables_metadata[FMP_VARIABLES_COUNT] = {
|
||||
+ {
|
||||
+ { 0x86c77a67, 0x0b97, 0x4633, \
|
||||
+ { 0xa1, 0x87, 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7} },
|
||||
+ /* name size = (variable_name + \0) * sizeof(u16) */
|
||||
+ .name_size = 42, { 'F', 'm', 'p', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'V', 'e', 'r', 's', 'i', 'o', 'n' },
|
||||
+ .attributes = EFI_VARIABLE_NON_VOLATILE, .uid = 0
|
||||
+ },
|
||||
+ {
|
||||
+ { 0x86c77a67, 0x0b97, 0x4633, \
|
||||
+ { 0xa1, 0x87, 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7} },
|
||||
+ /* name size = (variable_name + \0) * sizeof(u16) */
|
||||
+ .name_size = 34, { 'F', 'm', 'p', 'I', 'm', 'a', 'g', 'e', 'I', 'n', 'f', 'o', 'S', 'i', 'z', 'e' },
|
||||
+ .attributes = EFI_VARIABLE_NON_VOLATILE, .uid = 0
|
||||
+ },
|
||||
+ {
|
||||
+ { 0x86c77a67, 0x0b97, 0x4633, \
|
||||
+ { 0xa1, 0x87, 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7} },
|
||||
+ /* name size = (variable_name + \0) * sizeof(u16) */
|
||||
+ .name_size = 38, { 'F', 'm', 'p', 'D', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 'C', 'o', 'u', 'n', 't' },
|
||||
+ .attributes = EFI_VARIABLE_NON_VOLATILE, .uid = 0
|
||||
+ },
|
||||
+ {
|
||||
+ { 0x86c77a67, 0x0b97, 0x4633, \
|
||||
+ { 0xa1, 0x87, 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7} },
|
||||
+ /* name size = (variable_name + \0) * sizeof(u16) */
|
||||
+ .name_size = 26, { 'F', 'm', 'p', 'I', 'm', 'a', 'g', 'e', 'I', 'n', 'f', 'o' },
|
||||
+ .attributes = EFI_VARIABLE_NON_VOLATILE, .uid = 0
|
||||
+ },
|
||||
+ {
|
||||
+ { 0x86c77a67, 0x0b97, 0x4633, \
|
||||
+ { 0xa1, 0x87, 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7} },
|
||||
+ /* name size = (variable_name + \0) * sizeof(u16) */
|
||||
+ .name_size = 28, { 'F', 'm', 'p', 'I', 'm', 'a', 'g', 'e', 'N', 'a', 'm', 'e', '1' },
|
||||
+ .attributes = EFI_VARIABLE_NON_VOLATILE, .uid = 0
|
||||
+ },
|
||||
+ {
|
||||
+ { 0x86c77a67, 0x0b97, 0x4633, \
|
||||
+ { 0xa1, 0x87, 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7} },
|
||||
+ /* name size = (variable_name + \0) * sizeof(u16) */
|
||||
+ .name_size = 32, { 'F', 'm', 'p', 'V', 'e', 'r', 's', 'i', 'o', 'n', 'N', 'a', 'm', 'e', '1' },
|
||||
+ .attributes = EFI_VARIABLE_NON_VOLATILE, .uid = 0
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static psa_status_t protected_storage_set(struct rpc_caller *caller,
|
||||
+ psa_storage_uid_t uid, size_t data_length, const void *p_data)
|
||||
+{
|
||||
+ psa_status_t psa_status;
|
||||
+ psa_storage_create_flags_t create_flags = PSA_STORAGE_FLAG_NONE;
|
||||
+
|
||||
+ struct psa_invec in_vec[] = {
|
||||
+ { .base = psa_ptr_to_u32(&uid), .len = sizeof(uid) },
|
||||
+ { .base = psa_ptr_const_to_u32(p_data), .len = data_length },
|
||||
+ { .base = psa_ptr_to_u32(&create_flags), .len = sizeof(create_flags) },
|
||||
+ };
|
||||
+
|
||||
+ psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_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);
|
||||
+
|
||||
+ return psa_status;
|
||||
+}
|
||||
+
|
||||
+static psa_status_t protected_storage_get(struct rpc_caller *caller,
|
||||
+ psa_storage_uid_t uid, size_t data_size, void *p_data)
|
||||
+{
|
||||
+ psa_status_t psa_status;
|
||||
+ uint32_t offset = 0;
|
||||
+
|
||||
+ struct psa_invec in_vec[] = {
|
||||
+ { .base = psa_ptr_to_u32(&uid), .len = sizeof(uid) },
|
||||
+ { .base = psa_ptr_to_u32(&offset), .len = sizeof(offset) },
|
||||
+ };
|
||||
+
|
||||
+ struct psa_outvec out_vec[] = {
|
||||
+ { .base = psa_ptr_to_u32(p_data), .len = data_size },
|
||||
+ };
|
||||
+
|
||||
+ psa_status = psa_call(caller, TFM_PROTECTED_STORAGE_SERVICE_HANDLE,
|
||||
+ TFM_PS_ITS_GET, in_vec, IOVEC_LEN(in_vec),
|
||||
+ out_vec, IOVEC_LEN(out_vec));
|
||||
+
|
||||
+ if (psa_status == PSA_SUCCESS && out_vec[0].len != data_size) {
|
||||
+ EMSG("Return size does not match with expected size.");
|
||||
+ return PSA_ERROR_BUFFER_TOO_SMALL;
|
||||
+ }
|
||||
+
|
||||
+ return psa_status;
|
||||
+}
|
||||
+
|
||||
+static uint64_t name_hash(EFI_GUID *guid, size_t name_size,
|
||||
+ const int16_t *name)
|
||||
+{
|
||||
+ /* Using djb2 hash by Dan Bernstein */
|
||||
+ uint64_t hash = 5381;
|
||||
+
|
||||
+ /* Calculate hash over GUID */
|
||||
+ hash = ((hash << 5) + hash) + guid->Data1;
|
||||
+ hash = ((hash << 5) + hash) + guid->Data2;
|
||||
+ hash = ((hash << 5) + hash) + guid->Data3;
|
||||
+
|
||||
+ for (int i = 0; i < 8; ++i) {
|
||||
+
|
||||
+ hash = ((hash << 5) + hash) + guid->Data4[i];
|
||||
+ }
|
||||
+
|
||||
+ /* Extend to cover name up to but not including null terminator */
|
||||
+ for (int i = 0; i < name_size / sizeof(int16_t); ++i) {
|
||||
+
|
||||
+ if (!name[i]) break;
|
||||
+ hash = ((hash << 5) + hash) + name[i];
|
||||
+ }
|
||||
+
|
||||
+ return hash;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void initialize_metadata(void)
|
||||
+{
|
||||
+ for (int i = 0; i < FMP_VARIABLES_COUNT; i++) {
|
||||
+
|
||||
+ fmp_variables_metadata[i].uid = name_hash(
|
||||
+ &fmp_variables_metadata[i].guid,
|
||||
+ fmp_variables_metadata[i].name_size,
|
||||
+ fmp_variables_metadata[i].name);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void provision_fmp_variables_metadata(struct rpc_caller *caller)
|
||||
+{
|
||||
+ struct variable_metadata metadata;
|
||||
+ psa_status_t status;
|
||||
+ uint32_t dummy_values = 0xDEAD;
|
||||
+
|
||||
+ EMSG("Provisioning FMP metadata.");
|
||||
+
|
||||
+ initialize_metadata();
|
||||
+
|
||||
+ status = protected_storage_get(caller, VARIABLE_INDEX_STORAGE_UID,
|
||||
+ sizeof(struct variable_metadata), &metadata);
|
||||
+
|
||||
+ if (status == PSA_SUCCESS) {
|
||||
+ EMSG("UEFI variables store is already provisioned.");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Provision FMP variables with dummy values. */
|
||||
+ for (int i = 0; i < FMP_VARIABLES_COUNT; i++) {
|
||||
+ protected_storage_set(caller, fmp_variables_metadata[i].uid,
|
||||
+ sizeof(dummy_values), &dummy_values);
|
||||
+ }
|
||||
+
|
||||
+ status = protected_storage_set(caller, VARIABLE_INDEX_STORAGE_UID,
|
||||
+ sizeof(struct variable_metadata) * FMP_VARIABLES_COUNT,
|
||||
+ fmp_variables_metadata);
|
||||
+
|
||||
+ if (status != EFI_SUCCESS) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ EMSG("FMP metadata is provisioned");
|
||||
+}
|
||||
+
|
||||
+typedef struct {
|
||||
+ void *base;
|
||||
+ int len;
|
||||
+} variable_data_t;
|
||||
+
|
||||
+static variable_data_t fmp_variables_data[FMP_VARIABLES_COUNT];
|
||||
+
|
||||
+#define IMAGE_INFO_BUFFER_SIZE 256
|
||||
+static char image_info_buffer[IMAGE_INFO_BUFFER_SIZE];
|
||||
+#define IOCTL_CORSTONE1000_FMP_IMAGE_INFO 2
|
||||
+
|
||||
+static psa_status_t unpack_image_info(void *buffer, uint32_t size)
|
||||
+{
|
||||
+ typedef struct __attribute__ ((__packed__)) {
|
||||
+ uint32_t variable_count;
|
||||
+ uint32_t variable_size[FMP_VARIABLES_COUNT];
|
||||
+ uint8_t variable[];
|
||||
+ } packed_buffer_t;
|
||||
+
|
||||
+ packed_buffer_t *packed_buffer = buffer;
|
||||
+ int runner = 0;
|
||||
+
|
||||
+ if (packed_buffer->variable_count != FMP_VARIABLES_COUNT) {
|
||||
+ EMSG("Expected fmp varaibles = %u, but received = %u",
|
||||
+ FMP_VARIABLES_COUNT, packed_buffer->variable_count);
|
||||
+ return PSA_ERROR_PROGRAMMER_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < packed_buffer->variable_count; i++) {
|
||||
+ EMSG("FMP variable %d : size %u", i, packed_buffer->variable_size[i]);
|
||||
+ fmp_variables_data[i].base = &packed_buffer->variable[runner];
|
||||
+ fmp_variables_data[i].len= packed_buffer->variable_size[i];
|
||||
+ runner += packed_buffer->variable_size[i];
|
||||
+ }
|
||||
+
|
||||
+ return PSA_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+static psa_status_t get_image_info(struct rpc_caller *caller,
|
||||
+ psa_handle_t platform_service_handle)
|
||||
+{
|
||||
+ psa_status_t status;
|
||||
+ psa_handle_t handle;
|
||||
+ uint32_t ioctl_id = IOCTL_CORSTONE1000_FMP_IMAGE_INFO;
|
||||
+
|
||||
+ struct psa_invec in_vec[] = {
|
||||
+ { .base = &ioctl_id, .len = sizeof(ioctl_id) },
|
||||
+ };
|
||||
+
|
||||
+ struct psa_outvec out_vec[] = {
|
||||
+ { .base = image_info_buffer, .len = IMAGE_INFO_BUFFER_SIZE },
|
||||
+ };
|
||||
+
|
||||
+ memset(image_info_buffer, 0, IMAGE_INFO_BUFFER_SIZE);
|
||||
+
|
||||
+ psa_call(caller, platform_service_handle, PSA_IPC_CALL,
|
||||
+ in_vec, IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec));
|
||||
+
|
||||
+ status = unpack_image_info(image_info_buffer, IMAGE_INFO_BUFFER_SIZE);
|
||||
+ if (status != PSA_SUCCESS) {
|
||||
+ return status;
|
||||
+ }
|
||||
+
|
||||
+ return PSA_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+static psa_status_t set_image_info(struct rpc_caller *caller)
|
||||
+{
|
||||
+ psa_status_t status;
|
||||
+
|
||||
+ for (int i = 0; i < FMP_VARIABLES_COUNT; i++) {
|
||||
+
|
||||
+ status = protected_storage_set(caller,
|
||||
+ fmp_variables_metadata[i].uid,
|
||||
+ fmp_variables_data[i].len, fmp_variables_data[i].base);
|
||||
+
|
||||
+ if (status != PSA_SUCCESS) {
|
||||
+
|
||||
+ EMSG("FMP variable %d set unsuccessful", i);
|
||||
+ return status;
|
||||
+ }
|
||||
+
|
||||
+ EMSG("FMP variable %d set success", i);
|
||||
+ }
|
||||
+
|
||||
+ return PSA_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+void set_fmp_image_info(struct rpc_caller *caller,
|
||||
+ psa_handle_t platform_service_handle)
|
||||
+{
|
||||
+ psa_status_t status;
|
||||
+
|
||||
+ status = get_image_info(caller, platform_service_handle);
|
||||
+ if (status != PSA_SUCCESS) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ status = set_image_info(caller);
|
||||
+ if (status != PSA_SUCCESS) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+}
|
||||
diff --git a/components/service/capsule_update/provider/corstone1000_fmp_service.h b/components/service/capsule_update/provider/corstone1000_fmp_service.h
|
||||
new file mode 100644
|
||||
index 000000000000..95fba2a04d5c
|
||||
--- /dev/null
|
||||
+++ b/components/service/capsule_update/provider/corstone1000_fmp_service.h
|
||||
@@ -0,0 +1,26 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: BSD-3-Clause
|
||||
+ */
|
||||
+
|
||||
+#ifndef CORSTONE1000_FMP_SERVICE_H
|
||||
+#define CORSTONE1000_FMP_SERVICE_H
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
+#include <rpc_caller.h>
|
||||
+#include <psa/client.h>
|
||||
+
|
||||
+void provision_fmp_variables_metadata(struct rpc_caller *caller);
|
||||
+
|
||||
+void set_fmp_image_info(struct rpc_caller *caller,
|
||||
+ psa_handle_t platform_service_handle);
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+} /* extern "C" */
|
||||
+#endif
|
||||
+
|
||||
+#endif /* CORSTONE1000_FMP_SERVICE_H */
|
||||
--
|
||||
2.40.0
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
From 2aa665ad2cb13bc79b645db41686449a47593aab Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan <emekcan.aras@arm.com>
|
||||
Date: Thu, 3 Nov 2022 17:43:40 +0000
|
||||
Subject: [PATCH] smm_gateway: GetNextVariableName Fix
|
||||
|
||||
GetNextVariableName() should return EFI_BUFFER_TOO_SMALL
|
||||
when NameSize is smaller than the actual NameSize. It
|
||||
currently returns EFI_BUFFER_OUT_OF_RESOURCES due to setting
|
||||
max_name_len incorrectly. This fixes max_name_len error by
|
||||
replacing it with actual NameSize request by u-boot.
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
---
|
||||
.../service/smm_variable/provider/smm_variable_provider.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/components/service/smm_variable/provider/smm_variable_provider.c b/components/service/smm_variable/provider/smm_variable_provider.c
|
||||
index a9679b7e..6a4b6fa7 100644
|
||||
--- a/components/service/smm_variable/provider/smm_variable_provider.c
|
||||
+++ b/components/service/smm_variable/provider/smm_variable_provider.c
|
||||
@@ -197,7 +197,7 @@ static rpc_status_t get_next_variable_name_handler(void *context, struct call_re
|
||||
efi_status = uefi_variable_store_get_next_variable_name(
|
||||
&this_instance->variable_store,
|
||||
(SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME*)resp_buf->data,
|
||||
- max_name_len,
|
||||
+ ((SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME*)resp_buf->data)->NameSize,
|
||||
&resp_buf->data_len);
|
||||
}
|
||||
else {
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
From 041d30bb9cc6857f5ef26ded154ff7126dafaa20 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Fri, 16 Jun 2023 10:47:48 +0100
|
||||
Subject: [PATCH] plat: corstone1000: add compile definitions for
|
||||
ECP_DP_SECP512R1
|
||||
|
||||
Corstone1000 runs PSA-API tests which requires this ECC algorithm.
|
||||
Without setting this, corstone1000 fails psa-api-crypto-test no 243.
|
||||
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Upstream-Status: Pending
|
||||
|
||||
---
|
||||
platform/providers/arm/corstone1000/platform.cmake | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/platform/providers/arm/corstone1000/platform.cmake b/platform/providers/arm/corstone1000/platform.cmake
|
||||
index dbdf1097..e7a295dd 100644
|
||||
--- a/platform/providers/arm/corstone1000/platform.cmake
|
||||
+++ b/platform/providers/arm/corstone1000/platform.cmake
|
||||
@@ -14,3 +14,5 @@ target_compile_definitions(${TGT} PRIVATE
|
||||
SMM_VARIABLE_INDEX_STORAGE_UID=0x787
|
||||
SMM_GATEWAY_MAX_UEFI_VARIABLES=100
|
||||
)
|
||||
+
|
||||
+add_compile_definitions(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
From a71e99045996c57a4f80509ae8b770aa4f73f6c0 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Sun, 18 Jun 2023 14:38:42 +0100
|
||||
Subject: [PATCH] plat: corstone1000: Use the stateless platform service calls
|
||||
Calls to psa_connect is not needed and psa_call can be called directly with a
|
||||
pre defined handle.
|
||||
|
||||
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
|
||||
Upstream-Status: Inappropriate [Design is to revisted]
|
||||
---
|
||||
.../provider/capsule_update_provider.c | 24 ++++---------------
|
||||
.../provider/corstone1000_fmp_service.c | 10 ++++----
|
||||
.../provider/corstone1000_fmp_service.h | 3 +--
|
||||
components/service/common/include/psa/sid.h | 7 ++++++
|
||||
4 files changed, 17 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/components/service/capsule_update/provider/capsule_update_provider.c b/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
index 991a2235..6809249f 100644
|
||||
--- a/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
+++ b/components/service/capsule_update/provider/capsule_update_provider.c
|
||||
@@ -61,7 +61,6 @@ void capsule_update_provider_deinit(struct capsule_update_provider *context)
|
||||
static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller)
|
||||
{
|
||||
uint32_t ioctl_id;
|
||||
- psa_handle_t handle;
|
||||
rpc_status_t rpc_status = TS_RPC_CALL_ACCEPTED;
|
||||
|
||||
struct psa_invec in_vec[] = {
|
||||
@@ -79,31 +78,18 @@ static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller)
|
||||
case CAPSULE_UPDATE_REQUEST:
|
||||
/* Openamp call with IOCTL for firmware update*/
|
||||
ioctl_id = IOCTL_CORSTONE1000_FWU_FLASH_IMAGES;
|
||||
- handle = psa_connect(caller, TFM_SP_PLATFORM_IOCTL_SID,
|
||||
- TFM_SP_PLATFORM_IOCTL_VERSION);
|
||||
- if (handle <= 0) {
|
||||
- EMSG("%s Invalid handle", __func__);
|
||||
- rpc_status = TS_RPC_ERROR_INVALID_PARAMETER;
|
||||
- return rpc_status;
|
||||
- }
|
||||
- psa_call(caller,handle, PSA_IPC_CALL,
|
||||
+ psa_call(caller,TFM_PLATFORM_SERVICE_HANDLE, TFM_PLATFORM_API_ID_IOCTL,
|
||||
in_vec,IOVEC_LEN(in_vec), NULL, 0);
|
||||
- set_fmp_image_info(caller, handle);
|
||||
+ set_fmp_image_info(caller);
|
||||
break;
|
||||
|
||||
case KERNEL_STARTED_EVENT:
|
||||
ioctl_id = IOCTL_CORSTONE1000_FWU_HOST_ACK;
|
||||
/*openamp call with IOCTL for kernel start*/
|
||||
- handle = psa_connect(caller, TFM_SP_PLATFORM_IOCTL_SID,
|
||||
- TFM_SP_PLATFORM_IOCTL_VERSION);
|
||||
- if (handle <= 0) {
|
||||
- EMSG("%s Invalid handle", __func__);
|
||||
- rpc_status = TS_RPC_ERROR_INVALID_PARAMETER;
|
||||
- return rpc_status;
|
||||
- }
|
||||
- psa_call(caller,handle, PSA_IPC_CALL,
|
||||
+
|
||||
+ psa_call(caller,TFM_PLATFORM_SERVICE_HANDLE, TFM_PLATFORM_API_ID_IOCTL,
|
||||
in_vec,IOVEC_LEN(in_vec), NULL, 0);
|
||||
- set_fmp_image_info(caller, handle);
|
||||
+ set_fmp_image_info(caller);
|
||||
break;
|
||||
default:
|
||||
EMSG("%s unsupported opcode", __func__);
|
||||
diff --git a/components/service/capsule_update/provider/corstone1000_fmp_service.c b/components/service/capsule_update/provider/corstone1000_fmp_service.c
|
||||
index 6a7a47a7..d811af9f 100644
|
||||
--- a/components/service/capsule_update/provider/corstone1000_fmp_service.c
|
||||
+++ b/components/service/capsule_update/provider/corstone1000_fmp_service.c
|
||||
@@ -238,8 +238,7 @@ static psa_status_t unpack_image_info(void *buffer, uint32_t size)
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
-static psa_status_t get_image_info(struct rpc_caller *caller,
|
||||
- psa_handle_t platform_service_handle)
|
||||
+static psa_status_t get_image_info(struct rpc_caller *caller)
|
||||
{
|
||||
psa_status_t status;
|
||||
psa_handle_t handle;
|
||||
@@ -255,7 +254,7 @@ static psa_status_t get_image_info(struct rpc_caller *caller,
|
||||
|
||||
memset(image_info_buffer, 0, IMAGE_INFO_BUFFER_SIZE);
|
||||
|
||||
- psa_call(caller, platform_service_handle, PSA_IPC_CALL,
|
||||
+ psa_call(caller, TFM_PLATFORM_SERVICE_HANDLE, TFM_PLATFORM_API_ID_IOCTL,
|
||||
in_vec, IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec));
|
||||
|
||||
status = unpack_image_info(image_info_buffer, IMAGE_INFO_BUFFER_SIZE);
|
||||
@@ -288,12 +287,11 @@ static psa_status_t set_image_info(struct rpc_caller *caller)
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
-void set_fmp_image_info(struct rpc_caller *caller,
|
||||
- psa_handle_t platform_service_handle)
|
||||
+void set_fmp_image_info(struct rpc_caller *caller)
|
||||
{
|
||||
psa_status_t status;
|
||||
|
||||
- status = get_image_info(caller, platform_service_handle);
|
||||
+ status = get_image_info(caller);
|
||||
if (status != PSA_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
diff --git a/components/service/capsule_update/provider/corstone1000_fmp_service.h b/components/service/capsule_update/provider/corstone1000_fmp_service.h
|
||||
index 95fba2a0..963223e8 100644
|
||||
--- a/components/service/capsule_update/provider/corstone1000_fmp_service.h
|
||||
+++ b/components/service/capsule_update/provider/corstone1000_fmp_service.h
|
||||
@@ -16,8 +16,7 @@ extern "C" {
|
||||
|
||||
void provision_fmp_variables_metadata(struct rpc_caller *caller);
|
||||
|
||||
-void set_fmp_image_info(struct rpc_caller *caller,
|
||||
- psa_handle_t platform_service_handle);
|
||||
+void set_fmp_image_info(struct rpc_caller *caller);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
diff --git a/components/service/common/include/psa/sid.h b/components/service/common/include/psa/sid.h
|
||||
index 5aaa659d..fc3a4fb0 100644
|
||||
--- a/components/service/common/include/psa/sid.h
|
||||
+++ b/components/service/common/include/psa/sid.h
|
||||
@@ -40,6 +40,13 @@ extern "C" {
|
||||
#define TFM_CRYPTO_VERSION (1U)
|
||||
#define TFM_CRYPTO_HANDLE (0x40000100U)
|
||||
|
||||
+/******** TFM_PLATFORM_SERVICE *******/
|
||||
+#define TFM_PLATFORM_API_ID_IOCTL (1013)
|
||||
+#define TFM_PLATFORM_SERVICE_HANDLE (0x40000105U)
|
||||
+
|
||||
+/**
|
||||
+ * \brief Define a progressive numerical value for each SID which can be used
|
||||
+ * when dispatching the requests to the service
|
||||
/******** TFM_SP_PLATFORM ********/
|
||||
#define TFM_SP_PLATFORM_SYSTEM_RESET_SID (0x00000040U)
|
||||
#define TFM_SP_PLATFORM_SYSTEM_RESET_VERSION (1U)
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
From b5b31064959665f4cc616733be3d989ae4356636 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Sun, 18 Jun 2023 16:05:27 +0100
|
||||
Subject: [PATCH] plat: corstone1000: Initialize capsule update provider
|
||||
|
||||
Initializes the capsule update service provider in se-proxy-sp.c deployment
|
||||
for corstone1000.
|
||||
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Upstream-Status: Inappropriate [Design is to revisted]
|
||||
|
||||
---
|
||||
deployments/se-proxy/env/commonsp/se_proxy_sp.c | 3 +++
|
||||
.../infra/corstone1000/service_proxy_factory.c | 17 +++++++++++++++++
|
||||
.../se-proxy/infra/service_proxy_factory.h | 1 +
|
||||
3 files changed, 21 insertions(+)
|
||||
|
||||
diff --git a/deployments/se-proxy/env/commonsp/se_proxy_sp.c b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
|
||||
index 45fcb385..dc2a9d49 100644
|
||||
--- a/deployments/se-proxy/env/commonsp/se_proxy_sp.c
|
||||
+++ b/deployments/se-proxy/env/commonsp/se_proxy_sp.c
|
||||
@@ -77,6 +77,9 @@ void __noreturn sp_main(struct ffa_init_info *init_info)
|
||||
}
|
||||
rpc_demux_attach(&rpc_demux, SE_PROXY_INTERFACE_ID_ATTEST, rpc_iface);
|
||||
|
||||
+ rpc_iface = capsule_update_proxy_create();
|
||||
+ rpc_demux_attach(&rpc_demux, SE_PROXY_INTERFACE_ID_CAPSULE_UPDATE, rpc_iface);
|
||||
+
|
||||
/* End of boot phase */
|
||||
result = sp_msg_wait(&req_msg);
|
||||
if (result != SP_RESULT_OK) {
|
||||
diff --git a/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c b/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c
|
||||
index bacab1de..32d88c97 100644
|
||||
--- a/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c
|
||||
+++ b/deployments/se-proxy/infra/corstone1000/service_proxy_factory.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <service/crypto/factory/crypto_provider_factory.h>
|
||||
#include <service/secure_storage/frontend/secure_storage_provider/secure_storage_provider.h>
|
||||
#include <trace.h>
|
||||
+#include <service/capsule_update/provider/capsule_update_provider.h>
|
||||
|
||||
/* backends */
|
||||
#include <service/crypto/backend/psa_ipc/crypto_ipc_backend.h>
|
||||
@@ -94,3 +95,19 @@ struct rpc_interface *its_proxy_create(void)
|
||||
|
||||
return secure_storage_provider_init(&its_provider, backend);
|
||||
}
|
||||
+
|
||||
+struct rpc_interface *capsule_update_proxy_create(void)
|
||||
+{
|
||||
+ static struct capsule_update_provider capsule_update_provider;
|
||||
+ static struct rpc_caller *capsule_update_caller;
|
||||
+
|
||||
+ capsule_update_caller = psa_ipc_caller_init(&psa_ipc);
|
||||
+
|
||||
+ if (!capsule_update_caller)
|
||||
+ return NULL;
|
||||
+
|
||||
+ capsule_update_provider.client.caller = capsule_update_caller;
|
||||
+
|
||||
+ return capsule_update_provider_init(&capsule_update_provider);
|
||||
+}
|
||||
+
|
||||
diff --git a/deployments/se-proxy/infra/service_proxy_factory.h b/deployments/se-proxy/infra/service_proxy_factory.h
|
||||
index 298d407a..02aa7fe2 100644
|
||||
--- a/deployments/se-proxy/infra/service_proxy_factory.h
|
||||
+++ b/deployments/se-proxy/infra/service_proxy_factory.h
|
||||
@@ -17,6 +17,7 @@ struct rpc_interface *attest_proxy_create(void);
|
||||
struct rpc_interface *crypto_proxy_create(void);
|
||||
struct rpc_interface *ps_proxy_create(void);
|
||||
struct rpc_interface *its_proxy_create(void);
|
||||
+struct rpc_interface *capsule_update_proxy_create(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
Upstream-Status: Pending [Not submitted to upstream yet]
|
||||
Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
|
||||
|
||||
From c1bcab09bb5b73e0f7131d9433f5e23c3943f007 Mon Sep 17 00:00:00 2001
|
||||
From: Satish Kumar <satish.kumar01@arm.com>
|
||||
Date: Sat, 11 Dec 2021 11:06:57 +0000
|
||||
Subject: [PATCH] corstone1000: port crypto config
|
||||
|
||||
|
||||
Signed-off-by: Satish Kumar <satish.kumar01@arm.com>
|
||||
|
||||
%% original patch: 0002-corstone1000-port-crypto-config.patch
|
||||
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
.../nspe/pal_crypto_config.h | 81 +++++++++++++++----
|
||||
1 file changed, 65 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h b/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
index 218a94c69502..c6d4aadd8476 100755
|
||||
--- a/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
+++ b/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
@@ -34,10 +34,14 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_RSA
|
||||
#define ARCH_TEST_RSA_1024
|
||||
#define ARCH_TEST_RSA_2048
|
||||
#define ARCH_TEST_RSA_3072
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_ECC
|
||||
@@ -50,11 +54,17 @@
|
||||
* Requires: ARCH_TEST_ECC
|
||||
* Comment macros to disable the curve
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
#define ARCH_TEST_ECC
|
||||
#define ARCH_TEST_ECC_CURVE_SECP192R1
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_ECC_CURVE_SECP224R1
|
||||
+#endif
|
||||
#define ARCH_TEST_ECC_CURVE_SECP256R1
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_ECC_CURVE_SECP384R1
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_AES
|
||||
@@ -78,10 +88,10 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
-#define ARCH_TEST_DES
|
||||
-#define ARCH_TEST_DES_1KEY
|
||||
-#define ARCH_TEST_DES_2KEY
|
||||
-#define ARCH_TEST_DES_3KEY
|
||||
+//#define ARCH_TEST_DES
|
||||
+//#define ARCH_TEST_DES_1KEY
|
||||
+//#define ARCH_TEST_DES_2KEY
|
||||
+//#define ARCH_TEST_DES_3KEY
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_RAW
|
||||
@@ -104,7 +114,7 @@
|
||||
*
|
||||
* Enable the ARC4 key type.
|
||||
*/
|
||||
-#define ARCH_TEST_ARC4
|
||||
+//#define ARCH_TEST_ARC4
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_CIPHER_MODE_CTR
|
||||
@@ -113,7 +123,11 @@
|
||||
*
|
||||
* Requires: ARCH_TEST_CIPHER
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_CIPHER_MODE_CTR
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_CIPHER_MODE_CFB
|
||||
@@ -138,7 +152,11 @@
|
||||
*
|
||||
* Requires: ARCH_TEST_CIPHER, ARCH_TEST_AES, ARCH_TEST_CIPHER_MODE_CTR
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_CTR_AES
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_CBC_AES
|
||||
@@ -157,7 +175,11 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_CBC_NO_PADDING
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_CFB_AES
|
||||
@@ -177,11 +199,15 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_PKCS1V15
|
||||
#define ARCH_TEST_RSA_PKCS1V15_SIGN
|
||||
#define ARCH_TEST_RSA_PKCS1V15_SIGN_RAW
|
||||
#define ARCH_TEST_RSA_PKCS1V15_CRYPT
|
||||
#define ARCH_TEST_RSA_OAEP
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_CBC_PKCS7
|
||||
@@ -190,7 +216,11 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_CBC_PKCS7
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_ASYMMETRIC_ENCRYPTION
|
||||
@@ -227,21 +257,27 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
-// #define ARCH_TEST_MD2
|
||||
-// #define ARCH_TEST_MD4
|
||||
-#define ARCH_TEST_MD5
|
||||
-#define ARCH_TEST_RIPEMD160
|
||||
-#define ARCH_TEST_SHA1
|
||||
+//#define ARCH_TEST_MD2
|
||||
+//#define ARCH_TEST_MD4
|
||||
+//#define ARCH_TEST_MD5
|
||||
+//#define ARCH_TEST_RIPEMD160
|
||||
+//#define ARCH_TEST_SHA1
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
#define ARCH_TEST_SHA224
|
||||
+#endif
|
||||
#define ARCH_TEST_SHA256
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_SHA384
|
||||
#define ARCH_TEST_SHA512
|
||||
-// #define ARCH_TEST_SHA512_224
|
||||
-// #define ARCH_TEST_SHA512_256
|
||||
-// #define ARCH_TEST_SHA3_224
|
||||
-// #define ARCH_TEST_SHA3_256
|
||||
-// #define ARCH_TEST_SHA3_384
|
||||
-// #define ARCH_TEST_SHA3_512
|
||||
+#endif
|
||||
+#endif
|
||||
+//#define ARCH_TEST_SHA512_224
|
||||
+//#define ARCH_TEST_SHA512_256
|
||||
+//#define ARCH_TEST_SHA3_224
|
||||
+//#define ARCH_TEST_SHA3_256
|
||||
+//#define ARCH_TEST_SHA3_384
|
||||
+//#define ARCH_TEST_SHA3_512
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_HKDF
|
||||
@@ -270,7 +306,12 @@
|
||||
*
|
||||
* Comment macros to disable the types
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_CMAC
|
||||
+#endif
|
||||
+#endif
|
||||
+//#define ARCH_TEST_GMAC
|
||||
#define ARCH_TEST_HMAC
|
||||
|
||||
/**
|
||||
@@ -290,7 +331,11 @@
|
||||
* Requires: ARCH_TEST_AES
|
||||
*
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
+#ifndef TF_M_PROFILE_MEDIUM
|
||||
#define ARCH_TEST_GCM
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_TRUNCATED_MAC
|
||||
@@ -309,7 +354,9 @@
|
||||
*
|
||||
* Requires: ARCH_TEST_ECC
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
#define ARCH_TEST_ECDH
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_ECDSA
|
||||
@@ -317,7 +364,9 @@
|
||||
* Enable the elliptic curve DSA library.
|
||||
* Requires: ARCH_TEST_ECC
|
||||
*/
|
||||
+#ifndef TF_M_PROFILE_SMALL
|
||||
#define ARCH_TEST_ECDSA
|
||||
+#endif
|
||||
|
||||
/**
|
||||
* \def ARCH_TEST_DETERMINISTIC_ECDSA
|
||||
--
|
||||
2.38.0
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
From 1bc041813df89a1be953d0ba3471e608f6fa7ed8 Mon Sep 17 00:00:00 2001
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Date: Thu, 9 Feb 2023 20:54:40 +0000
|
||||
Subject: [PATCH] corstone1000: Disable obsolete algorithms
|
||||
|
||||
curves of size <255 are obsolete algorithms
|
||||
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Upstream-Status: Inappropriate [Discussions of having these configs
|
||||
in a separate target is ongoing]
|
||||
---
|
||||
.../targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h b/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
index c6d4aad..1d9b356 100755
|
||||
--- a/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
+++ b/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
@@ -66,6 +66,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+/* curves of size <255 are obsolete algorithms, should be disabled. */
|
||||
+#undef ARCH_TEST_ECC_CURVE_SECP192R1
|
||||
+#undef ARCH_TEST_ECC_CURVE_SECP224R1
|
||||
+
|
||||
/**
|
||||
* \def ARCH_TEST_AES
|
||||
*
|
||||
--
|
||||
2.25.1
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
From abdea43f1de61a0e76b13890cb403f7955998b02 Mon Sep 17 00:00:00 2001
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Date: Thu, 9 Feb 2023 21:06:22 +0000
|
||||
Subject: [PATCH] corstone1000: Disable SHA512/384
|
||||
|
||||
SHA512 and SHA384 is not available on Cryptocell (hardware accelerator)
|
||||
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Upstream-Status: Inappropriate [Discussions of having these configs
|
||||
in a separate target is ongoing]
|
||||
---
|
||||
.../targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h b/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
index 1d9b356..d6d552a 100755
|
||||
--- a/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
+++ b/api-tests/platform/targets/tgt_dev_apis_linux/nspe/pal_crypto_config.h
|
||||
@@ -272,8 +272,8 @@
|
||||
#define ARCH_TEST_SHA256
|
||||
#ifndef TF_M_PROFILE_SMALL
|
||||
#ifndef TF_M_PROFILE_MEDIUM
|
||||
-#define ARCH_TEST_SHA384
|
||||
-#define ARCH_TEST_SHA512
|
||||
+// #define ARCH_TEST_SHA384
|
||||
+// #define ARCH_TEST_SHA512
|
||||
#endif
|
||||
#endif
|
||||
//#define ARCH_TEST_SHA512_224
|
||||
--
|
||||
2.25.1
|
||||
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
From 03d97c104f2d68cffd1bfc48cd62727e13a64712 Mon Sep 17 00:00:00 2001
|
||||
From: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
Date: Fri, 14 Oct 2022 17:42:52 +0100
|
||||
Subject: [PATCH] newlib: memcpy: remove optimized version
|
||||
|
||||
When creating messages packed to send over openamp we may need
|
||||
to do some copy in unaligned address, because of that we may
|
||||
not always use the assembler optimized version, which will
|
||||
trough a data-abort on aligned address exception.
|
||||
|
||||
So, we may just use the version in string.h (the same used in
|
||||
optee-os) that will take care to check and use different
|
||||
optimization based on given source or destination address's.
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
newlib/libc/machine/aarch64/memcpy-stub.c | 2 +-
|
||||
newlib/libc/machine/aarch64/memcpy.S | 166 ----------------------
|
||||
2 files changed, 1 insertion(+), 167 deletions(-)
|
||||
|
||||
diff --git a/newlib/libc/machine/aarch64/memcpy-stub.c b/newlib/libc/machine/aarch64/memcpy-stub.c
|
||||
index cd6d72a8b8af..5f2b7968c7fc 100644
|
||||
--- a/newlib/libc/machine/aarch64/memcpy-stub.c
|
||||
+++ b/newlib/libc/machine/aarch64/memcpy-stub.c
|
||||
@@ -27,5 +27,5 @@
|
||||
#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
|
||||
# include "../../string/memcpy.c"
|
||||
#else
|
||||
-/* See memcpy.S */
|
||||
+# include "../../string/memcpy.c"
|
||||
#endif
|
||||
diff --git a/newlib/libc/machine/aarch64/memcpy.S b/newlib/libc/machine/aarch64/memcpy.S
|
||||
index 463bad0a1816..2a1460546374 100644
|
||||
--- a/newlib/libc/machine/aarch64/memcpy.S
|
||||
+++ b/newlib/libc/machine/aarch64/memcpy.S
|
||||
@@ -61,170 +61,4 @@
|
||||
#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED))
|
||||
/* See memcpy-stub.c */
|
||||
#else
|
||||
-
|
||||
-#define dstin x0
|
||||
-#define src x1
|
||||
-#define count x2
|
||||
-#define dst x3
|
||||
-#define srcend x4
|
||||
-#define dstend x5
|
||||
-#define A_l x6
|
||||
-#define A_lw w6
|
||||
-#define A_h x7
|
||||
-#define A_hw w7
|
||||
-#define B_l x8
|
||||
-#define B_lw w8
|
||||
-#define B_h x9
|
||||
-#define C_l x10
|
||||
-#define C_h x11
|
||||
-#define D_l x12
|
||||
-#define D_h x13
|
||||
-#define E_l src
|
||||
-#define E_h count
|
||||
-#define F_l srcend
|
||||
-#define F_h dst
|
||||
-#define tmp1 x9
|
||||
-
|
||||
-#define L(l) .L ## l
|
||||
-
|
||||
- .macro def_fn f p2align=0
|
||||
- .text
|
||||
- .p2align \p2align
|
||||
- .global \f
|
||||
- .type \f, %function
|
||||
-\f:
|
||||
- .endm
|
||||
-
|
||||
-/* Copies are split into 3 main cases: small copies of up to 16 bytes,
|
||||
- medium copies of 17..96 bytes which are fully unrolled. Large copies
|
||||
- of more than 96 bytes align the destination and use an unrolled loop
|
||||
- processing 64 bytes per iteration.
|
||||
- Small and medium copies read all data before writing, allowing any
|
||||
- kind of overlap, and memmove tailcalls memcpy for these cases as
|
||||
- well as non-overlapping copies.
|
||||
-*/
|
||||
-
|
||||
-def_fn memcpy p2align=6
|
||||
- prfm PLDL1KEEP, [src]
|
||||
- add srcend, src, count
|
||||
- add dstend, dstin, count
|
||||
- cmp count, 16
|
||||
- b.ls L(copy16)
|
||||
- cmp count, 96
|
||||
- b.hi L(copy_long)
|
||||
-
|
||||
- /* Medium copies: 17..96 bytes. */
|
||||
- sub tmp1, count, 1
|
||||
- ldp A_l, A_h, [src]
|
||||
- tbnz tmp1, 6, L(copy96)
|
||||
- ldp D_l, D_h, [srcend, -16]
|
||||
- tbz tmp1, 5, 1f
|
||||
- ldp B_l, B_h, [src, 16]
|
||||
- ldp C_l, C_h, [srcend, -32]
|
||||
- stp B_l, B_h, [dstin, 16]
|
||||
- stp C_l, C_h, [dstend, -32]
|
||||
-1:
|
||||
- stp A_l, A_h, [dstin]
|
||||
- stp D_l, D_h, [dstend, -16]
|
||||
- ret
|
||||
-
|
||||
- .p2align 4
|
||||
- /* Small copies: 0..16 bytes. */
|
||||
-L(copy16):
|
||||
- cmp count, 8
|
||||
- b.lo 1f
|
||||
- ldr A_l, [src]
|
||||
- ldr A_h, [srcend, -8]
|
||||
- str A_l, [dstin]
|
||||
- str A_h, [dstend, -8]
|
||||
- ret
|
||||
- .p2align 4
|
||||
-1:
|
||||
- tbz count, 2, 1f
|
||||
- ldr A_lw, [src]
|
||||
- ldr A_hw, [srcend, -4]
|
||||
- str A_lw, [dstin]
|
||||
- str A_hw, [dstend, -4]
|
||||
- ret
|
||||
-
|
||||
- /* Copy 0..3 bytes. Use a branchless sequence that copies the same
|
||||
- byte 3 times if count==1, or the 2nd byte twice if count==2. */
|
||||
-1:
|
||||
- cbz count, 2f
|
||||
- lsr tmp1, count, 1
|
||||
- ldrb A_lw, [src]
|
||||
- ldrb A_hw, [srcend, -1]
|
||||
- ldrb B_lw, [src, tmp1]
|
||||
- strb A_lw, [dstin]
|
||||
- strb B_lw, [dstin, tmp1]
|
||||
- strb A_hw, [dstend, -1]
|
||||
-2: ret
|
||||
-
|
||||
- .p2align 4
|
||||
- /* Copy 64..96 bytes. Copy 64 bytes from the start and
|
||||
- 32 bytes from the end. */
|
||||
-L(copy96):
|
||||
- ldp B_l, B_h, [src, 16]
|
||||
- ldp C_l, C_h, [src, 32]
|
||||
- ldp D_l, D_h, [src, 48]
|
||||
- ldp E_l, E_h, [srcend, -32]
|
||||
- ldp F_l, F_h, [srcend, -16]
|
||||
- stp A_l, A_h, [dstin]
|
||||
- stp B_l, B_h, [dstin, 16]
|
||||
- stp C_l, C_h, [dstin, 32]
|
||||
- stp D_l, D_h, [dstin, 48]
|
||||
- stp E_l, E_h, [dstend, -32]
|
||||
- stp F_l, F_h, [dstend, -16]
|
||||
- ret
|
||||
-
|
||||
- /* Align DST to 16 byte alignment so that we don't cross cache line
|
||||
- boundaries on both loads and stores. There are at least 96 bytes
|
||||
- to copy, so copy 16 bytes unaligned and then align. The loop
|
||||
- copies 64 bytes per iteration and prefetches one iteration ahead. */
|
||||
-
|
||||
- .p2align 4
|
||||
-L(copy_long):
|
||||
- and tmp1, dstin, 15
|
||||
- bic dst, dstin, 15
|
||||
- ldp D_l, D_h, [src]
|
||||
- sub src, src, tmp1
|
||||
- add count, count, tmp1 /* Count is now 16 too large. */
|
||||
- ldp A_l, A_h, [src, 16]
|
||||
- stp D_l, D_h, [dstin]
|
||||
- ldp B_l, B_h, [src, 32]
|
||||
- ldp C_l, C_h, [src, 48]
|
||||
- ldp D_l, D_h, [src, 64]!
|
||||
- subs count, count, 128 + 16 /* Test and readjust count. */
|
||||
- b.ls 2f
|
||||
-1:
|
||||
- stp A_l, A_h, [dst, 16]
|
||||
- ldp A_l, A_h, [src, 16]
|
||||
- stp B_l, B_h, [dst, 32]
|
||||
- ldp B_l, B_h, [src, 32]
|
||||
- stp C_l, C_h, [dst, 48]
|
||||
- ldp C_l, C_h, [src, 48]
|
||||
- stp D_l, D_h, [dst, 64]!
|
||||
- ldp D_l, D_h, [src, 64]!
|
||||
- subs count, count, 64
|
||||
- b.hi 1b
|
||||
-
|
||||
- /* Write the last full set of 64 bytes. The remainder is at most 64
|
||||
- bytes, so it is safe to always copy 64 bytes from the end even if
|
||||
- there is just 1 byte left. */
|
||||
-2:
|
||||
- ldp E_l, E_h, [srcend, -64]
|
||||
- stp A_l, A_h, [dst, 16]
|
||||
- ldp A_l, A_h, [srcend, -48]
|
||||
- stp B_l, B_h, [dst, 32]
|
||||
- ldp B_l, B_h, [srcend, -32]
|
||||
- stp C_l, C_h, [dst, 48]
|
||||
- ldp C_l, C_h, [srcend, -16]
|
||||
- stp D_l, D_h, [dst, 64]
|
||||
- stp E_l, E_h, [dstend, -64]
|
||||
- stp A_l, A_h, [dstend, -48]
|
||||
- stp B_l, B_h, [dstend, -32]
|
||||
- stp C_l, C_h, [dstend, -16]
|
||||
- ret
|
||||
-
|
||||
- .size memcpy, . - memcpy
|
||||
#endif
|
||||
--
|
||||
2.38.0
|
||||
|
||||
Reference in New Issue
Block a user