summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2018-01-16 10:04:16 +0100
committerSandrine Bailleux <sandrine.bailleux@arm.com>2018-01-22 14:49:46 +0000
commit992788147ff7461b37eb52f17ad962ef21fc372f (patch)
tree595d0856f8984e4c6a6c6172167ef78277a84cd5
parenta3077f97cf34e827bfa57d856d395ee98493f1d2 (diff)
FVP: Add support for comm. buffer in MM_COMMUNICATE
The MM_COMMUNICATE SMC interface supports passing a communication buffer for additional payload data from normal world to the secure partition. This commit adds support to use it. On the TFTF side, the memory mappings have been changed to map this memory buffer area. This allows TFTF tests to fill in this buffer to pass data associated to secure service requests. The number of translation tables had to be increased to map this new memory region. On Cactus' side, the secure services loop has been modified to read the communication buffer for MM_COMMUNICATE messages. A common data structure has been defined, that corresponds to the type of information that TFTF and Cactus will exchange through MM_COMMUNICATE messages. The structure might evolve in the future as we get a better idea of the kind of data that need to be passed for secure services requests. The existing MM_COMMUNICATE tests in TFTF have been modified to pass a valid communication buffer address with a dummy ID. Change-Id: I2df80a3e64f77eb229783802201a01008d3f9c2f Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
-rw-r--r--cactus/cactus_main.c56
-rw-r--r--include/plat/arm/common/arm_def.h24
-rw-r--r--include/runtime_services/secure_el0_payloads/secure_partition.h14
-rw-r--r--plat/arm/board/armstrong/include/platform_def.h3
-rw-r--r--plat/arm/board/ashbrook/include/platform_def.h3
-rw-r--r--plat/arm/board/fvp/include/platform_def.h8
-rw-r--r--plat/arm/board/fvp/plat_setup.c2
-rw-r--r--plat/arm/board/juno/include/platform_def.h3
-rw-r--r--tests/runtime_services/secure_service/secure_service_helpers.c23
-rw-r--r--tests/runtime_services/secure_service/test_secure_service_handle.c26
-rw-r--r--tests/tests.mk1
11 files changed, 136 insertions, 27 deletions
diff --git a/cactus/cactus_main.c b/cactus/cactus_main.c
index f04b1b4..3dd5009 100644
--- a/cactus/cactus_main.c
+++ b/cactus/cactus_main.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
#include <console.h>
#include <debug.h>
#include <mm_svc.h>
@@ -57,6 +58,9 @@ static void cactus_print_memory_layout(const secure_partition_boot_info_t *boot_
(void *) boot_info->sp_ns_comm_buf_base,
(void *)(boot_info->sp_ns_comm_buf_base + boot_info->sp_ns_comm_buf_size));
+ assert(boot_info->sp_ns_comm_buf_base == ARM_SECURE_SERVICE_BUFFER_BASE);
+ assert(boot_info->sp_ns_comm_buf_size == ARM_SECURE_SERVICE_BUFFER_SIZE);
+
NOTICE(" Stacks region (%u CPUS) : %p - %p\n",
boot_info->num_cpus,
(void *) boot_info->sp_stack_base,
@@ -72,6 +76,8 @@ static void cactus_print_memory_layout(const secure_partition_boot_info_t *boot_
}
+
+
static __dead2 void secure_services_loop(void)
{
int32_t event_status_code;
@@ -92,18 +98,56 @@ static __dead2 void secure_services_loop(void)
switch (event_id) {
case MM_COMMUNICATE_AARCH64:
+ {
+ uint64_t ctx_addr = svc_values.arg1;
+ uint32_t ctx_size = svc_values.arg2;
+ uint64_t cookie = svc_values.arg3;
+
+ NOTICE("Cactus: Received MM_COMMUNICATE_AARCH64 call\n");
+ NOTICE("Cactus: Context address: 0x%lx\n", ctx_addr);
+ NOTICE("Cactus: Context size : %u\n", ctx_size);
+ NOTICE("Cactus: Cookie : 0x%lx\n", cookie);
+
+ if (ctx_addr == 0) {
+ ERROR("Context address is invalid\n");
+ event_status_code = SPM_INVALID_PARAMETER;
+ continue;
+ }
+
+ secure_partition_request_info_t *sps = (void *)(uintptr_t) ctx_addr;
+ NOTICE("Received fast secure service request with ID #%u\n",
+ sps->id);
+ event_status_code = SPM_SUCCESS;
+ break;
+ }
+
case MM_COMMUNICATE_AARCH32:
- NOTICE("Cactus: Received MM_COMMUNICATE call on CPU #%lu\n",
- svc_values.arg3);
- NOTICE("Cactus: Context address: %p\n", (void *) svc_values.arg1);
- NOTICE("Cactus: Context size : %lu\n", svc_values.arg2);
- NOTICE("Cactus: Cookie : 0x%lx\n", svc_values.arg3);
+ {
+ uint32_t ctx_addr = svc_values.arg1;
+ uint32_t ctx_size = svc_values.arg2;
+ uint32_t cookie = svc_values.arg3;
+
+ NOTICE("Cactus: Received MM_COMMUNICATE_AARCH32 call\n");
+ NOTICE("Cactus: Context address: 0x%x\n", ctx_addr);
+ NOTICE("Cactus: Context size : %u\n", ctx_size);
+ NOTICE("Cactus: Cookie : 0x%x\n", cookie);
+
+ if (ctx_addr == 0) {
+ ERROR("Context address is invalid\n");
+ event_status_code = SPM_INVALID_PARAMETER;
+ continue;
+ }
+
+ secure_partition_request_info_t *sps = (void *)(uintptr_t) ctx_addr;
+ NOTICE("Received fast secure service request with ID #%u\n",
+ sps->id);
event_status_code = SPM_SUCCESS;
break;
+ }
default:
NOTICE("Unhandled Service ID 0x%x\n", event_id);
- event_status_code = -1;
+ event_status_code = SPM_NOT_SUPPORTED;
break;
}
}
diff --git a/include/plat/arm/common/arm_def.h b/include/plat/arm/common/arm_def.h
new file mode 100644
index 0000000..2d3731b
--- /dev/null
+++ b/include/plat/arm/common/arm_def.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __ARM_DEF_H__
+#define __ARM_DEF_H__
+
+/******************************************************************************
+ * Definitions common to all ARM standard platforms
+ *****************************************************************************/
+
+/*******************************************************************************
+ * Location of the memory buffer shared between Normal World (i.e. TFTF) and the
+ * Secure Partition (e.g. Cactus) to pass data associated to secure service
+ * requests.
+ * Note: This address has to match the one used in TF (see ARM_SP_IMAGE_NS_BUF_*
+ * macros).
+ ******************************************************************************/
+#define ARM_SECURE_SERVICE_BUFFER_BASE 0xff600000ull
+#define ARM_SECURE_SERVICE_BUFFER_SIZE 0x10000ull
+
+#endif /* __ARM_DEF_H__ */
diff --git a/include/runtime_services/secure_el0_payloads/secure_partition.h b/include/runtime_services/secure_el0_payloads/secure_partition.h
index 7eea507..f5c2004 100644
--- a/include/runtime_services/secure_el0_payloads/secure_partition.h
+++ b/include/runtime_services/secure_el0_payloads/secure_partition.h
@@ -60,6 +60,20 @@ typedef struct secure_partition_boot_info {
} secure_partition_boot_info_t;
/*
+ * This structure is used to pass data associated to secure service requests.
+ */
+#define SPS_MAX_PAYLOAD_SIZE 32
+typedef struct secure_partition_request_info {
+ uint32_t id;
+ uint64_t data_size;
+ uint8_t data[SPS_MAX_PAYLOAD_SIZE];
+} secure_partition_request_info_t;
+
+secure_partition_request_info_t *create_sps_request(uint32_t id,
+ const void *data,
+ uint64_t data_size);
+
+/*
* Compile time assertions related to the 'secure_partition_boot_info' structure
* to ensure that the assembler and the compiler view of the offsets of the
* structure members is the same.
diff --git a/plat/arm/board/armstrong/include/platform_def.h b/plat/arm/board/armstrong/include/platform_def.h
index e89f00a..2597313 100644
--- a/plat/arm/board/armstrong/include/platform_def.h
+++ b/plat/arm/board/armstrong/include/platform_def.h
@@ -28,8 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../armstrong_def.h"
#include <arch.h>
+#include <arm_def.h>
+#include "../armstrong_def.h"
/*******************************************************************************
* Platform definitions used by common code
diff --git a/plat/arm/board/ashbrook/include/platform_def.h b/plat/arm/board/ashbrook/include/platform_def.h
index f58a0af..3346294 100644
--- a/plat/arm/board/ashbrook/include/platform_def.h
+++ b/plat/arm/board/ashbrook/include/platform_def.h
@@ -28,8 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../ashbrook_def.h"
#include <arch.h>
+#include <arm_def.h>
+#include "../ashbrook_def.h"
/*******************************************************************************
* Platform definitions used by common code
diff --git a/plat/arm/board/fvp/include/platform_def.h b/plat/arm/board/fvp/include/platform_def.h
index 842efd2..e734371 100644
--- a/plat/arm/board/fvp/include/platform_def.h
+++ b/plat/arm/board/fvp/include/platform_def.h
@@ -28,8 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../fvp_def.h"
#include <arch.h>
+#include <arm_def.h>
+#include "../fvp_def.h"
/*******************************************************************************
* Platform definitions used by common code
@@ -219,8 +220,13 @@
* Platform specific page table and MMU setup constants
******************************************************************************/
#define ADDR_SPACE_SIZE (1ull << 32)
+#if IMAGE_TFTF
+#define MAX_XLAT_TABLES 5
+#define MAX_MMAP_REGIONS 16
+#else
#define MAX_XLAT_TABLES 4
#define MAX_MMAP_REGIONS 16
+#endif
/*******************************************************************************
* Used to align variables on the biggest cache line size in the platform.
diff --git a/plat/arm/board/fvp/plat_setup.c b/plat/arm/board/fvp/plat_setup.c
index 14d1305..e497f22 100644
--- a/plat/arm/board/fvp/plat_setup.c
+++ b/plat/arm/board/fvp/plat_setup.c
@@ -60,6 +60,8 @@ static const mmap_region_t mmap[] = {
{ TFTF_BASE + L2_BLOCK_SIZE, TFTF_BASE + L2_BLOCK_SIZE,
(DRAM_BASE + DRAM_SIZE) - (TFTF_BASE + L2_BLOCK_SIZE), MT_MEMORY | MT_RW | MT_NS },
{ 0xFFFFFFFF - DRAM_TZ_SIZE + 1, 0xFFFFFFFF - DRAM_TZ_SIZE + 1, DRAM_TZ_SIZE, MT_MEMORY | MT_RW | MT_NS },
+ { ARM_SECURE_SERVICE_BUFFER_BASE, ARM_SECURE_SERVICE_BUFFER_BASE,
+ ARM_SECURE_SERVICE_BUFFER_SIZE, MT_MEMORY | MT_RW | MT_NS },
{ 0 }
};
#endif /* IMAGE_NS_BL1U */
diff --git a/plat/arm/board/juno/include/platform_def.h b/plat/arm/board/juno/include/platform_def.h
index de69b24..f97d82e 100644
--- a/plat/arm/board/juno/include/platform_def.h
+++ b/plat/arm/board/juno/include/platform_def.h
@@ -28,8 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "../juno_def.h"
#include <arch.h>
+#include <arm_def.h>
+#include "../juno_def.h"
/*******************************************************************************
* Platform definitions used by common code
diff --git a/tests/runtime_services/secure_service/secure_service_helpers.c b/tests/runtime_services/secure_service/secure_service_helpers.c
new file mode 100644
index 0000000..9385d03
--- /dev/null
+++ b/tests/runtime_services/secure_service/secure_service_helpers.c
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <platform.h>
+#include <secure_partition.h>
+#include <string.h>
+
+
+secure_partition_request_info_t *create_sps_request(uint32_t id,
+ const void *data,
+ uint64_t data_size)
+{
+ secure_partition_request_info_t *sps_request
+ = (void *) ARM_SECURE_SERVICE_BUFFER_BASE;
+ sps_request->id = id;
+ sps_request->data_size = data_size;
+ if (data_size != 0)
+ memcpy(sps_request->data, data, data_size);
+ return sps_request;
+}
diff --git a/tests/runtime_services/secure_service/test_secure_service_handle.c b/tests/runtime_services/secure_service/test_secure_service_handle.c
index e452cf2..effa873 100644
--- a/tests/runtime_services/secure_service/test_secure_service_handle.c
+++ b/tests/runtime_services/secure_service/test_secure_service_handle.c
@@ -11,32 +11,29 @@
#include <plat_topology.h>
#include <platform.h>
#include <power_management.h>
+#include <secure_partition.h>
#include <smc.h>
#include <spm_svc.h>
#include <test_helpers.h>
#include <tftf_lib.h>
-/******************************************************************************/
+#define MM_COMMUNICATE_DUMMY_ID 42
static event_t cpu_has_finished_test;
/* Test routine for test_secure_partition_secondary_cores_seq() */
static test_result_t test_secure_partition_secondary_cores_seq_fn(void)
{
+ secure_partition_request_info_t *sps_request
+ = create_sps_request(MM_COMMUNICATE_DUMMY_ID, NULL, 0);
+
INFO("Sending MM_COMMUNICATE_AARCH64 from CPU %u\n",
platform_get_core_pos(read_mpidr_el1() & MPID_MASK));
smc_args mm_communicate_smc = {
MM_COMMUNICATE_AARCH64,
0,
-
- /*
- * TODO: Use a dummy non-zero value for comm_buffer_address
- * until we have a defined interface to specify the
- * communication buffer address used by TFTF and Cactus.
- */
- 0x100,
-
+ (u_register_t) sps_request,
0
};
@@ -113,18 +110,13 @@ static test_result_t test_secure_partition_secondary_cores_sim_fn(void)
{
u_register_t cpu_mpid = read_mpidr_el1() & MPID_MASK;
unsigned int core_pos = platform_get_core_pos(cpu_mpid);
+ secure_partition_request_info_t *sps_request
+ = create_sps_request(MM_COMMUNICATE_DUMMY_ID, NULL, 0);
smc_args mm_communicate_smc = {
MM_COMMUNICATE_AARCH64,
0,
-
- /*
- * TODO: Use a dummy non-zero value for comm_buffer_address
- * until we have a defined interface to specify the
- * communication buffer address used by TFTF and Cactus.
- */
- 0x100,
-
+ (u_register_t) sps_request,
0
};
diff --git a/tests/tests.mk b/tests/tests.mk
index 36d5c47..a20bdfd 100644
--- a/tests/tests.mk
+++ b/tests/tests.mk
@@ -11,6 +11,7 @@ TESTS_SOURCES := tests/framework_validation_tests/test_timer_framework.c \
tests/framework_validation_tests/test_validation_sgi.c \
tests/performance_tests/smc_latencies.c \
tests/runtime_services/secure_service/test_secure_service_handle.c \
+ tests/runtime_services/secure_service/secure_service_helpers.c \
tests/runtime_services/sip_service/test_exec_state_switch.c \
tests/runtime_services/sip_service/test_exec_state_switch_asm.S \
tests/runtime_services/standard_service/pmf/api_tests/runtime_instr/test_pmf_rt_instr.c \