1
0
mirror of https://git.yoctoproject.org/meta-arm synced 2026-05-07 16:59:30 +00:00

arm/trusted-services: Remove patches merged upstream

Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
Anton Antonov
2022-10-11 11:59:51 +01:00
committed by Jon Mason
parent 545ba524b8
commit dc4c85ccbb
9 changed files with 2 additions and 5178 deletions
@@ -1,349 +0,0 @@
From 2cd802030ab59787a34c0f6684c16848befabafa Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Wed, 15 Jun 2022 12:47:37 +0200
Subject: [PATCH 17/24] Move libsp mocks into separate component
Enable deployments to include libsp mocks in tests by simply adding
the newly created libsp mock component.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I40805fd49362c6cc71b5b34f9ba888d27ce01ed8
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../messaging/ffa/libsp/mock/component.cmake | 27 ++++++++++
.../ffa/libsp/{test => mock}/mock_assert.cpp | 0
.../ffa/libsp/{test => mock}/mock_assert.h | 0
.../ffa/libsp/{test => mock}/mock_ffa_api.cpp | 0
.../ffa/libsp/{test => mock}/mock_ffa_api.h | 0
.../{test => mock}/mock_ffa_internal_api.cpp | 0
.../{test => mock}/mock_ffa_internal_api.h | 0
.../ffa/libsp/{test => mock}/mock_sp_rxtx.cpp | 0
.../ffa/libsp/{test => mock}/mock_sp_rxtx.h | 0
.../{ => mock}/test/test_mock_assert.cpp | 0
.../{ => mock}/test/test_mock_ffa_api.cpp | 0
.../test/test_mock_ffa_internal_api.cpp | 0
.../{ => mock}/test/test_mock_sp_rxtx.cpp | 0
components/messaging/ffa/libsp/tests.cmake | 51 +++++++++++--------
.../mm_communicate/endpoint/sp/tests.cmake | 6 +--
.../frontend/mm_communicate/tests.cmake | 6 +--
16 files changed, 64 insertions(+), 26 deletions(-)
create mode 100644 components/messaging/ffa/libsp/mock/component.cmake
rename components/messaging/ffa/libsp/{test => mock}/mock_assert.cpp (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_assert.h (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_ffa_api.cpp (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_ffa_api.h (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_ffa_internal_api.cpp (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_ffa_internal_api.h (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_sp_rxtx.cpp (100%)
rename components/messaging/ffa/libsp/{test => mock}/mock_sp_rxtx.h (100%)
rename components/messaging/ffa/libsp/{ => mock}/test/test_mock_assert.cpp (100%)
rename components/messaging/ffa/libsp/{ => mock}/test/test_mock_ffa_api.cpp (100%)
rename components/messaging/ffa/libsp/{ => mock}/test/test_mock_ffa_internal_api.cpp (100%)
rename components/messaging/ffa/libsp/{ => mock}/test/test_mock_sp_rxtx.cpp (100%)
diff --git a/components/messaging/ffa/libsp/mock/component.cmake b/components/messaging/ffa/libsp/mock/component.cmake
new file mode 100644
index 0000000..03b8006
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/component.cmake
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, 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}/mock_assert.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/mock_ffa_api.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/mock_ffa_internal_api.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/mock_sp_rxtx.cpp"
+ )
+
+target_include_directories(${TGT}
+ PUBLIC
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/../include
+)
+
+target_compile_definitions(${TGT}
+ PUBLIC
+ "ARM64=1"
+)
\ No newline at end of file
diff --git a/components/messaging/ffa/libsp/test/mock_assert.cpp b/components/messaging/ffa/libsp/mock/mock_assert.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_assert.cpp
rename to components/messaging/ffa/libsp/mock/mock_assert.cpp
diff --git a/components/messaging/ffa/libsp/test/mock_assert.h b/components/messaging/ffa/libsp/mock/mock_assert.h
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_assert.h
rename to components/messaging/ffa/libsp/mock/mock_assert.h
diff --git a/components/messaging/ffa/libsp/test/mock_ffa_api.cpp b/components/messaging/ffa/libsp/mock/mock_ffa_api.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_ffa_api.cpp
rename to components/messaging/ffa/libsp/mock/mock_ffa_api.cpp
diff --git a/components/messaging/ffa/libsp/test/mock_ffa_api.h b/components/messaging/ffa/libsp/mock/mock_ffa_api.h
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_ffa_api.h
rename to components/messaging/ffa/libsp/mock/mock_ffa_api.h
diff --git a/components/messaging/ffa/libsp/test/mock_ffa_internal_api.cpp b/components/messaging/ffa/libsp/mock/mock_ffa_internal_api.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_ffa_internal_api.cpp
rename to components/messaging/ffa/libsp/mock/mock_ffa_internal_api.cpp
diff --git a/components/messaging/ffa/libsp/test/mock_ffa_internal_api.h b/components/messaging/ffa/libsp/mock/mock_ffa_internal_api.h
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_ffa_internal_api.h
rename to components/messaging/ffa/libsp/mock/mock_ffa_internal_api.h
diff --git a/components/messaging/ffa/libsp/test/mock_sp_rxtx.cpp b/components/messaging/ffa/libsp/mock/mock_sp_rxtx.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_sp_rxtx.cpp
rename to components/messaging/ffa/libsp/mock/mock_sp_rxtx.cpp
diff --git a/components/messaging/ffa/libsp/test/mock_sp_rxtx.h b/components/messaging/ffa/libsp/mock/mock_sp_rxtx.h
similarity index 100%
rename from components/messaging/ffa/libsp/test/mock_sp_rxtx.h
rename to components/messaging/ffa/libsp/mock/mock_sp_rxtx.h
diff --git a/components/messaging/ffa/libsp/test/test_mock_assert.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_assert.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/test_mock_assert.cpp
rename to components/messaging/ffa/libsp/mock/test/test_mock_assert.cpp
diff --git a/components/messaging/ffa/libsp/test/test_mock_ffa_api.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_ffa_api.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/test_mock_ffa_api.cpp
rename to components/messaging/ffa/libsp/mock/test/test_mock_ffa_api.cpp
diff --git a/components/messaging/ffa/libsp/test/test_mock_ffa_internal_api.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_ffa_internal_api.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/test_mock_ffa_internal_api.cpp
rename to components/messaging/ffa/libsp/mock/test/test_mock_ffa_internal_api.cpp
diff --git a/components/messaging/ffa/libsp/test/test_mock_sp_rxtx.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_sp_rxtx.cpp
similarity index 100%
rename from components/messaging/ffa/libsp/test/test_mock_sp_rxtx.cpp
rename to components/messaging/ffa/libsp/mock/test/test_mock_sp_rxtx.cpp
diff --git a/components/messaging/ffa/libsp/tests.cmake b/components/messaging/ffa/libsp/tests.cmake
index d851442..296ae46 100644
--- a/components/messaging/ffa/libsp/tests.cmake
+++ b/components/messaging/ffa/libsp/tests.cmake
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -9,10 +9,11 @@ include(UnitTest)
unit_test_add_suite(
NAME libsp_mock_assert
SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_assert.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/test_mock_assert.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_assert.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/test/test_mock_assert.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -21,10 +22,11 @@ unit_test_add_suite(
unit_test_add_suite(
NAME libsp_mock_ffa_internal_api
SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_internal_api.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/test_mock_ffa_internal_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_internal_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/test/test_mock_ffa_internal_api.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -35,12 +37,13 @@ unit_test_add_suite(
SOURCES
${CMAKE_CURRENT_LIST_DIR}/test/test_ffa_api.cpp
${CMAKE_CURRENT_LIST_DIR}/test/test_ffa_memory_descriptors.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_internal_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_internal_api.cpp
${CMAKE_CURRENT_LIST_DIR}/ffa.c
${CMAKE_CURRENT_LIST_DIR}/ffa_memory_descriptors.c
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_assert.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_assert.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -49,10 +52,11 @@ unit_test_add_suite(
unit_test_add_suite(
NAME libsp_mock_ffa_api
SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_mock_ffa_api.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/test/test_mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_api.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -62,10 +66,11 @@ unit_test_add_suite(
NAME libsp_sp_rxtx
SOURCES
${CMAKE_CURRENT_LIST_DIR}/test/test_sp_rxtx.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_api.cpp
${CMAKE_CURRENT_LIST_DIR}/sp_rxtx.c
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -74,10 +79,11 @@ unit_test_add_suite(
unit_test_add_suite(
NAME libsp_mock_sp_rxtx
SOURCES
- ${CMAKE_CURRENT_LIST_DIR}/test/test_mock_sp_rxtx.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_sp_rxtx.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/test/test_mock_sp_rxtx.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_sp_rxtx.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -88,10 +94,11 @@ unit_test_add_suite(
SOURCES
${CMAKE_CURRENT_LIST_DIR}/test/test_sp_discovery.cpp
${CMAKE_CURRENT_LIST_DIR}/sp_discovery.c
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_sp_rxtx.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_sp_rxtx.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -103,11 +110,12 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/test_sp_memory_management.cpp
${CMAKE_CURRENT_LIST_DIR}/sp_memory_management.c
${CMAKE_CURRENT_LIST_DIR}/ffa_memory_descriptors.c
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_assert.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_sp_rxtx.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_assert.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_sp_rxtx.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -119,9 +127,10 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/test_sp_memory_management_internals.cpp
${CMAKE_CURRENT_LIST_DIR}/test/sp_memory_management_internals.yml
${CMAKE_CURRENT_LIST_DIR}/ffa_memory_descriptors.c
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_assert.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_assert.cpp
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -131,10 +140,11 @@ unit_test_add_suite(
NAME libsp_sp_messaging
SOURCES
${CMAKE_CURRENT_LIST_DIR}/test/test_sp_messaging.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_api.cpp
${CMAKE_CURRENT_LIST_DIR}/sp_messaging.c
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
@@ -144,11 +154,12 @@ unit_test_add_suite(
NAME libsp_sp_messaging_with_routing_extension
SOURCES
${CMAKE_CURRENT_LIST_DIR}/test/test_sp_messaging.cpp
- ${CMAKE_CURRENT_LIST_DIR}/test/mock_ffa_api.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_ffa_api.cpp
${CMAKE_CURRENT_LIST_DIR}/sp_messaging.c
${CMAKE_CURRENT_LIST_DIR}/ffa_direct_msg_routing_extension.c
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
COMPILE_DEFINITIONS
-DARM64
diff --git a/components/rpc/mm_communicate/endpoint/sp/tests.cmake b/components/rpc/mm_communicate/endpoint/sp/tests.cmake
index 318f14d..c68a0c7 100644
--- a/components/rpc/mm_communicate/endpoint/sp/tests.cmake
+++ b/components/rpc/mm_communicate/endpoint/sp/tests.cmake
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2021, Arm Limited. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -13,12 +13,12 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/test/test_mm_communicate_call_ep.cpp
${CMAKE_CURRENT_LIST_DIR}/test/mock_mm_service.cpp
${CMAKE_CURRENT_LIST_DIR}/test/test_mock_mm_service.cpp
- ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/test/mock_assert.cpp
+ ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/mock/mock_assert.cpp
INCLUDE_DIRECTORIES
${UNIT_TEST_PROJECT_PATH}
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/include
- ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/test
+ ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/mock
${UNIT_TEST_PROJECT_PATH}/components/rpc/common/interface
COMPILE_DEFINITIONS
-DARM64
diff --git a/components/service/smm_variable/frontend/mm_communicate/tests.cmake b/components/service/smm_variable/frontend/mm_communicate/tests.cmake
index d1f930c..50b0b9a 100644
--- a/components/service/smm_variable/frontend/mm_communicate/tests.cmake
+++ b/components/service/smm_variable/frontend/mm_communicate/tests.cmake
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2021, Arm Limited. All rights reserved.
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -12,13 +12,13 @@ unit_test_add_suite(
${CMAKE_CURRENT_LIST_DIR}/smm_variable_mm_service.c
${CMAKE_CURRENT_LIST_DIR}/test/test_smm_variable_mm_service.cpp
${UNIT_TEST_PROJECT_PATH}/components/rpc/common/test/mock_rpc_interface.cpp
- ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/test/mock_assert.cpp
+ ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/mock/mock_assert.cpp
INCLUDE_DIRECTORIES
${UNIT_TEST_PROJECT_PATH}
${UNIT_TEST_PROJECT_PATH}/components/rpc/mm_communicate/endpoint/sp
${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/include
- ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/test
+ ${UNIT_TEST_PROJECT_PATH}/components/messaging/ffa/libsp/mock
${UNIT_TEST_PROJECT_PATH}/components/rpc/common/interface
COMPILE_DEFINITIONS
-DARM64
--
2.17.1
@@ -1,339 +0,0 @@
From e9ff55c03e06c044eb9c13f2a3315bf7e35f3659 Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Fri, 17 Jun 2022 13:51:21 +0200
Subject: [PATCH 18/24] Add mock for libsp/sp_discovery
Add mock_sp_discovery for mocking sp_discovery part of libsp.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I94460dc03dd6dcd27f6865f852cc9a0d85f4b583
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../messaging/ffa/libsp/mock/component.cmake | 1 +
.../ffa/libsp/mock/mock_sp_discovery.cpp | 109 +++++++++++++++++
.../ffa/libsp/mock/mock_sp_discovery.h | 37 ++++++
.../mock/test/test_mock_sp_discovery.cpp | 111 ++++++++++++++++++
components/messaging/ffa/libsp/tests.cmake | 13 ++
5 files changed, 271 insertions(+)
create mode 100644 components/messaging/ffa/libsp/mock/mock_sp_discovery.cpp
create mode 100644 components/messaging/ffa/libsp/mock/mock_sp_discovery.h
create mode 100644 components/messaging/ffa/libsp/mock/test/test_mock_sp_discovery.cpp
diff --git a/components/messaging/ffa/libsp/mock/component.cmake b/components/messaging/ffa/libsp/mock/component.cmake
index 03b8006..15db85a 100644
--- a/components/messaging/ffa/libsp/mock/component.cmake
+++ b/components/messaging/ffa/libsp/mock/component.cmake
@@ -12,6 +12,7 @@ target_sources(${TGT} PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/mock_assert.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_ffa_api.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_ffa_internal_api.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/mock_sp_discovery.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_sp_rxtx.cpp"
)
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_discovery.cpp b/components/messaging/ffa/libsp/mock/mock_sp_discovery.cpp
new file mode 100644
index 0000000..47f4ef7
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/mock_sp_discovery.cpp
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ */
+
+#include <CppUTestExt/MockSupport.h>
+#include "mock_sp_discovery.h"
+
+void expect_sp_discovery_ffa_version_get(const uint16_t *major,
+ const uint16_t *minor,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_discovery_ffa_version_get")
+ .withOutputParameterReturning("major", major, sizeof(*major))
+ .withOutputParameterReturning("minor", minor, sizeof(*minor))
+ .andReturnValue(result);
+}
+
+sp_result sp_discovery_ffa_version_get(uint16_t *major, uint16_t *minor)
+{
+ return mock()
+ .actualCall("sp_discovery_ffa_version_get")
+ .withOutputParameter("major", major)
+ .withOutputParameter("minor", minor)
+ .returnIntValue();
+}
+
+void expect_sp_discovery_own_id_get(const uint16_t *id, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_discovery_own_id_get")
+ .withOutputParameterReturning("id", id, sizeof(*id))
+ .andReturnValue(result);
+}
+
+sp_result sp_discovery_own_id_get(uint16_t *id)
+{
+ return mock()
+ .actualCall("sp_discovery_own_id_get")
+ .withOutputParameter("id", id)
+ .returnIntValue();
+}
+
+void expect_sp_discovery_partition_id_get(const struct sp_uuid *uuid,
+ const uint16_t *id, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_discovery_partition_id_get")
+ .withMemoryBufferParameter("uuid", (const unsigned char *)uuid,
+ sizeof(*uuid))
+ .withOutputParameterReturning("id", id, sizeof(*id))
+ .andReturnValue(result);
+}
+
+sp_result sp_discovery_partition_id_get(const struct sp_uuid *uuid,
+ uint16_t *id)
+{
+ return mock()
+ .actualCall("sp_discovery_partition_id_get")
+ .withMemoryBufferParameter("uuid", (const unsigned char *)uuid,
+ sizeof(*uuid))
+ .withOutputParameter("id", id)
+ .returnIntValue();
+}
+
+void expect_sp_discovery_partition_info_get(const struct sp_uuid *uuid,
+ const struct sp_partition_info *info,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_discovery_partition_info_get")
+ .withMemoryBufferParameter("uuid", (const unsigned char *)uuid,
+ sizeof(*uuid))
+ .withOutputParameterReturning("info", info, sizeof(*info))
+ .andReturnValue(result);
+}
+
+sp_result sp_discovery_partition_info_get(const struct sp_uuid *uuid,
+ struct sp_partition_info *info)
+{
+ return mock()
+ .actualCall("sp_discovery_partition_info_get")
+ .withMemoryBufferParameter("uuid", (const unsigned char *)uuid,
+ sizeof(*uuid))
+ .withOutputParameter("info", info)
+ .returnIntValue();
+}
+
+void expect_sp_discovery_partition_info_get_all(const struct sp_partition_info info[],
+ const uint32_t *count,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_discovery_partition_info_get_all")
+ .withOutputParameterReturning("info", info, sizeof(*info) * *count)
+ .withOutputParameterReturning("count", count, sizeof(*count))
+ .andReturnValue(result);
+}
+
+sp_result sp_discovery_partition_info_get_all(struct sp_partition_info info[],
+ uint32_t *count)
+{
+ return mock()
+ .actualCall("sp_discovery_partition_info_get_all")
+ .withOutputParameter("info", info)
+ .withOutputParameter("count", count)
+ .returnIntValue();
+}
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_discovery.h b/components/messaging/ffa/libsp/mock/mock_sp_discovery.h
new file mode 100644
index 0000000..a71ce18
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/mock_sp_discovery.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ */
+
+#ifndef LIBSP_MOCK_MOCK_SP_DISCOVERY_H_
+#define LIBSP_MOCK_MOCK_SP_DISCOVERY_H_
+
+#include "../include/sp_discovery.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void expect_sp_discovery_ffa_version_get(const uint16_t *major,
+ const uint16_t *minor,
+ sp_result result);
+
+void expect_sp_discovery_own_id_get(const uint16_t *id, sp_result result);
+
+void expect_sp_discovery_partition_id_get(const struct sp_uuid *uuid,
+ const uint16_t *id, sp_result result);
+
+
+void expect_sp_discovery_partition_info_get(const struct sp_uuid *uuid,
+ const struct sp_partition_info *info,
+ sp_result result);
+
+void expect_sp_discovery_partition_info_get_all(const struct sp_partition_info info[],
+ const uint32_t *count,
+ sp_result result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBSP_MOCK_MOCK_SP_DISCOVERY_H_ */
diff --git a/components/messaging/ffa/libsp/mock/test/test_mock_sp_discovery.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_sp_discovery.cpp
new file mode 100644
index 0000000..bb4bf07
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/test/test_mock_sp_discovery.cpp
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ */
+
+#include <CppUTestExt/MockSupport.h>
+#include <CppUTest/TestHarness.h>
+#include "mock_sp_discovery.h"
+#include <stdint.h>
+#include <stdlib.h>
+
+
+
+
+TEST_GROUP(mock_sp_discovery) {
+ TEST_TEARDOWN()
+ {
+ mock().checkExpectations();
+ mock().clear();
+ }
+
+ static const sp_result result = -1;
+};
+
+TEST(mock_sp_discovery, sp_discovery_ffa_version_get)
+{
+ const uint16_t expected_major = 0xabcd;
+ const uint16_t expected_minor = 0xef01;
+ uint16_t major = 0, minor = 0;
+
+ expect_sp_discovery_ffa_version_get(&expected_major, &expected_minor,
+ result);
+ LONGS_EQUAL(result, sp_discovery_ffa_version_get(&major, &minor));
+ UNSIGNED_LONGS_EQUAL(expected_major, major);
+ UNSIGNED_LONGS_EQUAL(expected_minor, minor);
+}
+
+TEST(mock_sp_discovery, sp_discovery_own_id_get)
+{
+ const uint16_t expected_id = 0x8765;
+ uint16_t id = 0;
+
+ expect_sp_discovery_own_id_get(&expected_id, result);
+ LONGS_EQUAL(result, sp_discovery_own_id_get(&id));
+ UNSIGNED_LONGS_EQUAL(expected_id, id);
+}
+
+TEST(mock_sp_discovery, sp_discovery_partition_id_get)
+{
+ const struct sp_uuid expected_uuid = {
+ .uuid = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}};
+ const uint16_t expected_id = 0xc1ca;
+
+ struct sp_uuid uuid = expected_uuid;
+ uint16_t id = 0;
+
+ expect_sp_discovery_partition_id_get(&expected_uuid, &expected_id,
+ result);
+ LONGS_EQUAL(result, sp_discovery_partition_id_get(&uuid, &id));
+ UNSIGNED_LONGS_EQUAL(expected_id, id);
+}
+
+TEST(mock_sp_discovery, sp_discovery_partition_info_get)
+{
+ const struct sp_uuid expected_uuid = {
+ .uuid = {0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}};
+ const struct sp_partition_info expected_info = {
+ .partition_id = 0x1234,
+ .execution_context_count = 0xffff,
+ .supports_direct_requests = true,
+ .can_send_direct_requests = true,
+ .supports_indirect_requests = false
+ };
+
+ struct sp_uuid uuid = expected_uuid;
+ struct sp_partition_info info = {0};
+
+ expect_sp_discovery_partition_info_get(&expected_uuid, &expected_info,
+ result);
+ LONGS_EQUAL(result, sp_discovery_partition_info_get(&uuid, &info));
+ MEMCMP_EQUAL(&expected_info, &info, sizeof(&expected_info));
+}
+
+TEST(mock_sp_discovery, sp_discovery_partition_info_get_all)
+{
+ const uint32_t expected_count = 2;
+ const struct sp_partition_info expected_info[expected_count] = {{
+ .partition_id = 0x5678,
+ .execution_context_count = 0x1111,
+ .supports_direct_requests = false,
+ .can_send_direct_requests = false,
+ .supports_indirect_requests = true
+ }, {
+ .partition_id = 0x1234,
+ .execution_context_count = 0xffff,
+ .supports_direct_requests = true,
+ .can_send_direct_requests = true,
+ .supports_indirect_requests = false
+ }};
+
+ struct sp_partition_info info[expected_count] = {0};
+ uint32_t count = 0;
+
+ expect_sp_discovery_partition_info_get_all(expected_info,
+ &expected_count, result);
+ LONGS_EQUAL(result, sp_discovery_partition_info_get_all(info, &count));
+ MEMCMP_EQUAL(&expected_info, &info, sizeof(&expected_info));
+ UNSIGNED_LONGS_EQUAL(expected_count, count);
+}
\ No newline at end of file
diff --git a/components/messaging/ffa/libsp/tests.cmake b/components/messaging/ffa/libsp/tests.cmake
index 296ae46..7b52248 100644
--- a/components/messaging/ffa/libsp/tests.cmake
+++ b/components/messaging/ffa/libsp/tests.cmake
@@ -104,6 +104,19 @@ unit_test_add_suite(
-DARM64
)
+unit_test_add_suite(
+ NAME libsp_mock_sp_discovery
+ SOURCES
+ ${CMAKE_CURRENT_LIST_DIR}/mock/test/test_mock_sp_discovery.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_sp_discovery.cpp
+ INCLUDE_DIRECTORIES
+ ${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
+ COMPILE_DEFINITIONS
+ -DARM64
+)
+
unit_test_add_suite(
NAME libsp_sp_memory_management
SOURCES
--
2.17.1
@@ -1,977 +0,0 @@
From b592a22dbce521522931f8e3d79d6e16f2d334fa Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Fri, 17 Jun 2022 14:42:04 +0200
Subject: [PATCH 19/24] Add mock for libsp/sp_memory_management
Add mock_sp_memory_management for mocking sp_memory_management part of
libsp.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I9f74142bc3568dfc59f820ec2c2af81deba0d0da
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../ffa/libsp/include/sp_memory_management.h | 2 +-
.../messaging/ffa/libsp/mock/component.cmake | 1 +
.../libsp/mock/mock_sp_memory_management.cpp | 523 ++++++++++++++++++
.../libsp/mock/mock_sp_memory_management.h | 98 ++++
.../test/test_mock_sp_memory_management.cpp | 260 +++++++++
components/messaging/ffa/libsp/tests.cmake | 13 +
6 files changed, 896 insertions(+), 1 deletion(-)
create mode 100644 components/messaging/ffa/libsp/mock/mock_sp_memory_management.cpp
create mode 100644 components/messaging/ffa/libsp/mock/mock_sp_memory_management.h
create mode 100644 components/messaging/ffa/libsp/test/test_mock_sp_memory_management.cpp
diff --git a/components/messaging/ffa/libsp/include/sp_memory_management.h b/components/messaging/ffa/libsp/include/sp_memory_management.h
index 58a6cc1..ec76a3d 100644
--- a/components/messaging/ffa/libsp/include/sp_memory_management.h
+++ b/components/messaging/ffa/libsp/include/sp_memory_management.h
@@ -381,7 +381,7 @@ sp_result sp_memory_share_dynamic_is_supported(bool *supported);
*
* @param[in] descriptor The memory descriptor
* @param[in,out] acc_desc Access descriptor
- * @param[in,out regions Memory region array
+ * @param[in,out] regions Memory region array
* @param[in] in_region_count Count of the specified regions, can be 0
* @param[in,out] out_region_count Count of the reserved space of in the
* regions buffer for retrieved regions. After
diff --git a/components/messaging/ffa/libsp/mock/component.cmake b/components/messaging/ffa/libsp/mock/component.cmake
index 15db85a..eb0d28c 100644
--- a/components/messaging/ffa/libsp/mock/component.cmake
+++ b/components/messaging/ffa/libsp/mock/component.cmake
@@ -13,6 +13,7 @@ target_sources(${TGT} PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/mock_ffa_api.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_ffa_internal_api.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_sp_discovery.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/mock_sp_memory_management.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_sp_rxtx.cpp"
)
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_memory_management.cpp b/components/messaging/ffa/libsp/mock/mock_sp_memory_management.cpp
new file mode 100644
index 0000000..9eb0aaa
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/mock_sp_memory_management.cpp
@@ -0,0 +1,523 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ */
+
+#include <CppUTestExt/MockSupport.h>
+#include "mock_sp_memory_management.h"
+
+void expect_sp_memory_donate(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *acc_desc,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_donate")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc))
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameterReturning("handle", handle, sizeof(*handle))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_donate(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor *acc_desc,
+ struct sp_memory_region regions[],
+ uint32_t region_count, uint64_t *handle)
+{
+ return mock()
+ .actualCall("sp_memory_donate")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc))
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_donate_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *acc_desc,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_donate_dynamic")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc))
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameterReturning("handle", handle, sizeof(*handle))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_donate_dynamic(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor *acc_desc,
+ struct sp_memory_region regions[],
+ uint32_t region_count, uint64_t *handle,
+ struct ffa_mem_transaction_buffer *buffer)
+{
+ if (buffer == NULL) { // LCOV_EXCL_BR_LINE
+ FAIL("ffa_mem_transaction_buffer is NULL"); // LCOV_EXCL_LINE
+ }
+
+ return mock()
+ .actualCall("sp_memory_donate_dynamic")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc))
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_donate_dynamic_is_supported(const bool *supported, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_lend_dynamic_is_supported")
+ .withOutputParameterReturning("supported", supported, sizeof(*supported))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_donate_dynamic_is_supported(bool *supported)
+{
+ return mock()
+ .actualCall("sp_memory_lend_dynamic_is_supported")
+ .withOutputParameter("supported", supported)
+ .returnIntValue();
+}
+
+void expect_sp_memory_lend(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_lend")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameterReturning("handle", handle, sizeof(*handle))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_lend(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ struct sp_memory_region regions[],
+ uint32_t region_count, uint64_t *handle)
+{
+ return mock()
+ .actualCall("sp_memory_lend")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_lend_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ const uint32_t region_count, const uint64_t *handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_lend")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameterReturning("handle", handle, sizeof(*handle))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_lend_dynamic(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ struct sp_memory_region regions[],
+ uint32_t region_count, uint64_t *handle,
+ struct ffa_mem_transaction_buffer *buffer)
+{
+ if (buffer == NULL) { // LCOV_EXCL_BR_LINE
+ FAIL("ffa_mem_transaction_buffer is NULL"); // LCOV_EXCL_LINE
+ }
+
+ return mock()
+ .actualCall("sp_memory_lend")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_lend_dynamic_is_supported(const bool *supported, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_lend_dynamic_is_supported")
+ .withOutputParameterReturning("supported", supported, sizeof(*supported))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_lend_dynamic_is_supported(bool *supported)
+{
+ return mock()
+ .actualCall("sp_memory_lend_dynamic_is_supported")
+ .withOutputParameter("supported", supported)
+ .returnIntValue();
+}
+
+void expect_sp_memory_share(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_share")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameterReturning("handle", handle, sizeof(*handle))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_share(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ struct sp_memory_region regions[],
+ uint32_t region_count, uint64_t *handle)
+{
+ return mock()
+ .actualCall("sp_memory_share")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_share_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_share_dynamic")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameterReturning("handle", handle, sizeof(*handle))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_share_dynamic(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ struct sp_memory_region regions[],
+ uint32_t region_count, uint64_t *handle,
+ struct ffa_mem_transaction_buffer *buffer)
+{
+ if (buffer == NULL) { // LCOV_EXCL_BR_LINE
+ FAIL("ffa_mem_transaction_buffer is NULL"); // LCOV_EXCL_LINE
+ }
+
+ return mock()
+ .actualCall("sp_memory_share_dynamic")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(*descriptor))
+ .withMemoryBufferParameter("acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc) * acc_desc_count)
+ .withUnsignedIntParameter("acc_desc_count", acc_desc_count)
+ .withMemoryBufferParameter("regions", (const unsigned char *)regions,
+ sizeof(*regions) * region_count)
+ .withUnsignedIntParameter("region_count", region_count)
+ .withOutputParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_share_dynamic_is_supported(const bool *supported, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_share_dynamic_is_supported")
+ .withOutputParameterReturning("supported", supported, sizeof(*supported))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_share_dynamic_is_supported(bool *supported)
+{
+ return mock()
+ .actualCall("sp_memory_share_dynamic_is_supported")
+ .withOutputParameter("supported", supported)
+ .returnIntValue();
+}
+
+void expect_sp_memory_retrieve(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *req_acc_desc,
+ const struct sp_memory_access_descriptor *resp_acc_desc,
+ const struct sp_memory_region in_regions[],
+ const struct sp_memory_region out_regions[],
+ uint32_t in_region_count,
+ const uint32_t *out_region_count, uint64_t handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_retrieve")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(descriptor))
+ .withMemoryBufferParameter("req_acc_desc", (const unsigned char *)req_acc_desc,
+ sizeof(*req_acc_desc))
+ .withOutputParameterReturning("resp_acc_desc",
+ (const unsigned char *)resp_acc_desc,
+ sizeof(*resp_acc_desc))
+ .withMemoryBufferParameter("in_regions", (const unsigned char *)in_regions,
+ sizeof(*in_regions) * in_region_count)
+ .withOutputParameterReturning("out_regions", out_regions,
+ sizeof(*out_regions) * *out_region_count)
+ .withUnsignedIntParameter("in_region_count", in_region_count)
+ .withOutputParameterReturning("out_region_count", out_region_count,
+ sizeof(*out_region_count))
+ .withUnsignedLongIntParameter("handle", handle)
+ .andReturnValue(result);
+
+}
+
+sp_result sp_memory_retrieve(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor *acc_desc,
+ struct sp_memory_region regions[],
+ uint32_t in_region_count,
+ uint32_t *out_region_count, uint64_t handle)
+{
+ return mock()
+ .actualCall("sp_memory_retrieve")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(descriptor))
+ .withMemoryBufferParameter("req_acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc))
+ .withOutputParameter("resp_acc_desc", acc_desc)
+ .withMemoryBufferParameter("in_regions", (const unsigned char *)regions,
+ sizeof(*regions) * in_region_count)
+ .withOutputParameter("out_regions", regions)
+ .withUnsignedIntParameter("in_region_count", in_region_count)
+ .withOutputParameter("out_region_count", out_region_count)
+ .withUnsignedLongIntParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_retrieve_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *req_acc_desc,
+ const struct sp_memory_access_descriptor *resp_acc_desc,
+ const struct sp_memory_region in_regions[],
+ const struct sp_memory_region out_regions[],
+ uint32_t in_region_count,
+ const uint32_t *out_region_count, uint64_t handle,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_retrieve")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(descriptor))
+ .withMemoryBufferParameter("req_acc_desc", (const unsigned char *)req_acc_desc,
+ sizeof(*req_acc_desc))
+ .withOutputParameterReturning("resp_acc_desc",
+ (const unsigned char *)resp_acc_desc,
+ sizeof(*resp_acc_desc))
+ .withMemoryBufferParameter("in_regions", (const unsigned char *)in_regions,
+ sizeof(*in_regions) * in_region_count)
+ .withOutputParameterReturning("out_regions", out_regions,
+ sizeof(*out_regions) * *out_region_count)
+ .withUnsignedIntParameter("in_region_count", in_region_count)
+ .withOutputParameterReturning("out_region_count", out_region_count,
+ sizeof(*out_region_count))
+ .withUnsignedLongIntParameter("handle", handle)
+ .andReturnValue(result);
+}
+
+sp_result
+sp_memory_retrieve_dynamic(struct sp_memory_descriptor *descriptor,
+ struct sp_memory_access_descriptor *acc_desc,
+ struct sp_memory_region regions[],
+ uint32_t in_region_count, uint32_t *out_region_count,
+ uint64_t handle,
+ struct ffa_mem_transaction_buffer *buffer)
+{
+ if (buffer == NULL) { // LCOV_EXCL_BR_LINE
+ FAIL("ffa_mem_transaction_buffer is NULL"); // LCOV_EXCL_LINE
+ }
+
+ return mock()
+ .actualCall("sp_memory_retrieve")
+ .withMemoryBufferParameter("descriptor", (const unsigned char *)descriptor,
+ sizeof(descriptor))
+ .withMemoryBufferParameter("req_acc_desc", (const unsigned char *)acc_desc,
+ sizeof(*acc_desc))
+ .withOutputParameter("resp_acc_desc", acc_desc)
+ .withMemoryBufferParameter("in_regions", (const unsigned char *)regions,
+ sizeof(*regions) * in_region_count)
+ .withOutputParameter("out_regions", regions)
+ .withUnsignedIntParameter("in_region_count", in_region_count)
+ .withOutputParameter("out_region_count", out_region_count)
+ .withUnsignedLongIntParameter("handle", handle)
+ .returnIntValue();
+}
+
+void expect_sp_memory_retrieve_dynamic_is_supported(const bool *supported, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_retrieve_dynamic_is_supported")
+ .withOutputParameterReturning("supported", supported, sizeof(*supported))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_retrieve_dynamic_is_supported(bool *supported)
+{
+ return mock()
+ .actualCall("sp_memory_retrieve_dynamic_is_supported")
+ .withOutputParameter("supported", supported)
+ .returnIntValue();
+}
+
+void expect_sp_memory_relinquish(uint64_t handle, const uint16_t endpoints[],
+ uint32_t endpoint_count,
+ const struct sp_memory_transaction_flags *flags,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_relinquish")
+ .withUnsignedLongIntParameter("handle", handle)
+ .withMemoryBufferParameter("endpoints", (const unsigned char *)endpoints,
+ sizeof(*endpoints) * endpoint_count)
+ .withMemoryBufferParameter("flags", (const unsigned char *)flags, sizeof(*flags))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_relinquish(uint64_t handle, const uint16_t endpoints[],
+ uint32_t endpoint_count,
+ struct sp_memory_transaction_flags *flags)
+{
+ return mock()
+ .actualCall("sp_memory_relinquish")
+ .withUnsignedLongIntParameter("handle", handle)
+ .withMemoryBufferParameter("endpoints", (const unsigned char *)endpoints,
+ sizeof(*endpoints) * endpoint_count)
+ .withMemoryBufferParameter("flags", (const unsigned char *)flags, sizeof(*flags))
+ .returnIntValue();
+}
+
+void expect_sp_memory_reclaim(uint64_t handle, uint32_t flags, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_reclaim")
+ .withUnsignedLongIntParameter("handle", handle)
+ .withUnsignedIntParameter("flags", flags)
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_reclaim(uint64_t handle, uint32_t flags)
+{
+ return mock()
+ .actualCall("sp_memory_reclaim")
+ .withUnsignedLongIntParameter("handle", handle)
+ .withUnsignedIntParameter("flags", flags)
+ .returnIntValue();
+}
+
+void expect_sp_memory_permission_get(const void *base_address, const struct sp_mem_perm *mem_perm,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_permission_set")
+ .withConstPointerParameter("base_address", base_address)
+ .withOutputParameterReturning("mem_perm", mem_perm,
+ sizeof(*mem_perm))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_permission_get(const void *base_address,
+ struct sp_mem_perm *mem_perm)
+{
+ return mock()
+ .actualCall("sp_memory_permission_set")
+ .withConstPointerParameter("base_address", base_address)
+ .withOutputParameter("mem_perm", mem_perm)
+ .returnIntValue();
+}
+
+void expect_sp_memory_permission_set(const void *base_address, size_t region_size,
+ const struct sp_mem_perm *mem_perm, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_memory_permission_set")
+ .withConstPointerParameter("base_address", base_address)
+ .withUnsignedLongIntParameter("region_size", region_size)
+ .withMemoryBufferParameter("mem_perm", (const unsigned char *)mem_perm,
+ sizeof(*mem_perm))
+ .andReturnValue(result);
+}
+
+sp_result sp_memory_permission_set(const void *base_address, size_t region_size,
+ const struct sp_mem_perm *mem_perm)
+{
+ return mock()
+ .actualCall("sp_memory_permission_set")
+ .withConstPointerParameter("base_address", base_address)
+ .withUnsignedLongIntParameter("region_size", region_size)
+ .withMemoryBufferParameter("mem_perm", (const unsigned char *)mem_perm,
+ sizeof(*mem_perm))
+ .returnIntValue();
+}
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_memory_management.h b/components/messaging/ffa/libsp/mock/mock_sp_memory_management.h
new file mode 100644
index 0000000..458d2af
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/mock_sp_memory_management.h
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ */
+
+#ifndef LIBSP_MOCK_MOCK_SP_MEMORY_MANAGEMENT_H_
+#define LIBSP_MOCK_MOCK_SP_MEMORY_MANAGEMENT_H_
+
+#include "../include/sp_memory_management.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void expect_sp_memory_donate(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *acc_desc,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result);
+
+void expect_sp_memory_donate_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *acc_desc,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result);
+
+void expect_sp_memory_donate_dynamic_is_supported(const bool *supported, sp_result result);
+
+void expect_sp_memory_lend(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result);
+
+void expect_sp_memory_lend_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ const uint32_t region_count, const uint64_t *handle,
+ sp_result result);
+
+void expect_sp_memory_lend_dynamic_is_supported(const bool *supported, sp_result result);
+
+void expect_sp_memory_share(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result);
+
+void expect_sp_memory_share_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor acc_desc[],
+ uint32_t acc_desc_count,
+ const struct sp_memory_region regions[],
+ uint32_t region_count, const uint64_t *handle,
+ sp_result result);
+
+void expect_sp_memory_share_dynamic_is_supported(const bool *supported, sp_result result);
+
+void expect_sp_memory_retrieve(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *req_acc_desc,
+ const struct sp_memory_access_descriptor *resp_acc_desc,
+ const struct sp_memory_region in_regions[],
+ const struct sp_memory_region out_regions[],
+ uint32_t in_region_count,
+ const uint32_t *out_region_count, uint64_t handle,
+ sp_result result);
+
+void expect_sp_memory_retrieve_dynamic(const struct sp_memory_descriptor *descriptor,
+ const struct sp_memory_access_descriptor *req_acc_desc,
+ const struct sp_memory_access_descriptor *resp_acc_desc,
+ const struct sp_memory_region in_regions[],
+ const struct sp_memory_region out_regions[],
+ uint32_t in_region_count,
+ const uint32_t *out_region_count, uint64_t handle,
+ sp_result result);
+
+void expect_sp_memory_retrieve_dynamic_is_supported(const bool *supported, sp_result result);
+
+void expect_sp_memory_relinquish(uint64_t handle, const uint16_t endpoints[],
+ uint32_t endpoint_count,
+ const struct sp_memory_transaction_flags *flags,
+ sp_result result);
+
+void expect_sp_memory_reclaim(uint64_t handle, uint32_t flags, sp_result result);
+
+void expect_sp_memory_permission_get(const void *base_address, const struct sp_mem_perm *mem_perm,
+ sp_result result);
+
+void expect_sp_memory_permission_set(const void *base_address, size_t region_size,
+ const struct sp_mem_perm *mem_perm, sp_result result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBSP_MOCK_MOCK_SP_MEMORY_MANAGEMENT_H_ */
diff --git a/components/messaging/ffa/libsp/test/test_mock_sp_memory_management.cpp b/components/messaging/ffa/libsp/test/test_mock_sp_memory_management.cpp
new file mode 100644
index 0000000..387b50f
--- /dev/null
+++ b/components/messaging/ffa/libsp/test/test_mock_sp_memory_management.cpp
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ */
+
+#include <CppUTestExt/MockSupport.h>
+#include <CppUTest/TestHarness.h>
+#include "mock_sp_memory_management.h"
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const struct sp_memory_descriptor expected_descriptor = {
+ .sender_id = 0xfedc,
+ .memory_type = sp_memory_type_normal_memory,
+ .mem_region_attr = {.normal_memory = {
+ .cacheability = sp_cacheability_write_back,
+ .shareability = sp_shareability_inner_shareable
+ }},
+ .flags = {
+ .zero_memory = true,
+ .operation_time_slicing = true,
+ .zero_memory_after_relinquish = true,
+ .transaction_type = sp_memory_transaction_type_relayer_specified,
+ .alignment_hint = 0x2000
+ },
+ .tag = 0x0123456789abcdefULL
+};
+static const struct sp_memory_access_descriptor expected_acc_desc[] = {
+ {
+ .receiver_id = 0xfafa,
+ .instruction_access = sp_instruction_access_executable,
+ .data_access = sp_data_access_read_only
+ }, {
+ .receiver_id = 0xc1ca,
+ .instruction_access = sp_instruction_access_not_executable,
+ .data_access = sp_data_access_read_write
+ }
+};
+static const struct sp_memory_region expected_regions[2] = {
+ {.address = (void *)0x01234567, .page_count = 0x89abcdef},
+ {.address = (void *)0x12345670, .page_count = 0x9abcdef8},
+};
+static const uint64_t expected_handle = 0xabcdef0123456789ULL;
+static const void *expected_address = (const void *)0x234567879;
+static const struct sp_mem_perm expected_mem_perm = {
+ .data_access = sp_mem_perm_data_perm_read_write,
+ .instruction_access = sp_mem_perm_instruction_perm_non_executable,
+};
+
+TEST_GROUP(mock_sp_memory_management)
+{
+ TEST_SETUP()
+ {
+ memset(&descriptor, 0x00, sizeof(descriptor));
+ memset(&acc_desc, 0x00, sizeof(acc_desc));
+ memset(&regions, 0x00, sizeof(regions));
+ handle = 0;
+ supported = false;
+ }
+
+ TEST_TEARDOWN()
+ {
+ mock().checkExpectations();
+ mock().clear();
+ }
+
+ struct sp_memory_descriptor descriptor;
+ struct sp_memory_access_descriptor acc_desc[2];
+ struct sp_memory_region regions[2];
+ uint64_t handle;
+ bool supported;
+ struct ffa_mem_transaction_buffer tr_buffer;
+
+ static const sp_result result = -1;
+};
+
+TEST(mock_sp_memory_management, sp_memory_donate)
+{
+ descriptor = expected_descriptor;
+ acc_desc[0] = expected_acc_desc[0];
+ memcpy(regions, expected_regions, sizeof(regions));
+
+ expect_sp_memory_donate(&expected_descriptor, expected_acc_desc, expected_regions, 2,
+ &expected_handle, result);
+ LONGS_EQUAL(result, sp_memory_donate(&descriptor, acc_desc, regions, 2, &handle));
+
+ UNSIGNED_LONGLONGS_EQUAL(expected_handle, handle);
+}
+
+TEST(mock_sp_memory_management, sp_memory_donate_dynamic)
+{
+ descriptor = expected_descriptor;
+ acc_desc[0] = expected_acc_desc[0];
+ memcpy(regions, expected_regions, sizeof(regions));
+
+ expect_sp_memory_donate_dynamic(&expected_descriptor, expected_acc_desc, expected_regions,
+ 2, &expected_handle, result);
+ LONGS_EQUAL(result, sp_memory_donate_dynamic(&descriptor, acc_desc, regions, 2, &handle,
+ &tr_buffer));
+
+ UNSIGNED_LONGLONGS_EQUAL(expected_handle, handle);
+}
+
+TEST(mock_sp_memory_management, sp_memory_donate_dynamic_is_supported)
+{
+ const bool expected_supported = true;
+ expect_sp_memory_donate_dynamic_is_supported(&expected_supported, result);
+ LONGS_EQUAL(result, sp_memory_donate_dynamic_is_supported(&supported));
+ CHECK_TRUE(supported);
+}
+
+TEST(mock_sp_memory_management, sp_memory_lend)
+{
+ descriptor = expected_descriptor;
+ memcpy(acc_desc, expected_acc_desc, sizeof(acc_desc));
+ memcpy(regions, expected_regions, sizeof(regions));
+
+ expect_sp_memory_lend(&descriptor, acc_desc, 2, regions, 2, &expected_handle, result);
+ LONGS_EQUAL(result, sp_memory_lend(&descriptor, acc_desc, 2, regions, 2, &handle));
+ UNSIGNED_LONGLONGS_EQUAL(expected_handle, handle);
+}
+
+TEST(mock_sp_memory_management, sp_memory_lend_dynamic)
+{
+ descriptor = expected_descriptor;
+ memcpy(acc_desc, expected_acc_desc, sizeof(acc_desc));
+ memcpy(regions, expected_regions, sizeof(regions));
+
+ expect_sp_memory_lend_dynamic(&descriptor, acc_desc, 2, regions, 2, &expected_handle,
+ result);
+ LONGS_EQUAL(result, sp_memory_lend_dynamic(&descriptor, acc_desc, 2, regions, 2, &handle,
+ &tr_buffer));
+ UNSIGNED_LONGLONGS_EQUAL(expected_handle, handle);
+}
+
+TEST(mock_sp_memory_management, sp_memory_lend_dynamic_is_supported)
+{
+ const bool expected_supported = true;
+ expect_sp_memory_lend_dynamic_is_supported(&expected_supported, result);
+ LONGS_EQUAL(result, sp_memory_lend_dynamic_is_supported(&supported));
+ CHECK_TRUE(supported);
+}
+
+TEST(mock_sp_memory_management, sp_memory_share)
+{
+ descriptor = expected_descriptor;
+ memcpy(acc_desc, expected_acc_desc, sizeof(acc_desc));
+ memcpy(regions, expected_regions, sizeof(regions));
+
+ expect_sp_memory_share(&descriptor, acc_desc, 2, regions, 2, &expected_handle, result);
+ LONGS_EQUAL(result, sp_memory_share(&descriptor, acc_desc, 2, regions, 2, &handle));
+ UNSIGNED_LONGLONGS_EQUAL(expected_handle, handle);
+}
+
+TEST(mock_sp_memory_management, sp_memory_share_dynamic)
+{
+ descriptor = expected_descriptor;
+ memcpy(acc_desc, expected_acc_desc, sizeof(acc_desc));
+ memcpy(regions, expected_regions, sizeof(regions));
+
+ expect_sp_memory_share_dynamic(&descriptor, acc_desc, 2, regions, 2, &expected_handle,
+ result);
+ LONGS_EQUAL(result, sp_memory_share_dynamic(&descriptor, acc_desc, 2, regions, 2, &handle,
+ &tr_buffer));
+ UNSIGNED_LONGLONGS_EQUAL(expected_handle, handle);
+}
+
+TEST(mock_sp_memory_management, sp_memory_share_dynamic_is_supported)
+{
+ const bool expected_supported = true;
+ expect_sp_memory_share_dynamic_is_supported(&expected_supported, result);
+ LONGS_EQUAL(result, sp_memory_share_dynamic_is_supported(&supported));
+ CHECK_TRUE(supported);
+}
+
+TEST(mock_sp_memory_management, sp_memory_retrieve)
+{
+ const uint32_t expected_region_count = 1;
+ struct sp_memory_access_descriptor acc_desc = expected_acc_desc[0];
+ struct sp_memory_region region = expected_regions[0];
+ uint32_t out_region_count = 0;
+
+ descriptor = expected_descriptor;
+
+ expect_sp_memory_retrieve(&expected_descriptor, &expected_acc_desc[0],
+ &expected_acc_desc[1], &expected_regions[0],
+ &expected_regions[1], 1, &expected_region_count, expected_handle,
+ result);
+ LONGS_EQUAL(result, sp_memory_retrieve(&descriptor, &acc_desc, &region, 1,
+ &out_region_count, expected_handle));
+ MEMCMP_EQUAL(&acc_desc, &expected_acc_desc[1], sizeof(acc_desc));
+ MEMCMP_EQUAL(&region, &expected_regions[1], sizeof(region));
+ UNSIGNED_LONGS_EQUAL(expected_region_count, out_region_count);
+}
+
+TEST(mock_sp_memory_management, sp_memory_retrieve_dynamic)
+{
+ const uint32_t expected_region_count = 1;
+ struct sp_memory_access_descriptor acc_desc = expected_acc_desc[0];
+ struct sp_memory_region region = expected_regions[0];
+ uint32_t out_region_count = 0;
+
+ descriptor = expected_descriptor;
+
+ expect_sp_memory_retrieve_dynamic(&expected_descriptor, &expected_acc_desc[0],
+ &expected_acc_desc[1], &expected_regions[0],
+ &expected_regions[1], 1, &expected_region_count,
+ expected_handle, result);
+ LONGS_EQUAL(result, sp_memory_retrieve_dynamic(&descriptor, &acc_desc, &region, 1,
+ &out_region_count, expected_handle,
+ &tr_buffer));
+ MEMCMP_EQUAL(&acc_desc, &expected_acc_desc[1], sizeof(acc_desc));
+ MEMCMP_EQUAL(&region, &expected_regions[1], sizeof(region));
+ UNSIGNED_LONGS_EQUAL(expected_region_count, out_region_count);
+}
+
+TEST(mock_sp_memory_management, sp_memory_retrieve_dynamic_is_supported)
+{
+ const bool expected_supported = true;
+ expect_sp_memory_retrieve_dynamic_is_supported(&expected_supported, result);
+ LONGS_EQUAL(result, sp_memory_retrieve_dynamic_is_supported(&supported));
+ CHECK_TRUE(supported);
+}
+
+TEST(mock_sp_memory_management, sp_memory_relinquish)
+{
+ uint16_t endpoints[3] = {1, 2, 3};
+ struct sp_memory_transaction_flags flags = {0}; // TODO: flags
+
+ expect_sp_memory_relinquish(expected_handle, endpoints, 3, &flags, result);
+ LONGS_EQUAL(result, sp_memory_relinquish(expected_handle, endpoints, 3, &flags));
+}
+
+TEST(mock_sp_memory_management, sp_memory_reclaim)
+{
+ uint32_t flags = 0xffffffff;
+
+ expect_sp_memory_reclaim(expected_handle, flags, result);
+ LONGS_EQUAL(result, sp_memory_reclaim(expected_handle, flags));
+}
+
+TEST(mock_sp_memory_management, sp_memory_permission_get)
+{
+ struct sp_mem_perm mem_perm;
+
+ memset(&mem_perm, 0x00, sizeof(mem_perm));
+
+ expect_sp_memory_permission_get(expected_address, &expected_mem_perm, result);
+ LONGS_EQUAL(result, sp_memory_permission_get(expected_address, &mem_perm));
+ MEMCMP_EQUAL(&expected_mem_perm, &mem_perm, sizeof(expected_mem_perm));
+}
+
+TEST(mock_sp_memory_management, sp_memory_permission_set)
+{
+ size_t size = 0x7654;
+
+ expect_sp_memory_permission_set(expected_address, size, &expected_mem_perm, result);
+ LONGS_EQUAL(result, sp_memory_permission_set(expected_address, size, &expected_mem_perm));
+}
diff --git a/components/messaging/ffa/libsp/tests.cmake b/components/messaging/ffa/libsp/tests.cmake
index 7b52248..63abb57 100644
--- a/components/messaging/ffa/libsp/tests.cmake
+++ b/components/messaging/ffa/libsp/tests.cmake
@@ -134,6 +134,19 @@ unit_test_add_suite(
-DARM64
)
+unit_test_add_suite(
+ NAME libsp_mock_sp_memory_management
+ SOURCES
+ ${CMAKE_CURRENT_LIST_DIR}/test/test_mock_sp_memory_management.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_sp_memory_management.cpp
+ INCLUDE_DIRECTORIES
+ ${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
+ COMPILE_DEFINITIONS
+ -DARM64
+)
+
unit_test_add_suite(
NAME libsp_sp_memory_management_internals
SOURCES
--
2.17.1
@@ -1,284 +0,0 @@
From 1e5ce152214e22a7cd9617a5059e42c370351354 Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Fri, 17 Jun 2022 15:40:18 +0200
Subject: [PATCH 20/24] Add mock for libsp/sp_messaging
Add mock_sp_messaging for mocking sp_messaging part of libsp.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I87478027c61b41028682b10e2535a7e14cf6922f
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../messaging/ffa/libsp/mock/component.cmake | 1 +
.../ffa/libsp/mock/mock_sp_messaging.cpp | 86 +++++++++++++++++++
.../ffa/libsp/mock/mock_sp_messaging.h | 39 +++++++++
.../mock/test/test_mock_sp_messaging.cpp | 77 +++++++++++++++++
components/messaging/ffa/libsp/tests.cmake | 14 +++
5 files changed, 217 insertions(+)
create mode 100644 components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp
create mode 100644 components/messaging/ffa/libsp/mock/mock_sp_messaging.h
create mode 100644 components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp
diff --git a/components/messaging/ffa/libsp/mock/component.cmake b/components/messaging/ffa/libsp/mock/component.cmake
index eb0d28c..375cb46 100644
--- a/components/messaging/ffa/libsp/mock/component.cmake
+++ b/components/messaging/ffa/libsp/mock/component.cmake
@@ -14,6 +14,7 @@ target_sources(${TGT} PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/mock_ffa_internal_api.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_sp_discovery.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_sp_memory_management.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/mock_sp_messaging.cpp"
"${CMAKE_CURRENT_LIST_DIR}/mock_sp_rxtx.cpp"
)
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp b/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp
new file mode 100644
index 0000000..522abb3
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/mock_sp_messaging.cpp
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ */
+
+#include <CppUTestExt/MockSupport.h>
+#include "mock_sp_messaging.h"
+
+void expect_sp_msg_wait(const struct sp_msg *msg, sp_result result)
+{
+ mock()
+ .expectOneCall("sp_msg_wait")
+ .withOutputParameterReturning("msg", msg, sizeof(*msg))
+ .andReturnValue(result);
+}
+
+sp_result sp_msg_wait(struct sp_msg *msg)
+{
+ return mock()
+ .actualCall("sp_msg_wait")
+ .withOutputParameter("msg", msg)
+ .returnIntValue();
+}
+
+void expect_sp_msg_send_direct_req(const struct sp_msg *req,
+ const struct sp_msg *resp,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_msg_send_direct_req")
+ .withMemoryBufferParameter("req", (const unsigned char *)req, sizeof(*req))
+ .withOutputParameterReturning("resp", resp, sizeof(*resp))
+ .andReturnValue(result);
+}
+
+sp_result sp_msg_send_direct_req(const struct sp_msg *req, struct sp_msg *resp)
+{
+ return mock()
+ .actualCall("sp_msg_send_direct_req")
+ .withMemoryBufferParameter("req", (const unsigned char *)req, sizeof(*req))
+ .withOutputParameter("resp", resp)
+ .returnIntValue();
+}
+
+void expect_sp_msg_send_direct_resp(const struct sp_msg *resp,
+ const struct sp_msg *req,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_msg_send_direct_resp")
+ .withMemoryBufferParameter("resp", (const unsigned char *)resp, sizeof(*resp))
+ .withOutputParameterReturning("req", req, sizeof(*req))
+ .andReturnValue(result);
+}
+
+sp_result sp_msg_send_direct_resp(const struct sp_msg *resp,
+ struct sp_msg *req)
+{
+ return mock()
+ .actualCall("sp_msg_send_direct_resp")
+ .withMemoryBufferParameter("resp", (const unsigned char *)resp, sizeof(*resp))
+ .withOutputParameter("req", req)
+ .returnIntValue();
+}
+
+#if FFA_DIRECT_MSG_ROUTING_EXTENSION
+void expect_sp_msg_send_rc_req(const struct sp_msg *req,
+ const struct sp_msg *resp,
+ sp_result result)
+{
+ mock()
+ .expectOneCall("sp_msg_send_rc_req")
+ .withMemoryBufferParameter("req", (const unsigned char *)req, sizeof(*req))
+ .withOutputParameterReturning("resp", resp, sizeof(*resp))
+ .andReturnValue(result);
+}
+
+sp_result sp_msg_send_rc_req(const struct sp_msg *req, struct sp_msg *resp)
+{
+ return mock()
+ .actualCall("sp_msg_send_rc_req")
+ .withMemoryBufferParameter("req", (const unsigned char *)req, sizeof(*req))
+ .withOutputParameter("resp", resp)
+ .returnIntValue();
+}
+#endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */
diff --git a/components/messaging/ffa/libsp/mock/mock_sp_messaging.h b/components/messaging/ffa/libsp/mock/mock_sp_messaging.h
new file mode 100644
index 0000000..8183012
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/mock_sp_messaging.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ */
+
+#ifndef LIBSP_MOCK_MOCK_SP_MESSAGING_H_
+#define LIBSP_MOCK_MOCK_SP_MESSAGING_H_
+
+#include "../include/sp_messaging.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void expect_sp_msg_wait(const struct sp_msg *msg, sp_result result);
+
+
+void expect_sp_msg_send_direct_req(const struct sp_msg *req,
+ const struct sp_msg *resp,
+ sp_result result);
+
+
+void expect_sp_msg_send_direct_resp(const struct sp_msg *resp,
+ const struct sp_msg *req,
+ sp_result result);
+
+#if FFA_DIRECT_MSG_ROUTING_EXTENSION
+void expect_sp_msg_send_rc_req(const struct sp_msg *req,
+ const struct sp_msg *resp,
+ sp_result result);
+#endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBSP_MOCK_MOCK_SP_MESSAGING_H_ */
diff --git a/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp b/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp
new file mode 100644
index 0000000..bfc7959
--- /dev/null
+++ b/components/messaging/ffa/libsp/mock/test/test_mock_sp_messaging.cpp
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ */
+
+#include <CppUTestExt/MockSupport.h>
+#include <CppUTest/TestHarness.h>
+#include "mock_sp_messaging.h"
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const struct sp_msg expected_req = {
+ .source_id = 0x0123,
+ .destination_id = 0x4567,
+ .args = {0x89abcdef, 0xfedcba98, 0x76543210, 0xabcdef01}
+};
+static const struct sp_msg expected_resp = {
+ .source_id = 0x1234,
+ .destination_id = 0x5678,
+ .args = {0x9abcdef8, 0xedcba98f, 0x65432107, 0xbcdef01a}
+};
+
+TEST_GROUP(mock_sp_messaging)
+{
+ TEST_SETUP()
+ {
+ memset(&req, 0x00, sizeof(req));
+ memset(&resp, 0x00, sizeof(resp));
+ }
+
+ TEST_TEARDOWN()
+ {
+ mock().checkExpectations();
+ mock().clear();
+ }
+
+ struct sp_msg req;
+ struct sp_msg resp;
+ static const sp_result result = -1;
+};
+
+TEST(mock_sp_messaging, sp_msg_wait)
+{
+ expect_sp_msg_wait(&expected_req, result);
+ LONGS_EQUAL(result, sp_msg_wait(&req));
+ MEMCMP_EQUAL(&expected_req, &req, sizeof(expected_req));
+}
+
+TEST(mock_sp_messaging, sp_msg_send_direct_req)
+{
+ req = expected_req;
+
+ expect_sp_msg_send_direct_req(&expected_req, &expected_resp, result);
+ LONGS_EQUAL(result, sp_msg_send_direct_req(&req, &resp));
+ MEMCMP_EQUAL(&expected_resp, &resp, sizeof(expected_resp));
+}
+
+TEST(mock_sp_messaging, sp_msg_send_direct_resp)
+{
+ resp = expected_resp;
+
+ expect_sp_msg_send_direct_resp(&expected_resp, &expected_req, result);
+ LONGS_EQUAL(result, sp_msg_send_direct_resp(&resp, &req));
+ MEMCMP_EQUAL(&expected_req, &req, sizeof(expected_req));
+}
+
+#if FFA_DIRECT_MSG_ROUTING_EXTENSION
+TEST(mock_sp_messaging, sp_msg_send_rc_req)
+{
+ req = expected_req;
+
+ expect_sp_msg_send_rc_req(&expected_req, &expected_resp, result);
+ LONGS_EQUAL(result, sp_msg_send_rc_req(&req, &resp));
+ MEMCMP_EQUAL(&expected_resp, &resp, sizeof(expected_resp));
+}
+#endif /* FFA_DIRECT_MSG_ROUTING_EXTENSION */
diff --git a/components/messaging/ffa/libsp/tests.cmake b/components/messaging/ffa/libsp/tests.cmake
index 63abb57..eb0b41e 100644
--- a/components/messaging/ffa/libsp/tests.cmake
+++ b/components/messaging/ffa/libsp/tests.cmake
@@ -176,6 +176,20 @@ unit_test_add_suite(
-DARM64
)
+unit_test_add_suite(
+ NAME libsp_mock_sp_messaging
+ SOURCES
+ ${CMAKE_CURRENT_LIST_DIR}/mock/test/test_mock_sp_messaging.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/mock/mock_sp_messaging.cpp
+ INCLUDE_DIRECTORIES
+ ${CMAKE_CURRENT_LIST_DIR}/include/
+ ${CMAKE_CURRENT_LIST_DIR}/mock
+ ${UNIT_TEST_PROJECT_PATH}/components/common/utils/include
+ COMPILE_DEFINITIONS
+ -DARM64
+ -DFFA_DIRECT_MSG_ROUTING_EXTENSION=1
+)
+
unit_test_add_suite(
NAME libsp_sp_messaging_with_routing_extension
SOURCES
--
2.17.1
@@ -1,497 +0,0 @@
From 0f02f04c7f0a7130874dc4bc1a500604d580c4dc Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Wed, 20 Jul 2022 15:19:17 +0200
Subject: [PATCH 22/24] Change MM communicate RPC protocol of call endpoint
Replace buffer address and size parameter by offset in buffer parameter
and move to 64 bit FF-A direct message call. Deny all 32 bit direct
messages in SMM gateway.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I7a69b440ff9842960229b2bfdd1b5ae5318d9c26
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../common/mm_communicate_call_args.h | 15 ++-
.../endpoint/sp/mm_communicate_call_ep.c | 58 ++++-----
.../endpoint/sp/test/mock_mm_service.cpp | 6 +-
.../endpoint/sp/test/mock_mm_service.h | 4 +-
.../sp/test/test_mm_communicate_call_ep.cpp | 110 +++++++++++-------
.../endpoint/sp/test/test_mock_mm_service.cpp | 4 +-
.../smm-gateway/common/smm_gateway_sp.c | 17 ++-
7 files changed, 123 insertions(+), 91 deletions(-)
diff --git a/components/rpc/mm_communicate/common/mm_communicate_call_args.h b/components/rpc/mm_communicate/common/mm_communicate_call_args.h
index 7d7311d..280c04d 100644
--- a/components/rpc/mm_communicate/common/mm_communicate_call_args.h
+++ b/components/rpc/mm_communicate/common/mm_communicate_call_args.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef MM_COMMUNICATE_CALL_ARGS_H_
@@ -12,13 +12,12 @@
*/
/* SP message arg indexes */
-#define MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_ADDRESS 0
-#define MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_SIZE 1
+#define MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_OFFSET 0
-#define MM_COMMUNICATE_CALL_ARGS_RETURN_ID 0
-#define MM_COMMUNICATE_CALL_ARGS_RETURN_CODE 1
-#define MM_COMMUNICATE_CALL_ARGS_MBZ0 2
-#define MM_COMMUNICATE_CALL_ARGS_MBZ1 3
-#define MM_COMMUNICATE_CALL_ARGS_MBZ2 4
+#define MM_COMMUNICATE_CALL_ARGS_RETURN_CODE 0
+#define MM_COMMUNICATE_CALL_ARGS_MBZ0 1
+#define MM_COMMUNICATE_CALL_ARGS_MBZ1 2
+#define MM_COMMUNICATE_CALL_ARGS_MBZ2 3
+#define MM_COMMUNICATE_CALL_ARGS_MBZ3 4
#endif /* MM_COMMUNICATE_CALL_ARGS_H_ */
diff --git a/components/rpc/mm_communicate/endpoint/sp/mm_communicate_call_ep.c b/components/rpc/mm_communicate/endpoint/sp/mm_communicate_call_ep.c
index dc49e64..93aa0f4 100644
--- a/components/rpc/mm_communicate/endpoint/sp/mm_communicate_call_ep.c
+++ b/components/rpc/mm_communicate/endpoint/sp/mm_communicate_call_ep.c
@@ -35,7 +35,8 @@ bool mm_communicate_call_ep_init(struct mm_communicate_ep *call_ep, uint8_t *com
static int32_t invoke_mm_service(struct mm_communicate_ep *call_ep, uint16_t source_id,
struct mm_service_interface *iface,
- EFI_MM_COMMUNICATE_HEADER *header)
+ EFI_MM_COMMUNICATE_HEADER *header,
+ size_t buffer_size)
{
rpc_status_t rpc_status = TS_RPC_ERROR_INTERNAL;
struct mm_service_call_req call_req = { 0 };
@@ -49,11 +50,11 @@ static int32_t invoke_mm_service(struct mm_communicate_ep *call_ep, uint16_t sou
*/
call_req.req_buf.data = header->Data;
call_req.req_buf.data_len = header->MessageLength;
- call_req.req_buf.size = call_ep->comm_buffer_size - EFI_MM_COMMUNICATE_HEADER_SIZE;
+ call_req.req_buf.size = buffer_size;
call_req.resp_buf.data = header->Data;
call_req.resp_buf.data_len = 0;
- call_req.resp_buf.size = call_ep->comm_buffer_size - EFI_MM_COMMUNICATE_HEADER_SIZE;
+ call_req.resp_buf.size = buffer_size;
result = iface->receive(iface, &call_req);
@@ -63,32 +64,38 @@ static int32_t invoke_mm_service(struct mm_communicate_ep *call_ep, uint16_t sou
}
static int32_t handle_mm_communicate(struct mm_communicate_ep *call_ep, uint16_t source_id,
- uintptr_t buffer_addr, size_t buffer_size)
+ size_t buffer_offset)
{
- uintptr_t buffer_arg = 0;
- size_t request_size = 0;
+ size_t header_end_offset = 0;
+ size_t request_end_offset = 0;
+ size_t buffer_size = 0;
EFI_MM_COMMUNICATE_HEADER *header = NULL;
unsigned int i = 0;
- /* Validating call args according to ARM MM spec 3.2.4 */
- if (buffer_addr == 0)
+ if (ADD_OVERFLOW(buffer_offset, EFI_MM_COMMUNICATE_HEADER_SIZE, &header_end_offset))
+ return MM_RETURN_CODE_INVALID_PARAMETER;
+
+ if (call_ep->comm_buffer_size < header_end_offset)
return MM_RETURN_CODE_INVALID_PARAMETER;
/* Validating comm buffer contents */
- header = (EFI_MM_COMMUNICATE_HEADER *)call_ep->comm_buffer;
- if (ADD_OVERFLOW(header->MessageLength, EFI_MM_COMMUNICATE_HEADER_SIZE, &request_size))
+ header = (EFI_MM_COMMUNICATE_HEADER *)(call_ep->comm_buffer + buffer_offset);
+ if (ADD_OVERFLOW(header_end_offset, header->MessageLength, &request_end_offset))
return MM_RETURN_CODE_INVALID_PARAMETER;
- if (call_ep->comm_buffer_size < request_size)
+ if (call_ep->comm_buffer_size < request_end_offset)
return MM_RETURN_CODE_INVALID_PARAMETER;
+ buffer_size = call_ep->comm_buffer_size - header_end_offset;
+
/* Finding iface_id by GUID */
for (i = 0; i < ARRAY_SIZE(call_ep->service_table); i++) {
const struct mm_service_entry *entry = &call_ep->service_table[i];
if (entry->iface != NULL &&
memcmp(&header->HeaderGuid, &entry->guid, sizeof(entry->guid)) == 0)
- return invoke_mm_service(call_ep, source_id, entry->iface, header);
+ return invoke_mm_service(call_ep, source_id, entry->iface, header,
+ buffer_size);
}
return MM_RETURN_CODE_NOT_SUPPORTED;
@@ -123,19 +130,16 @@ void mm_communicate_call_ep_receive(struct mm_communicate_ep *mm_communicate_cal
const struct ffa_direct_msg *req_msg,
struct ffa_direct_msg *resp_msg)
{
- int32_t return_value = 0;
- uintptr_t buffer_address = 0;
- size_t buffer_size = 0;
-
- buffer_address = req_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_ADDRESS];
- buffer_size = req_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_SIZE];
-
- return_value = handle_mm_communicate(mm_communicate_call_ep, req_msg->source_id,
- buffer_address, buffer_size);
-
- resp_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_RETURN_ID] = ARM_SVC_ID_SP_EVENT_COMPLETE;
- resp_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_RETURN_CODE] = return_value;
- resp_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_MBZ0] = 0;
- resp_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_MBZ1] = 0;
- resp_msg->args.args32[MM_COMMUNICATE_CALL_ARGS_MBZ2] = 0;
+ int32_t return_value = MM_RETURN_CODE_NOT_SUPPORTED;
+ size_t buffer_offset = req_msg->args.args64[MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_OFFSET];
+
+ return_value = handle_mm_communicate(mm_communicate_call_ep,
+ req_msg->source_id,
+ buffer_offset);
+
+ resp_msg->args.args64[MM_COMMUNICATE_CALL_ARGS_RETURN_CODE] = return_value;
+ resp_msg->args.args64[MM_COMMUNICATE_CALL_ARGS_MBZ0] = 0;
+ resp_msg->args.args64[MM_COMMUNICATE_CALL_ARGS_MBZ1] = 0;
+ resp_msg->args.args64[MM_COMMUNICATE_CALL_ARGS_MBZ2] = 0;
+ resp_msg->args.args64[MM_COMMUNICATE_CALL_ARGS_MBZ3] = 0;
}
diff --git a/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.cpp b/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.cpp
index a58c33a..0ae2a80 100644
--- a/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.cpp
+++ b/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#include <CppUTestExt/MockSupport.h>
@@ -16,7 +16,7 @@ void mock_mm_service_init(void)
void expect_mock_mm_service_receive(struct mm_service_interface *iface,
const struct mm_service_call_req *req,
- int32_t result)
+ int64_t result)
{
mock().expectOneCall("mm_service_receive").onObject(iface).
withOutputParameterReturning("resp_buf_data_len", &req->resp_buf.data_len,
@@ -31,5 +31,5 @@ int32_t mock_mm_service_receive(struct mm_service_interface *iface,
return mock().actualCall("mm_service_receive").onObject(iface).
withOutputParameter("resp_buf_data_len", &req->resp_buf.data_len).
withParameterOfType("mm_service_call_req", "req", req).
- returnIntValue();
+ returnLongIntValue();
}
diff --git a/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.h b/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.h
index 768022d..56c8a26 100644
--- a/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.h
+++ b/components/rpc/mm_communicate/endpoint/sp/test/mock_mm_service.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#ifndef MOCK_MM_SERVICE_H_
@@ -16,7 +16,7 @@ void mock_mm_service_init(void);
void expect_mock_mm_service_receive(struct mm_service_interface *iface,
const struct mm_service_call_req *req,
- int32_t result);
+ int64_t result);
int32_t mock_mm_service_receive(struct mm_service_interface *iface,
struct mm_service_call_req *req);
diff --git a/components/rpc/mm_communicate/endpoint/sp/test/test_mm_communicate_call_ep.cpp b/components/rpc/mm_communicate/endpoint/sp/test/test_mm_communicate_call_ep.cpp
index 55a61fb..5aaa3a6 100644
--- a/components/rpc/mm_communicate/endpoint/sp/test/test_mm_communicate_call_ep.cpp
+++ b/components/rpc/mm_communicate/endpoint/sp/test/test_mm_communicate_call_ep.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#include <CppUTest/TestHarness.h>
@@ -32,14 +32,14 @@ TEST_GROUP(mm_communicate_call_ep)
mock().clear();
}
- void check_sp_msg(const struct ffa_direct_msg *msg, uint32_t arg0,
- uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4)
+ void check_sp_msg(const struct ffa_direct_msg *msg, uint64_t arg0,
+ uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4)
{
- UNSIGNED_LONGLONGS_EQUAL(arg0, msg->args[0]);
- UNSIGNED_LONGLONGS_EQUAL(arg1, msg->args[1]);
- UNSIGNED_LONGLONGS_EQUAL(arg2, msg->args[2]);
- UNSIGNED_LONGLONGS_EQUAL(arg3, msg->args[3]);
- UNSIGNED_LONGLONGS_EQUAL(arg4, msg->args[4]);
+ UNSIGNED_LONGLONGS_EQUAL(arg0, msg->args.args64[0]);
+ UNSIGNED_LONGLONGS_EQUAL(arg1, msg->args.args64[1]);
+ UNSIGNED_LONGLONGS_EQUAL(arg2, msg->args.args64[2]);
+ UNSIGNED_LONGLONGS_EQUAL(arg3, msg->args.args64[3]);
+ UNSIGNED_LONGLONGS_EQUAL(arg4, msg->args.args64[4]);
}
struct mm_communicate_ep call_ep;
@@ -114,59 +114,54 @@ TEST(mm_communicate_call_ep, attach_do_not_fit)
}
}
-TEST(mm_communicate_call_ep, mm_communicate_no_buffer_arg)
+TEST(mm_communicate_call_ep, mm_communicate_offset_int_overflow)
{
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
+ req_msg.args.args64[0] = 0xffffffffffffffff;
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_INVALID_PARAMETER,
- 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_INVALID_PARAMETER, 0, 0, 0, 0);
}
-TEST(mm_communicate_call_ep, mm_communicate_length_overflow)
+TEST(mm_communicate_call_ep, mm_communicate_offset_overflow)
{
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
+ req_msg.args.args64[0] = sizeof(comm_buffer) - EFI_MM_COMMUNICATE_HEADER_SIZE + 1;
+
+ mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_INVALID_PARAMETER, 0, 0, 0, 0);
+}
+TEST(mm_communicate_call_ep, mm_communicate_length_overflow)
+{
+ CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
header->MessageLength = UINT64_MAX - EFI_MM_COMMUNICATE_HEADER_SIZE + 1;
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_INVALID_PARAMETER,
- 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_INVALID_PARAMETER, 0, 0, 0, 0);
}
TEST(mm_communicate_call_ep, mm_communicate_too_large)
{
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
-
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
-
header->MessageLength = sizeof(comm_buffer) - EFI_MM_COMMUNICATE_HEADER_SIZE + 1;
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_INVALID_PARAMETER,
- 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_INVALID_PARAMETER, 0, 0, 0, 0);
}
TEST(mm_communicate_call_ep, mm_communicate_no_handler)
{
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
-
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
-
header->MessageLength = 0;
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_NOT_SUPPORTED,
- 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_NOT_SUPPORTED, 0, 0, 0, 0);
}
TEST(mm_communicate_call_ep, mm_communicate_single_handler_not_matching)
@@ -175,16 +170,11 @@ TEST(mm_communicate_call_ep, mm_communicate_single_handler_not_matching)
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
mm_communicate_call_ep_attach_service(&call_ep, &guid0, &iface);
-
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
-
header->MessageLength = 0;
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_NOT_SUPPORTED,
- 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_NOT_SUPPORTED, 0, 0, 0, 0);
}
TEST(mm_communicate_call_ep, mm_communicate_single_handler_matching)
@@ -211,19 +201,55 @@ TEST(mm_communicate_call_ep, mm_communicate_single_handler_matching)
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
mm_communicate_call_ep_attach_service(&call_ep, &guid0, &iface);
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
+ memcpy(&header->HeaderGuid, &guid0, sizeof(guid0));
+ header->MessageLength = req_len;
+
+ expect_mock_mm_service_receive(&iface, &req, MM_RETURN_CODE_SUCCESS);
+
+ mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
+
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_SUCCESS, 0, 0, 0, 0);
+}
+
+TEST(mm_communicate_call_ep, mm_communicate_single_handler_matching_with_offset)
+{
+ const size_t offset = 0x10;
+ EFI_MM_COMMUNICATE_HEADER *header = (EFI_MM_COMMUNICATE_HEADER *)(comm_buffer + offset);
+
+ const size_t req_len = 16;
+ struct mm_service_interface iface = {
+ .context = (void *)0x1234,
+ .receive = mock_mm_service_receive
+ };
+ struct mm_service_call_req req = {
+ .guid = &guid0,
+ .req_buf = {
+ .size = sizeof(comm_buffer) - EFI_MM_COMMUNICATE_HEADER_SIZE - offset,
+ .data_len = req_len,
+ .data = header->Data
+ },
+ .resp_buf = {
+ .size = sizeof(comm_buffer) - EFI_MM_COMMUNICATE_HEADER_SIZE - offset,
+ .data_len = 0,
+ .data = header->Data
+ },
+ };
+
+ CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
+ mm_communicate_call_ep_attach_service(&call_ep, &guid0, &iface);
memcpy(&header->HeaderGuid, &guid0, sizeof(guid0));
header->MessageLength = req_len;
+ req_msg.args.args64[0] = offset;
expect_mock_mm_service_receive(&iface, &req, MM_RETURN_CODE_SUCCESS);
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_SUCCESS, 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_SUCCESS, 0, 0, 0, 0);
}
+
TEST(mm_communicate_call_ep, mm_communicate_single_handler_matching_error)
{
const size_t req_len = 16;
@@ -248,9 +274,6 @@ TEST(mm_communicate_call_ep, mm_communicate_single_handler_matching_error)
CHECK_TRUE(mm_communicate_call_ep_init(&call_ep, comm_buffer, sizeof(comm_buffer)));
mm_communicate_call_ep_attach_service(&call_ep, &guid0, &iface);
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
-
memcpy(&header->HeaderGuid, &guid0, sizeof(guid0));
header->MessageLength = req_len;
@@ -258,7 +281,7 @@ TEST(mm_communicate_call_ep, mm_communicate_single_handler_matching_error)
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_NO_MEMORY, 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_NO_MEMORY, 0, 0, 0, 0);
}
TEST(mm_communicate_call_ep, mm_communicate_two_handlers)
@@ -290,9 +313,6 @@ TEST(mm_communicate_call_ep, mm_communicate_two_handlers)
mm_communicate_call_ep_attach_service(&call_ep, &guid0, &iface0);
mm_communicate_call_ep_attach_service(&call_ep, &guid1, &iface1);
- req_msg.args[0] = (uintptr_t)comm_buffer;
- req_msg.args[1] = sizeof(comm_buffer);
-
memcpy(&header->HeaderGuid, &guid1, sizeof(guid0));
header->MessageLength = req_len;
@@ -300,5 +320,5 @@ TEST(mm_communicate_call_ep, mm_communicate_two_handlers)
mm_communicate_call_ep_receive(&call_ep, &req_msg, &resp_msg);
- check_sp_msg(&resp_msg, ARM_SVC_ID_SP_EVENT_COMPLETE, MM_RETURN_CODE_SUCCESS, 0, 0, 0);
+ check_sp_msg(&resp_msg, MM_RETURN_CODE_SUCCESS, 0, 0, 0, 0);
}
diff --git a/components/rpc/mm_communicate/endpoint/sp/test/test_mock_mm_service.cpp b/components/rpc/mm_communicate/endpoint/sp/test/test_mock_mm_service.cpp
index 360a8fa..600386e 100644
--- a/components/rpc/mm_communicate/endpoint/sp/test/test_mock_mm_service.cpp
+++ b/components/rpc/mm_communicate/endpoint/sp/test/test_mock_mm_service.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
*/
#include <CppUTest/TestHarness.h>
@@ -44,7 +44,7 @@ TEST(mock_mm_service, receive)
.data = (void *)0x2345
}
};
- int32_t result = -123456;
+ int64_t result = -123456;
expect_mock_mm_service_receive(&iface, &req, result);
LONGS_EQUAL(result, mock_mm_service_receive(&iface, &req));
diff --git a/deployments/smm-gateway/common/smm_gateway_sp.c b/deployments/smm-gateway/common/smm_gateway_sp.c
index 3697b7f..3062877 100644
--- a/deployments/smm-gateway/common/smm_gateway_sp.c
+++ b/deployments/smm-gateway/common/smm_gateway_sp.c
@@ -11,6 +11,7 @@
#include "components/rpc/mm_communicate/endpoint/sp/mm_communicate_call_ep.h"
#include "components/service/smm_variable/frontend/mm_communicate/smm_variable_mm_service.h"
#include "platform/interface/memory_region.h"
+#include "protocols/common/mm/mm_smc.h"
#include <ffa_api.h>
#include <sp_api.h>
#include <sp_messaging.h>
@@ -68,12 +69,20 @@ void __noreturn sp_main(struct ffa_init_info *init_info)
ffa_msg_wait(&req_msg);
while (1) {
+ if (FFA_IS_32_BIT_FUNC(req_msg.function_id)) {
+ EMSG("MM communicate over 32 bit FF-A messages is not supported");
+ ffa_msg_send_direct_resp_32(req_msg.destination_id, req_msg.source_id,
+ MM_RETURN_CODE_NOT_SUPPORTED, 0, 0, 0, 0,
+ &req_msg);
+ continue;
+ }
+
mm_communicate_call_ep_receive(&mm_communicate_call_ep, &req_msg, &resp_msg);
- ffa_msg_send_direct_resp_32(req_msg.destination_id,
- req_msg.source_id, resp_msg.args.args32[0],
- resp_msg.args.args32[1], resp_msg.args.args32[2],
- resp_msg.args.args32[3], resp_msg.args.args32[4],
+ ffa_msg_send_direct_resp_64(req_msg.destination_id,
+ req_msg.source_id, resp_msg.args.args64[0],
+ resp_msg.args.args64[1], resp_msg.args.args64[2],
+ resp_msg.args.args64[3], resp_msg.args.args64[4],
&req_msg);
}
--
2.17.1
@@ -1,100 +0,0 @@
From 96d226e4e0ea9c633dbc5d05ae2a7a2f4ba0f39e Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Fri, 22 Jul 2022 17:22:05 +0200
Subject: [PATCH 23/24] Change MM communicate RPC protocol of MM caller
Replace buffer address and size parameter by offset in buffer parameter
and move to 64 bit FF-A direct message call. This change requires an
updated version of the debugfs driver which supports 64 bit direct
messages.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I003c1de7f9c3f45bbc52e4a51d622ec960fa7052
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../caller/linux/mm_communicate_caller.c | 35 +++++++------------
.../LinuxFFAUserShim/LinuxFFAUserShim.cmake | 2 +-
2 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/components/rpc/mm_communicate/caller/linux/mm_communicate_caller.c b/components/rpc/mm_communicate/caller/linux/mm_communicate_caller.c
index 0c505b4..0287acf 100644
--- a/components/rpc/mm_communicate/caller/linux/mm_communicate_caller.c
+++ b/components/rpc/mm_communicate/caller/linux/mm_communicate_caller.c
@@ -19,7 +19,7 @@
#include <string.h>
#include <errno.h>
-#define KERNEL_MOD_REQ_VER_MAJOR 2
+#define KERNEL_MOD_REQ_VER_MAJOR 5
#define KERNEL_MOD_REQ_VER_MINOR 0
#define KERNEL_MOD_REQ_VER_PATCH 0
@@ -294,37 +294,28 @@ static rpc_status_t call_invoke(
direct_msg.dst_id = s->dest_partition_id;
- direct_msg.args[MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_ADDRESS] = (uintptr_t)s->comm_buffer;
- direct_msg.args[MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_SIZE] = s->comm_buffer_size;
+ direct_msg.args[MM_COMMUNICATE_CALL_ARGS_COMM_BUFFER_OFFSET] = 0;
int kernel_op_status = ioctl(s->ffa_fd, FFA_IOC_MSG_SEND, &direct_msg);
if (kernel_op_status == 0) {
-
/* Kernel send operation completed normally */
- uint32_t mm_return_id = direct_msg.args[MM_COMMUNICATE_CALL_ARGS_RETURN_ID];
int32_t mm_return_code = direct_msg.args[MM_COMMUNICATE_CALL_ARGS_RETURN_CODE];
- if (mm_return_id == ARM_SVC_ID_SP_EVENT_COMPLETE) {
-
- if (mm_return_code == MM_RETURN_CODE_SUCCESS) {
-
- mm_communicate_serializer_header_decode(s->serializer,
- s->comm_buffer, (efi_status_t*)opstatus, resp_buf, resp_len);
-
- if (*resp_len > s->req_len) {
+ if (mm_return_code == MM_RETURN_CODE_SUCCESS) {
+ mm_communicate_serializer_header_decode(
+ s->serializer, s->comm_buffer, (efi_status_t *)opstatus,
+ resp_buf, resp_len);
- s->scrub_len =
- mm_communicate_serializer_header_size(s->serializer) +
- *resp_len;
- }
+ if (*resp_len > s->req_len)
+ s->scrub_len =
+ mm_communicate_serializer_header_size(
+ s->serializer) + *resp_len;
- rpc_status = TS_RPC_CALL_ACCEPTED;
- }
- else {
+ rpc_status = TS_RPC_CALL_ACCEPTED;
+ } else {
- rpc_status = mm_return_code_to_rpc_status(mm_return_code);
- }
+ rpc_status = mm_return_code_to_rpc_status(mm_return_code);
}
}
}
diff --git a/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake b/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake
index 7ba64af..9c2252c 100644
--- a/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake
+++ b/external/LinuxFFAUserShim/LinuxFFAUserShim.cmake
@@ -11,7 +11,7 @@
set(LINUX_FFA_USER_SHIM_URL "https://git.gitlab.arm.com/linux-arm/linux-trusted-services.git"
CACHE STRING "Linux FF-A user space shim repository URL")
-set(LINUX_FFA_USER_SHIM_REFSPEC "v4.0.0"
+set(LINUX_FFA_USER_SHIM_REFSPEC "v5.0.0"
CACHE STRING "Linux FF-A user space shim git refspec")
set(LINUX_FFA_USER_SHIM_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/linux_ffa_user_shim-src"
--
2.17.1
@@ -1,70 +0,0 @@
From f173e99554512c982665c1d5d4b0543421177b09 Mon Sep 17 00:00:00 2001
From: Imre Kis <imre.kis@arm.com>
Date: Tue, 26 Jul 2022 17:06:46 +0200
Subject: [PATCH 24/24] Deny 64 bit FF-A messages in FF-A RPC endpoint
FF-A RPC protocol only allows 32 bit FF-A direct messages thus deny all
64 bit messages in the RPC endpoint.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I37c95425f80b6e2821b3f6b8649ceba8aa007bce
Upstream-Status: Pending [In review]
Signed-off-by: Anton Antonov <Anton.Antonov@arm.com>
---
.../rpc/ffarpc/endpoint/ffarpc_call_ep.c | 31 ++++++++++++-------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
index c024196..3035c16 100644
--- a/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
+++ b/components/rpc/ffarpc/endpoint/ffarpc_call_ep.c
@@ -12,6 +12,7 @@
#include <protocols/rpc/common/packed-c/status.h>
#include <trace.h>
#include <stddef.h>
+#include <string.h>
/* TODO: remove this when own ID will be available in libsp */
extern uint16_t own_id;
@@ -260,17 +261,25 @@ void ffa_call_ep_receive(struct ffa_call_ep *call_ep,
const struct sp_msg *req_msg,
struct sp_msg *resp_msg)
{
- const uint32_t *req_args = req_msg->args.args32;
- uint32_t *resp_args = resp_msg->args.args32;
-
- uint16_t source_id = req_msg->source_id;
- uint32_t ifaceid_opcode = req_args[SP_CALL_ARGS_IFACE_ID_OPCODE];
-
- if (FFA_CALL_ARGS_EXTRACT_IFACE(ifaceid_opcode) == FFA_CALL_MGMT_IFACE_ID) {
- /* It's an RPC layer management request */
- handle_mgmt_msg(call_ep, source_id, req_args, resp_args);
+ resp_msg->is_64bit_message = req_msg->is_64bit_message;
+ memset(&resp_msg->args, 0x00, sizeof(resp_msg->args));
+
+ if (!req_msg->is_64bit_message) {
+ const uint32_t *req_args = req_msg->args.args32;
+ uint32_t *resp_args = resp_msg->args.args32;
+ uint16_t source_id = req_msg->source_id;
+ uint32_t ifaceid_opcode = req_args[SP_CALL_ARGS_IFACE_ID_OPCODE];
+
+ if (FFA_CALL_ARGS_EXTRACT_IFACE(ifaceid_opcode) == FFA_CALL_MGMT_IFACE_ID) {
+ /* It's an RPC layer management request */
+ handle_mgmt_msg(call_ep, source_id, req_args, resp_args);
+ } else {
+ /* Assume anything else is a service request */
+ handle_service_msg(call_ep, source_id, req_args, resp_args);
+ }
} else {
- /* Assume anything else is a service request */
- handle_service_msg(call_ep, source_id, req_args, resp_args);
+ EMSG("64 bit FF-A messages are not supported by the TS RPC layer");
+ resp_msg->args.args64[SP_CALL_ARGS_RESP_RPC_STATUS] =
+ TS_RPC_ERROR_INVALID_PARAMETER;
}
}
--
2.17.1
@@ -9,18 +9,10 @@ SRC_URI = "git://git.trustedfirmware.org/TS/trusted-services.git;protocol=https;
file://0009-PSA-CRYPTO-API-INCLUDE.patch \
file://0010-change-libts-to-export-CMake-package.patch \
file://0011-Adapt-deployments-to-libts-changes.patch \
file://0017-Move-libsp-mocks-into-separate-component.patch \
file://0018-Add-mock-for-libsp-sp_discovery.patch \
file://0019-Add-mock-for-libsp-sp_memory_management.patch \
file://0020-Add-mock-for-libsp-sp_messaging.patch \
file://0021-Add-64-bit-direct-message-handling-to-libsp.patch \
file://0022-Change-MM-communicate-RPC-protocol-of-call-endpoint.patch \
file://0023-Change-MM-communicate-RPC-protocol-of-MM-caller.patch \
file://0024-Deny-64-bit-FF-A-messages-in-FF-A-RPC-endpoint.patch \
"
#latest on 05.07.22.
SRCREV_trusted-services = "1b0c520279445fc4d85fc582eda5e5ff5f380c39"
#latest on 07.10.22.
SRCREV_trusted-services = "45353ba0bd5b4059e71ae67f9c49749da8b41b43"
LIC_FILES_CHKSUM = "file://${S}/license.rst;md5=ea160bac7f690a069c608516b17997f4"
S = "${WORKDIR}/git/trusted-services"