aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile23
-rw-r--r--include/common/aarch64/asm_macros.S11
-rw-r--r--include/common/test_helpers.h9
-rw-r--r--include/lib/extensions/sve.h13
-rw-r--r--include/runtime_services/cactus_test_cmds.h50
-rw-r--r--include/runtime_services/ffa_endpoints.h10
-rw-r--r--include/runtime_services/ffa_helpers.h58
-rw-r--r--include/runtime_services/ffa_svc.h6
-rw-r--r--include/runtime_services/spm_common.h29
-rw-r--r--lib/aarch64/exception_stubs.S39
-rw-r--r--plat/arm/fvp/platform.mk19
-rw-r--r--plat/arm/tc0/include/platform_def.h7
-rw-r--r--plat/arm/tc0/platform.mk1
-rw-r--r--plat/arm/tc0/tests_to_skip.txt4
-rw-r--r--spm/cactus/cactus.h7
-rw-r--r--spm/cactus/cactus.mk7
-rw-r--r--spm/cactus/cactus_interrupt.c2
-rw-r--r--spm/cactus/cactus_main.c10
-rw-r--r--spm/cactus/cactus_tests/cactus_test_direct_messaging.c26
-rw-r--r--spm/cactus/cactus_tests/cactus_test_ffa.c151
-rw-r--r--spm/cactus/cactus_tests/cactus_test_memory_sharing.c10
-rw-r--r--spm/cactus/cactus_tests/cactus_tests_smmuv3.c4
-rw-r--r--spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts4
-rw-r--r--spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts4
-rw-r--r--spm/cactus/plat/arm/fvp/fdts/cactus.dts2
-rw-r--r--spm/cactus/plat/arm/fvp/include/cactus_platform_def.h4
-rw-r--r--spm/cactus/plat/arm/tc0/fdts/cactus.dts2
-rw-r--r--spm/cactus/plat/arm/tc0/include/cactus_platform_def.h13
-rw-r--r--spm/cactus_mm/cactus_mm.mk3
-rw-r--r--spm/common/sp_debug.c (renamed from spm/cactus/cactus_debug.c)22
-rw-r--r--spm/common/sp_debug.h13
-rw-r--r--spm/common/sp_helpers.h2
-rw-r--r--spm/ivy/app/aarch64/ivy_entrypoint.S (renamed from spm/ivy/aarch64/ivy_entrypoint.S)2
-rw-r--r--spm/ivy/app/ivy.h46
-rw-r--r--spm/ivy/app/ivy_def.h (renamed from spm/ivy/ivy_def.h)4
-rw-r--r--spm/ivy/app/ivy_main.c50
-rw-r--r--spm/ivy/app/plat/arm/fvp/fdts/ivy.dts32
-rw-r--r--spm/ivy/app/plat/arm/fvp/include/ivy_platform_def.h20
-rw-r--r--spm/ivy/app/plat/arm/fvp/platform.mk15
-rw-r--r--spm/ivy/app/plat/arm/tc0/fdts/ivy.dts35
-rw-r--r--spm/ivy/app/plat/arm/tc0/include/ivy_platform_def.h20
-rw-r--r--spm/ivy/app/plat/arm/tc0/platform.mk15
-rw-r--r--spm/ivy/ivy.dts95
-rw-r--r--spm/ivy/ivy.h29
-rw-r--r--spm/ivy/ivy.ld.S69
-rw-r--r--spm/ivy/ivy.mk66
-rw-r--r--spm/ivy/ivy_main.c135
-rw-r--r--spm/ivy/shim/aarch64/spm_shim_entrypoint.S83
-rw-r--r--spm/ivy/shim/aarch64/spm_shim_exceptions.S96
-rw-r--r--spm/ivy/shim/shim_main.c105
-rw-r--r--tftf/framework/aarch64/exceptions.S34
-rw-r--r--tftf/tests/common/test_helpers.c2
-rw-r--r--tftf/tests/extensions/sve/test_sve.c7
-rw-r--r--tftf/tests/misc_tests/inject_serror.S2
-rw-r--r--tftf/tests/runtime_services/secure_service/ffa_helpers.c44
-rw-r--r--tftf/tests/runtime_services/secure_service/spm_common.c219
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c10
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_features.c47
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c4
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c67
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c311
-rw-r--r--tftf/tests/runtime_services/secure_service/test_ffa_version.c88
-rw-r--r--tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c62
-rw-r--r--tftf/tests/tests-spm.mk4
-rw-r--r--tftf/tests/tests-spm.xml42
-rwxr-xr-xtools/generate_json/generate_json.sh8
66 files changed, 1603 insertions, 830 deletions
diff --git a/Makefile b/Makefile
index 8eba9403..3c1cf533 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -108,16 +108,16 @@ include tftf/tests/tests.mk
include fwu/ns_bl1u/ns_bl1u.mk
include fwu/ns_bl2u/ns_bl2u.mk
-# Only platform fvp supports cactus_mm, ivy, quark
+# Only platform fvp supports cactus_mm, quark
ifeq (${ARCH}-${PLAT},aarch64-fvp)
include spm/cactus_mm/cactus_mm.mk
-include spm/ivy/ivy.mk
include spm/quark/quark.mk
endif
-# cactus is supported on platforms: fvp, tc0
+# cactus and ivy are supported on platforms: fvp, tc0
ifeq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc0))
include spm/cactus/cactus.mk
+include spm/ivy/ivy.mk
endif
################################################################################
@@ -289,9 +289,9 @@ CACTUS_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
IVY_SOURCES += ${LIBC_SRCS}
IVY_INCLUDES += ${PLAT_INCLUDES}
-IVY_CFLAGS += ${COMMON_CFLAGS}
+IVY_CFLAGS += ${COMMON_CFLAGS} -fpie
IVY_ASFLAGS += ${COMMON_ASFLAGS}
-IVY_LDFLAGS += ${COMMON_LDFLAGS}
+IVY_LDFLAGS += ${COMMON_LDFLAGS} $(PIE_LDFLAGS)
QUARK_SOURCES += ${LIBC_SRCS}
QUARK_INCLUDES += ${PLAT_INCLUDES}
@@ -367,11 +367,6 @@ cactus_mm:
@echo "ERROR: $@ is supported only on AArch64 FVP."
@exit 1
-.PHONY: ivy
-ivy:
- @echo "ERROR: $@ is supported only on AArch64 FVP."
- @exit 1
-
.PHONY: quark
quark:
@echo "ERROR: $@ is supported only on AArch64 FVP."
@@ -383,6 +378,11 @@ ifneq (${ARCH}-${PLAT},$(filter ${ARCH}-${PLAT},aarch64-fvp aarch64-tc0))
cactus:
@echo "ERROR: $@ is supported only on AArch64 FVP or TC0."
@exit 1
+
+.PHONY: ivy
+ivy:
+ @echo "ERROR: $@ is supported only on AArch64 FVP or TC0."
+ @exit 1
endif
MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@
@@ -524,6 +524,7 @@ endif
ifeq (${ARCH}-${PLAT},aarch64-tc0)
$(eval $(call MAKE_IMG,cactus))
+ $(eval $(call MAKE_IMG,ivy))
endif
# The EL3 test payload is only supported in AArch64. It has an independent build
diff --git a/include/common/aarch64/asm_macros.S b/include/common/aarch64/asm_macros.S
index d829133f..8a69c38d 100644
--- a/include/common/aarch64/asm_macros.S
+++ b/include/common/aarch64/asm_macros.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -79,6 +79,15 @@
.endm
/*
+ * Create a vector entry that just spins making the exception unrecoverable.
+ */
+ .macro vector_entry_spin name
+ vector_entry \name
+ b \name
+ end_vector_entry \name
+ .endm
+
+ /*
* This macro calculates the base address of an MP stack using the
* platform_get_core_pos() index, the name of the stack storage and
* the size of each stack
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index 3ee2b531..9c5f6e4d 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -107,6 +107,14 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
} \
} while (0)
+#define SKIP_TEST_IF_SVE_NOT_SUPPORTED() \
+ do { \
+ if (!is_armv8_2_sve_present()) { \
+ tftf_testcase_printf("SVE not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (0)
+
#define SKIP_TEST_IF_ECV_NOT_SELF_SYNC() \
do { \
if (get_armv8_6_ecv_support() != \
@@ -228,6 +236,7 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
#define CHECK_SPMC_TESTING_SETUP(ffa_major, ffa_minor, expected_uuids) \
do { \
+ SKIP_TEST_IF_AARCH32(); \
const size_t expected_uuids_size = \
sizeof(expected_uuids) / sizeof(struct ffa_uuid); \
test_result_t ret = check_spmc_testing_set_up( \
diff --git a/include/lib/extensions/sve.h b/include/lib/extensions/sve.h
new file mode 100644
index 00000000..278dcf34
--- /dev/null
+++ b/include/lib/extensions/sve.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SVE_H
+#define SVE_H
+
+#define fill_sve_helper(num) "ldr z"#num", [%0, #"#num", MUL VL];"
+#define read_sve_helper(num) "str z"#num", [%0, #"#num", MUL VL];"
+
+#endif /* SVE_H */ \ No newline at end of file
diff --git a/include/runtime_services/cactus_test_cmds.h b/include/runtime_services/cactus_test_cmds.h
index 483a7f49..09709687 100644
--- a/include/runtime_services/cactus_test_cmds.h
+++ b/include/runtime_services/cactus_test_cmds.h
@@ -37,7 +37,7 @@ static inline uint64_t cactus_get_cmd(smc_ret_values ret)
* messages interfaces.
*/
static inline smc_ret_values cactus_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint64_t cmd, uint64_t val0,
+ ffa_id_t source, ffa_id_t dest, uint64_t cmd, uint64_t val0,
uint64_t val1, uint64_t val2, uint64_t val3)
{
return ffa_msg_send_direct_req64(source, dest, cmd, val0, val1, val2,
@@ -50,7 +50,7 @@ static inline smc_ret_values cactus_send_cmd(
* a need to propagate more than one value in the response of a command.
*/
static inline smc_ret_values cactus_send_response(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t resp, uint32_t val0,
+ ffa_id_t source, ffa_id_t dest, uint32_t resp, uint32_t val0,
uint64_t val1, uint64_t val2, uint64_t val3)
{
return ffa_msg_send_direct_resp64(source, dest, resp, val0, val1,
@@ -61,7 +61,7 @@ static inline smc_ret_values cactus_send_response(
* For responses of one value only.
*/
static inline smc_ret_values cactus_response(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t response)
+ ffa_id_t source, ffa_id_t dest, uint32_t response)
{
return ffa_msg_send_direct_resp64(source, dest, response, 0, 0, 0, 0);
}
@@ -78,7 +78,7 @@ static inline uint32_t cactus_get_response(smc_ret_values ret)
* specific test.
*/
static inline smc_ret_values cactus_success_resp(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint64_t value)
+ ffa_id_t source, ffa_id_t dest, uint64_t value)
{
return cactus_send_response(source, dest, CACTUS_SUCCESS, value,
0, 0, 0);
@@ -90,7 +90,7 @@ static inline smc_ret_values cactus_success_resp(
* in the error code list.
*/
static inline smc_ret_values cactus_error_resp(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t error_code)
+ ffa_id_t source, ffa_id_t dest, uint32_t error_code)
{
return cactus_send_response(source, dest, CACTUS_ERROR, error_code,
0, 0, 0);
@@ -110,7 +110,7 @@ static inline uint32_t cactus_error_code(smc_ret_values ret)
#define CACTUS_ECHO_CMD U(0x6563686f)
static inline smc_ret_values cactus_echo_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint64_t echo_val)
+ ffa_id_t source, ffa_id_t dest, uint64_t echo_val)
{
return cactus_send_cmd(source, dest, CACTUS_ECHO_CMD, echo_val, 0, 0,
0);
@@ -131,16 +131,16 @@ static inline uint64_t cactus_echo_get_val(smc_ret_values ret)
#define CACTUS_REQ_ECHO_CMD (CACTUS_ECHO_CMD + 1)
static inline smc_ret_values cactus_req_echo_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, ffa_vm_id_t echo_dest,
+ ffa_id_t source, ffa_id_t dest, ffa_id_t echo_dest,
uint64_t echo_val)
{
return cactus_send_cmd(source, dest, CACTUS_REQ_ECHO_CMD, echo_val,
echo_dest, 0, 0);
}
-static inline ffa_vm_id_t cactus_req_echo_get_echo_dest(smc_ret_values ret)
+static inline ffa_id_t cactus_req_echo_get_echo_dest(smc_ret_values ret)
{
- return (ffa_vm_id_t)ret.ret5;
+ return (ffa_id_t)ret.ret5;
}
/**
@@ -155,15 +155,15 @@ static inline ffa_vm_id_t cactus_req_echo_get_echo_dest(smc_ret_values ret)
#define CACTUS_DEADLOCK_CMD U(0x64656164)
static inline smc_ret_values cactus_deadlock_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, ffa_vm_id_t next_dest)
+ ffa_id_t source, ffa_id_t dest, ffa_id_t next_dest)
{
return cactus_send_cmd(source, dest, CACTUS_DEADLOCK_CMD, next_dest, 0,
0, 0);
}
-static inline ffa_vm_id_t cactus_deadlock_get_next_dest(smc_ret_values ret)
+static inline ffa_id_t cactus_deadlock_get_next_dest(smc_ret_values ret)
{
- return (ffa_vm_id_t)ret.ret4;
+ return (ffa_id_t)ret.ret4;
}
/**
@@ -173,17 +173,17 @@ static inline ffa_vm_id_t cactus_deadlock_get_next_dest(smc_ret_values ret)
#define CACTUS_REQ_DEADLOCK_CMD (CACTUS_DEADLOCK_CMD + 1)
static inline smc_ret_values cactus_req_deadlock_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, ffa_vm_id_t next_dest1,
- ffa_vm_id_t next_dest2)
+ ffa_id_t source, ffa_id_t dest, ffa_id_t next_dest1,
+ ffa_id_t next_dest2)
{
return cactus_send_cmd(source, dest, CACTUS_REQ_DEADLOCK_CMD,
next_dest1, next_dest2, 0, 0);
}
/* To get next_dest1 use CACTUS_DEADLOCK_GET_NEXT_DEST */
-static inline ffa_vm_id_t cactus_deadlock_get_next_dest2(smc_ret_values ret)
+static inline ffa_id_t cactus_deadlock_get_next_dest2(smc_ret_values ret)
{
- return (ffa_vm_id_t)ret.ret5;
+ return (ffa_id_t)ret.ret5;
}
/**
@@ -195,7 +195,7 @@ static inline ffa_vm_id_t cactus_deadlock_get_next_dest2(smc_ret_values ret)
#define CACTUS_MEM_SEND_CMD U(0x6d656d)
static inline smc_ret_values cactus_mem_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t mem_func,
+ ffa_id_t source, ffa_id_t dest, uint32_t mem_func,
ffa_memory_handle_t handle)
{
return cactus_send_cmd(source, dest, CACTUS_MEM_SEND_CMD, mem_func,
@@ -217,8 +217,8 @@ static inline ffa_memory_handle_t cactus_mem_send_get_handle(smc_ret_values ret)
#define CACTUS_REQ_MEM_SEND_CMD U(0x6d656d6f7279)
static inline smc_ret_values cactus_req_mem_send_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t mem_func,
- ffa_vm_id_t receiver)
+ ffa_id_t source, ffa_id_t dest, uint32_t mem_func,
+ ffa_id_t receiver)
{
return cactus_send_cmd(source, dest, CACTUS_REQ_MEM_SEND_CMD, mem_func,
receiver, 0, 0);
@@ -229,9 +229,9 @@ static inline uint32_t cactus_req_mem_send_get_mem_func(smc_ret_values ret)
return (uint32_t)ret.ret4;
}
-static inline ffa_vm_id_t cactus_req_mem_send_get_receiver(smc_ret_values ret)
+static inline ffa_id_t cactus_req_mem_send_get_receiver(smc_ret_values ret)
{
- return (ffa_vm_id_t)ret.ret5;
+ return (ffa_id_t)ret.ret5;
}
/**
@@ -244,7 +244,7 @@ static inline ffa_vm_id_t cactus_req_mem_send_get_receiver(smc_ret_values ret)
#define CACTUS_REQ_SIMD_FILL_CMD U(0x53494d44)
static inline smc_ret_values cactus_req_simd_fill_send_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest)
+ ffa_id_t source, ffa_id_t dest)
{
return cactus_send_cmd(source, dest, CACTUS_REQ_SIMD_FILL_CMD, 0, 0, 0,
0);
@@ -258,7 +258,7 @@ static inline smc_ret_values cactus_req_simd_fill_send_cmd(
#define CACTUS_SLEEP_CMD U(0x736c656570)
static inline smc_ret_values cactus_sleep_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t sleep_time)
+ ffa_id_t source, ffa_id_t dest, uint32_t sleep_time)
{
return cactus_send_cmd(source, dest, CACTUS_SLEEP_CMD, sleep_time, 0, 0,
0);
@@ -277,7 +277,7 @@ static inline uint32_t cactus_get_sleep_time(smc_ret_values ret)
#define CACTUS_INTERRUPT_CMD U(0x696e7472)
static inline smc_ret_values cactus_interrupt_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest, uint32_t interrupt_id,
+ ffa_id_t source, ffa_id_t dest, uint32_t interrupt_id,
bool enable, uint32_t pin)
{
return cactus_send_cmd(source, dest, CACTUS_INTERRUPT_CMD, interrupt_id,
@@ -307,7 +307,7 @@ static inline enum interrupt_pin cactus_get_interrupt_pin(smc_ret_values ret)
#define CACTUS_DMA_SMMUv3_CMD (0x534d4d55)
static inline smc_ret_values cactus_send_dma_cmd(
- ffa_vm_id_t source, ffa_vm_id_t dest)
+ ffa_id_t source, ffa_id_t dest)
{
return cactus_send_cmd(source, dest, CACTUS_DMA_SMMUv3_CMD, 0, 0, 0,
0);
diff --git a/include/runtime_services/ffa_endpoints.h b/include/runtime_services/ffa_endpoints.h
index 7a6cd4f7..06b5abc1 100644
--- a/include/runtime_services/ffa_endpoints.h
+++ b/include/runtime_services/ffa_endpoints.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,11 +7,19 @@
#ifndef FFA_ENDPOINTS_H
#define FFA_ENDPOINTS_H
+#include <platform_def.h>
+
/* UUID of cactus SPs as defined in the respective manifests. */
#define PRIMARY_UUID {0xb4b5671e, 0x4a904fe1, 0xb81ffb13, 0xdae1dacb}
#define SECONDARY_UUID {0xd1582309, 0xf02347b9, 0x827c4464, 0xf5578fc8}
#define TERTIARY_UUID {0x79b55c73, 0x1d8c44b9, 0x859361e1, 0x770ad8d2}
+/* vcpu_count of cactus SPs. */
+#define PRIMARY_EXEC_CTX_COUNT PLATFORM_CORE_COUNT
+#define SECONDARY_EXEC_CTX_COUNT PLATFORM_CORE_COUNT
+#define TERTIARY_EXEC_CTX_COUNT (1)
+#define IVY_EXEC_CTX_COUNT (1)
+
/* UUID of OPTEE SP as defined in the respective manifest. */
#define OPTEE_UUID {0x486178e0, 0xe7f811e3, 0xbc5e0002, 0xa5d5c51b}
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index 592327af..a17f115b 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -14,7 +14,7 @@
/* This error code must be different to the ones used by FFA */
#define FFA_TFTF_ERROR -42
-typedef unsigned short ffa_vm_id_t;
+typedef unsigned short ffa_id_t;
typedef unsigned short ffa_vm_count_t;
typedef unsigned short ffa_vcpu_count_t;
typedef uint64_t ffa_memory_handle_t;
@@ -29,9 +29,18 @@ struct ffa_uuid {
#include <stdint.h>
+/** Partition property: partition supports receipt of direct requests. */
+#define FFA_PARTITION_DIRECT_REQ_RECV 0x1
+
+/** Partition property: partition can send direct requests. */
+#define FFA_PARTITION_DIRECT_REQ_SEND 0x2
+
+/** Partition property: partition can send and receive indirect messages. */
+#define FFA_PARTITION_INDIRECT_MSG 0x4
+
struct ffa_partition_info {
/** The ID of the VM the information is about */
- ffa_vm_id_t id;
+ ffa_id_t id;
/** The number of execution contexts implemented by the partition */
uint16_t exec_context;
/** The Partition's properties, e.g. supported messaging methods */
@@ -46,6 +55,10 @@ static inline int32_t ffa_error_code(smc_ret_values val) {
return (int32_t) val.ret2;
}
+static inline ffa_id_t ffa_endpoint_id(smc_ret_values val) {
+ return (ffa_id_t) val.ret2 & 0xffff;
+}
+
enum ffa_data_access {
FFA_DATA_ACCESS_NOT_SPECIFIED,
FFA_DATA_ACCESS_RO,
@@ -196,7 +209,7 @@ struct ffa_composite_memory_region {
*/
struct ffa_memory_region_attributes {
/** The ID of the VM to which the memory is being given or shared. */
- ffa_vm_id_t receiver;
+ ffa_id_t receiver;
/**
* The permissions with which the memory region should be mapped in the
* receiver's page table.
@@ -264,7 +277,7 @@ struct ffa_memory_region {
* The ID of the VM which originally sent the memory region, i.e. the
* owner.
*/
- ffa_vm_id_t sender;
+ ffa_id_t sender;
ffa_memory_attributes_t attributes;
/** Reserved field, must be 0. */
uint8_t reserved_0;
@@ -300,7 +313,7 @@ struct ffa_mem_relinquish {
ffa_memory_handle_t handle;
ffa_memory_region_flags_t flags;
uint32_t endpoint_count;
- ffa_vm_id_t endpoints[];
+ ffa_id_t endpoints[];
};
static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t h1, uint32_t h2)
@@ -335,18 +348,18 @@ ffa_memory_region_get_composite(struct ffa_memory_region *memory_region,
static inline uint32_t ffa_mem_relinquish_init(
struct ffa_mem_relinquish *relinquish_request,
ffa_memory_handle_t handle, ffa_memory_region_flags_t flags,
- ffa_vm_id_t sender)
+ ffa_id_t sender)
{
relinquish_request->handle = handle;
relinquish_request->flags = flags;
relinquish_request->endpoint_count = 1;
relinquish_request->endpoints[0] = sender;
- return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_vm_id_t);
+ return sizeof(struct ffa_mem_relinquish) + sizeof(ffa_id_t);
}
uint32_t ffa_memory_retrieve_request_init(
struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
- ffa_vm_id_t sender, ffa_vm_id_t receiver, uint32_t tag,
+ ffa_id_t sender, ffa_id_t receiver, uint32_t tag,
ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
enum ffa_instruction_access instruction_access,
enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
@@ -354,7 +367,7 @@ uint32_t ffa_memory_retrieve_request_init(
uint32_t ffa_memory_region_init(
struct ffa_memory_region *memory_region, size_t memory_region_max_size,
- ffa_vm_id_t sender, ffa_vm_id_t receiver,
+ ffa_id_t sender, ffa_id_t receiver,
const struct ffa_memory_region_constituent constituents[],
uint32_t constituent_count, uint32_t tag,
ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
@@ -363,41 +376,42 @@ uint32_t ffa_memory_region_init(
enum ffa_memory_shareability shareability, uint32_t *total_length,
uint32_t *fragment_length);
-static inline ffa_vm_id_t ffa_dir_msg_dest(smc_ret_values val) {
- return (ffa_vm_id_t)val.ret1 & U(0xFFFF);
+static inline ffa_id_t ffa_dir_msg_dest(smc_ret_values val) {
+ return (ffa_id_t)val.ret1 & U(0xFFFF);
}
-static inline ffa_vm_id_t ffa_dir_msg_source(smc_ret_values val) {
- return (ffa_vm_id_t)(val.ret1 >> 16U);
+static inline ffa_id_t ffa_dir_msg_source(smc_ret_values val) {
+ return (ffa_id_t)(val.ret1 >> 16U);
}
-smc_ret_values ffa_msg_send_direct_req64(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint64_t arg0,
+smc_ret_values ffa_msg_send_direct_req64(ffa_id_t source_id,
+ ffa_id_t dest_id, uint64_t arg0,
uint64_t arg1, uint64_t arg2,
uint64_t arg3, uint64_t arg4);
-smc_ret_values ffa_msg_send_direct_req32(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint32_t arg0,
+smc_ret_values ffa_msg_send_direct_req32(ffa_id_t source_id,
+ ffa_id_t dest_id, uint32_t arg0,
uint32_t arg1, uint32_t arg2,
uint32_t arg3, uint32_t arg4);
-smc_ret_values ffa_msg_send_direct_resp64(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint64_t arg0,
+smc_ret_values ffa_msg_send_direct_resp64(ffa_id_t source_id,
+ ffa_id_t dest_id, uint64_t arg0,
uint64_t arg1, uint64_t arg2,
uint64_t arg3, uint64_t arg4);
-smc_ret_values ffa_msg_send_direct_resp32(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint32_t arg0,
+smc_ret_values ffa_msg_send_direct_resp32(ffa_id_t source_id,
+ ffa_id_t dest_id, uint32_t arg0,
uint32_t arg1, uint32_t arg2,
uint32_t arg3, uint32_t arg4);
smc_ret_values ffa_run(uint32_t dest_id, uint32_t vcpu_id);
smc_ret_values ffa_version(uint32_t input_version);
smc_ret_values ffa_id_get(void);
+smc_ret_values ffa_spm_id_get(void);
smc_ret_values ffa_msg_wait(void);
smc_ret_values ffa_error(int32_t error_code);
smc_ret_values ffa_features(uint32_t feature);
-smc_ret_values ffa_partition_info_get(const uint32_t uuid[4]);
+smc_ret_values ffa_partition_info_get(const struct ffa_uuid uuid);
smc_ret_values ffa_rx_release(void);
smc_ret_values ffa_rxtx_map(uintptr_t send, uintptr_t recv, uint32_t pages);
smc_ret_values ffa_mem_donate(uint32_t descriptor_length,
diff --git a/include/runtime_services/ffa_svc.h b/include/runtime_services/ffa_svc.h
index c9702658..3a474e70 100644
--- a/include/runtime_services/ffa_svc.h
+++ b/include/runtime_services/ffa_svc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -22,7 +22,7 @@
/* The macros below are used to identify FFA calls from the SMC function ID */
#define FFA_FNUM_MIN_VALUE U(0x60)
-#define FFA_FNUM_MAX_VALUE U(0x84)
+#define FFA_FNUM_MAX_VALUE U(0x85)
#define is_ffa_fid(fid) __extension__ ({ \
__typeof__(fid) _fid = (fid); \
((GET_SMC_NUM(_fid) >= FFA_FNUM_MIN_VALUE) && \
@@ -85,6 +85,7 @@
#define FFA_FNUM_MEM_RELINQUISH U(0x76)
#define FFA_FNUM_MEM_RECLAIM U(0x77)
#define FFA_FNUM_SECONDARY_EP_REGISTER U(0x84)
+#define FFA_FNUM_SPM_ID_GET U(0x85)
/* FFA SMC32 FIDs */
#define FFA_ERROR FFA_FID(SMC_32, FFA_FNUM_ERROR)
@@ -114,6 +115,7 @@
#define FFA_MEM_RETRIEVE_RESP FFA_FID(SMC_32, FFA_FNUM_MEM_RETRIEVE_RESP)
#define FFA_MEM_RELINQUISH FFA_FID(SMC_32, FFA_FNUM_MEM_RELINQUISH)
#define FFA_MEM_RECLAIM FFA_FID(SMC_32, FFA_FNUM_MEM_RECLAIM)
+#define FFA_SPM_ID_GET FFA_FID(SMC_32, FFA_FNUM_SPM_ID_GET)
/* FFA SMC64 FIDs */
#define FFA_SUCCESS_SMC64 FFA_FID(SMC_64, FFA_FNUM_SUCCESS)
diff --git a/include/runtime_services/spm_common.h b/include/runtime_services/spm_common.h
index 50159ecb..ffe666ff 100644
--- a/include/runtime_services/spm_common.h
+++ b/include/runtime_services/spm_common.h
@@ -13,6 +13,8 @@
/* Hypervisor ID at physical FFA instance */
#define HYP_ID (0)
+/* SPMC ID */
+#define SPMC_ID U(0x8000)
/* ID for the first Secure Partition. */
#define SPM_VM_ID_FIRST SP_ID(1)
@@ -42,6 +44,7 @@ struct ffa_features_test {
const char *test_name;
unsigned int feature;
unsigned int expected_ret;
+ unsigned int version_added;
};
struct mailbox_buffers {
@@ -80,22 +83,29 @@ bool is_expected_ffa_return(smc_ret_values ret, uint32_t func_id);
/*
* Vector length:
* SIMD: 128 bits = 16 bytes
+ * SVE: 512 bits = 64 bytes
*/
#define SIMD_VECTOR_LEN_BYTES 16
+#define SVE_VECTOR_LEN_BYTES 64
+
#define SIMD_NUM_VECTORS 32
+#define SVE_NUM_VECTORS 32
typedef uint8_t simd_vector_t[SIMD_VECTOR_LEN_BYTES];
+typedef uint8_t sve_vector_t[SVE_VECTOR_LEN_BYTES];
/*
- * Fills SIMD registers with the content of the container v.
- * Number of vectors is assumed to be SIMD_NUM_VECTORS.
+ * Fills SIMD/SVE registers with the content of the container v.
+ * Number of vectors is assumed to be SIMD/SVE_NUM_VECTORS.
*/
void fill_simd_vector_regs(const simd_vector_t v[SIMD_NUM_VECTORS]);
+void fill_sve_vector_regs(const sve_vector_t v[SVE_NUM_VECTORS]);
/*
- * Reads contents of SIMD registers into the provided container v.
- * Number of vectors is assumed to be SIMD_NUM_VECTORS.
+ * Reads contents of SIMD/SVE registers into the provided container v.
+ * Number of vectors is assumed to be SIMD/SVE_NUM_VECTORS.
*/
void read_simd_vector_regs(simd_vector_t v[SIMD_NUM_VECTORS]);
+void read_sve_vector_regs(sve_vector_t v[SVE_NUM_VECTORS]);
bool check_spmc_execution_level(void);
@@ -107,7 +117,7 @@ unsigned int get_ffa_feature_test_target(const struct ffa_features_test **test_t
*/
bool memory_retrieve(struct mailbox_buffers *mb,
struct ffa_memory_region **retrieved, uint64_t handle,
- ffa_vm_id_t sender, ffa_vm_id_t receiver,
+ ffa_id_t sender, ffa_id_t receiver,
uint32_t mem_func);
/**
@@ -115,7 +125,7 @@ bool memory_retrieve(struct mailbox_buffers *mb,
* after it being done with the memory shared, identified by the 'handle'.
*/
bool memory_relinquish(struct ffa_mem_relinquish *m, uint64_t handle,
- ffa_vm_id_t id);
+ ffa_id_t id);
ffa_memory_handle_t memory_send(
struct ffa_memory_region *memory_region, uint32_t mem_func,
@@ -123,8 +133,13 @@ ffa_memory_handle_t memory_send(
ffa_memory_handle_t memory_init_and_send(
struct ffa_memory_region *memory_region, size_t memory_region_max_size,
- ffa_vm_id_t sender, ffa_vm_id_t receiver,
+ ffa_id_t sender, ffa_id_t receiver,
const struct ffa_memory_region_constituent* constituents,
uint32_t constituents_count, uint32_t mem_func);
+bool ffa_partition_info_helper(struct mailbox_buffers *mb,
+ const struct ffa_uuid uuid,
+ const struct ffa_partition_info *expected,
+ const uint16_t expected_size);
+
#endif /* SPM_COMMON_H */
diff --git a/lib/aarch64/exception_stubs.S b/lib/aarch64/exception_stubs.S
index d418451a..b186e82b 100644
--- a/lib/aarch64/exception_stubs.S
+++ b/lib/aarch64/exception_stubs.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -12,26 +12,21 @@
* Simplistic exceptions vector table.
* All entries spin, which means all types of exceptions are unrecoverable.
*/
- .macro vector_entry_spin name
- vector_entry \name
- b \name
- end_vector_entry \name
- .endm
vector_base exception_stubs
-vector_entry_spin SynchronousExceptionSP0
-vector_entry_spin IrqSP0
-vector_entry_spin FiqSP0
-vector_entry_spin SErrorSP0
-vector_entry_spin SynchronousExceptionSPx
-vector_entry_spin IrqSPx
-vector_entry_spin FiqSPx
-vector_entry_spin SErrorSPx
-vector_entry_spin SynchronousExceptionA64
-vector_entry_spin IrqA64
-vector_entry_spin FiqA64
-vector_entry_spin SErrorA64
-vector_entry_spin SynchronousExceptionA32
-vector_entry_spin IrqA32
-vector_entry_spin FiqA32
-vector_entry_spin SErrorA32
+vector_entry_spin sync_exception_sp_el0
+vector_entry_spin irq_sp_el0
+vector_entry_spin fiq_sp_el0
+vector_entry_spin serror_sp_el0
+vector_entry_spin sync_exception_sp_elx
+vector_entry_spin irq_sp_elx
+vector_entry_spin fiq_sp_elx
+vector_entry_spin serror_sp_elx
+vector_entry_spin sync_exception_aarch64
+vector_entry_spin irq_aarch64
+vector_entry_spin fiq_aarch64
+vector_entry_spin serror_aarch64
+vector_entry_spin sync_exception_aarch32
+vector_entry_spin irq_aarch32
+vector_entry_spin fiq_aarch32
+vector_entry_spin serror_aarch32
diff --git a/plat/arm/fvp/platform.mk b/plat/arm/fvp/platform.mk
index 42779c72..c9bbe6e5 100644
--- a/plat/arm/fvp/platform.mk
+++ b/plat/arm/fvp/platform.mk
@@ -56,9 +56,17 @@ ifneq ($(FVP_MAX_CPUS_PER_CLUSTER),$(filter $(FVP_MAX_CPUS_PER_CLUSTER),$(CPU)))
endif
# Pass FVP topology definitions to the build system
-$(eval $(call add_define,TFTF_DEFINES,FVP_CLUSTER_COUNT))
-$(eval $(call add_define,TFTF_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
-$(eval $(call add_define,TFTF_DEFINES,FVP_MAX_PE_PER_CPU))
+$(eval $(call add_define,CACTUS_DEFINES,FVP_CLUSTER_COUNT))
+$(eval $(call add_define,CACTUS_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
+$(eval $(call add_define,CACTUS_DEFINES,FVP_MAX_PE_PER_CPU))
+
+$(eval $(call add_define,CACTUS_MM_DEFINES,FVP_CLUSTER_COUNT))
+$(eval $(call add_define,CACTUS_MM_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
+$(eval $(call add_define,CACTUS_MM_DEFINES,FVP_MAX_PE_PER_CPU))
+
+$(eval $(call add_define,IVY_DEFINES,FVP_CLUSTER_COUNT))
+$(eval $(call add_define,IVY_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
+$(eval $(call add_define,IVY_DEFINES,FVP_MAX_PE_PER_CPU))
$(eval $(call add_define,NS_BL1U_DEFINES,FVP_CLUSTER_COUNT))
$(eval $(call add_define,NS_BL1U_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
@@ -68,6 +76,10 @@ $(eval $(call add_define,NS_BL2U_DEFINES,FVP_CLUSTER_COUNT))
$(eval $(call add_define,NS_BL2U_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
$(eval $(call add_define,NS_BL2U_DEFINES,FVP_MAX_PE_PER_CPU))
+$(eval $(call add_define,TFTF_DEFINES,FVP_CLUSTER_COUNT))
+$(eval $(call add_define,TFTF_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
+$(eval $(call add_define,TFTF_DEFINES,FVP_MAX_PE_PER_CPU))
+
PLAT_INCLUDES += -Iplat/arm/fvp/include/
PLAT_SOURCES := drivers/arm/gic/arm_gic_v2v3.c \
@@ -83,6 +95,7 @@ PLAT_SOURCES := drivers/arm/gic/arm_gic_v2v3.c \
plat/arm/fvp/plat_setup.c
CACTUS_SOURCES += plat/arm/fvp/${ARCH}/plat_helpers.S
+IVY_SOURCES += plat/arm/fvp/${ARCH}/plat_helpers.S
# Firmware update is implemented on FVP.
FIRMWARE_UPDATE := 1
diff --git a/plat/arm/tc0/include/platform_def.h b/plat/arm/tc0/include/platform_def.h
index acdf370d..9df99d14 100644
--- a/plat/arm/tc0/include/platform_def.h
+++ b/plat/arm/tc0/include/platform_def.h
@@ -72,7 +72,7 @@
/* GIC-600 & interrupt handling related constants */
#define TC0_GICD_BASE 0x30000000
-#define TC0_GICR_BASE 0x30140000
+#define TC0_GICR_BASE 0x30080000
#define TC0_GICC_BASE 0x2C000000
/* SoC's PL011 UART0 related constants */
@@ -109,7 +109,12 @@
/* Platform specific page table and MMU setup constants */
#define PLAT_PHY_ADDR_SPACE_SIZE (1ull << 36)
#define PLAT_VIRT_ADDR_SPACE_SIZE (1ull << 36)
+
+#if IMAGE_CACTUS
+#define MAX_XLAT_TABLES 6
+#else
#define MAX_XLAT_TABLES 5
+#endif
#define MAX_MMAP_REGIONS 16
/*******************************************************************************
diff --git a/plat/arm/tc0/platform.mk b/plat/arm/tc0/platform.mk
index faf0d195..1cfe9eea 100644
--- a/plat/arm/tc0/platform.mk
+++ b/plat/arm/tc0/platform.mk
@@ -32,6 +32,7 @@ PLAT_SOURCES := drivers/arm/gic/arm_gic_v2v3.c \
plat/arm/tc0/tc0_topology.c
CACTUS_SOURCES += plat/arm/tc0/${ARCH}/plat_helpers.S
+IVY_SOURCES += plat/arm/tc0/${ARCH}/plat_helpers.S
PLAT_TESTS_SKIP_LIST := plat/arm/tc0/tests_to_skip.txt
diff --git a/plat/arm/tc0/tests_to_skip.txt b/plat/arm/tc0/tests_to_skip.txt
index f039eeda..0d1c16d8 100644
--- a/plat/arm/tc0/tests_to_skip.txt
+++ b/plat/arm/tc0/tests_to_skip.txt
@@ -4,9 +4,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-# System suspend is not supported as there are no wakeup sources in tc0 FVP
+# Disable SMMUv3 tests
+SMMUv3 tests
# PSCI is enabled but not tested
PSCI STAT/Stats test cases after system suspend
PSCI System Suspend Validation
-PSCI NODE_HW_STATE
diff --git a/spm/cactus/cactus.h b/spm/cactus/cactus.h
index cbf2dcb2..c7176c27 100644
--- a/spm/cactus/cactus.h
+++ b/spm/cactus/cactus.h
@@ -26,11 +26,4 @@ extern uintptr_t __BSS_START__, __BSS_END__;
#define CACTUS_BSS_START ((uintptr_t)&__BSS_START__)
#define CACTUS_BSS_END ((uintptr_t)&__BSS_END__)
-enum stdout_route {
- PL011_AS_STDOUT = 0,
- HVC_CALL_AS_STDOUT,
-};
-
-void set_putc_impl(enum stdout_route);
-
#endif /* __CACTUS_H__ */
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index ae66c1de..c21f44b2 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -33,14 +33,14 @@ CACTUS_SOURCES := \
$(addprefix spm/cactus/, \
aarch64/cactus_entrypoint.S \
aarch64/cactus_exceptions.S \
- cactus_debug.c \
cactus_interrupt.c \
cactus_main.c \
) \
$(addprefix spm/common/, \
aarch64/sp_arch_helpers.S \
+ sp_debug.c \
sp_helpers.c \
- spm_helpers.c \
+ spm_helpers.c \
) \
$(addprefix spm/cactus/cactus_tests/, \
cactus_message_loop.c \
@@ -80,9 +80,6 @@ $(eval $(call add_define,CACTUS_DEFINES,DEBUG))
$(eval $(call add_define,CACTUS_DEFINES,ENABLE_ASSERTIONS))
$(eval $(call add_define,CACTUS_DEFINES,ENABLE_BTI))
$(eval $(call add_define,CACTUS_DEFINES,ENABLE_PAUTH))
-$(eval $(call add_define,CACTUS_DEFINES,FVP_CLUSTER_COUNT))
-$(eval $(call add_define,CACTUS_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
-$(eval $(call add_define,CACTUS_DEFINES,FVP_MAX_PE_PER_CPU))
$(eval $(call add_define,CACTUS_DEFINES,LOG_LEVEL))
$(eval $(call add_define,CACTUS_DEFINES,PLAT_${PLAT}))
$(eval $(call add_define,CACTUS_DEFINES,PLAT_XLAT_TABLES_DYNAMIC))
diff --git a/spm/cactus/cactus_interrupt.c b/spm/cactus/cactus_interrupt.c
index 7de36cf0..f61df94e 100644
--- a/spm/cactus/cactus_interrupt.c
+++ b/spm/cactus/cactus_interrupt.c
@@ -13,7 +13,7 @@
#include "cactus_test_cmds.h"
#include "spm_common.h"
-extern ffa_vm_id_t g_ffa_id;
+extern ffa_id_t g_ffa_id;
static void managed_exit_handler(void)
{
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index ff3f6187..59cd7e70 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -16,9 +16,11 @@
#include <lib/tftf_lib.h>
#include <lib/xlat_tables/xlat_mmu_helpers.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include <plat_arm.h>
#include <plat/common/platform.h>
#include <platform_def.h>
+#include <sp_debug.h>
#include <sp_helpers.h>
#include <spm_helpers.h>
#include <std_svc.h>
@@ -34,7 +36,7 @@ extern const char version_string[];
extern void secondary_cold_entry(void);
/* Global ffa_id */
-ffa_vm_id_t g_ffa_id;
+ffa_id_t g_ffa_id;
/*
*
@@ -45,10 +47,10 @@ ffa_vm_id_t g_ffa_id;
*
*/
-static void __dead2 message_loop(ffa_vm_id_t vm_id, struct mailbox_buffers *mb)
+static void __dead2 message_loop(ffa_id_t vm_id, struct mailbox_buffers *mb)
{
smc_ret_values ffa_ret;
- ffa_vm_id_t destination;
+ ffa_id_t destination;
/*
* This initial wait call is necessary to inform SPMD that
@@ -182,7 +184,7 @@ void __dead2 cactus_main(bool primary_cold_boot)
/* Get current FFA id */
smc_ret_values ffa_id_ret = ffa_id_get();
- ffa_vm_id_t ffa_id = (ffa_vm_id_t)(ffa_id_ret.ret2 & 0xffff);
+ ffa_id_t ffa_id = ffa_endpoint_id(ffa_id_ret);
if (ffa_func_id(ffa_id_ret) != FFA_SUCCESS_SMC32) {
ERROR("FFA_ID_GET failed.\n");
panic();
diff --git a/spm/cactus/cactus_tests/cactus_test_direct_messaging.c b/spm/cactus/cactus_tests/cactus_test_direct_messaging.c
index a59cfa24..9b9d1aa1 100644
--- a/spm/cactus/cactus_tests/cactus_test_direct_messaging.c
+++ b/spm/cactus/cactus_tests/cactus_test_direct_messaging.c
@@ -24,8 +24,8 @@ CACTUS_CMD_HANDLER(echo_cmd, CACTUS_ECHO_CMD)
CACTUS_CMD_HANDLER(req_echo_cmd, CACTUS_REQ_ECHO_CMD)
{
smc_ret_values ffa_ret;
- ffa_vm_id_t vm_id = ffa_dir_msg_dest(*args);
- ffa_vm_id_t echo_dest = cactus_req_echo_get_echo_dest(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t echo_dest = cactus_req_echo_get_echo_dest(*args);
uint64_t echo_val = cactus_echo_get_val(*args);
VERBOSE("%x requested to send echo to %x, value %llx\n",
@@ -48,10 +48,10 @@ CACTUS_CMD_HANDLER(req_echo_cmd, CACTUS_REQ_ECHO_CMD)
return cactus_success_resp(vm_id, ffa_dir_msg_source(*args), 0);
}
-static smc_ret_values base_deadlock_handler(ffa_vm_id_t vm_id,
- ffa_vm_id_t source,
- ffa_vm_id_t deadlock_dest,
- ffa_vm_id_t deadlock_next_dest)
+static smc_ret_values base_deadlock_handler(ffa_id_t vm_id,
+ ffa_id_t source,
+ ffa_id_t deadlock_dest,
+ ffa_id_t deadlock_next_dest)
{
smc_ret_values ffa_ret;
@@ -92,9 +92,9 @@ static smc_ret_values base_deadlock_handler(ffa_vm_id_t vm_id,
CACTUS_CMD_HANDLER(deadlock_cmd, CACTUS_DEADLOCK_CMD)
{
- ffa_vm_id_t source = ffa_dir_msg_source(*args);
- ffa_vm_id_t deadlock_dest = cactus_deadlock_get_next_dest(*args);
- ffa_vm_id_t deadlock_next_dest = source;
+ ffa_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t deadlock_dest = cactus_deadlock_get_next_dest(*args);
+ ffa_id_t deadlock_next_dest = source;
VERBOSE("%x is creating deadlock. next: %x\n", source, deadlock_dest);
@@ -104,10 +104,10 @@ CACTUS_CMD_HANDLER(deadlock_cmd, CACTUS_DEADLOCK_CMD)
CACTUS_CMD_HANDLER(req_deadlock_cmd, CACTUS_REQ_DEADLOCK_CMD)
{
- ffa_vm_id_t vm_id = ffa_dir_msg_dest(*args);
- ffa_vm_id_t source = ffa_dir_msg_source(*args);
- ffa_vm_id_t deadlock_dest = cactus_deadlock_get_next_dest(*args);
- ffa_vm_id_t deadlock_next_dest = cactus_deadlock_get_next_dest2(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t deadlock_dest = cactus_deadlock_get_next_dest(*args);
+ ffa_id_t deadlock_next_dest = cactus_deadlock_get_next_dest2(*args);
VERBOSE("%x requested deadlock with %x and %x\n",
ffa_dir_msg_source(*args), deadlock_dest, deadlock_next_dest);
diff --git a/spm/cactus/cactus_tests/cactus_test_ffa.c b/spm/cactus/cactus_tests/cactus_test_ffa.c
index 2ade7bd9..ba069d0c 100644
--- a/spm/cactus/cactus_tests/cactus_test_ffa.c
+++ b/spm/cactus/cactus_tests/cactus_test_ffa.c
@@ -20,10 +20,39 @@
#define FFA_MAJOR 1U
#define FFA_MINOR 0U
-static const uint32_t primary_uuid[4] = PRIMARY_UUID;
-static const uint32_t secondary_uuid[4] = SECONDARY_UUID;
-static const uint32_t tertiary_uuid[4] = TERTIARY_UUID;
-static const uint32_t null_uuid[4] = {0};
+static uint32_t spm_version;
+
+static const struct ffa_uuid sp_uuids[] = {
+ {PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}
+ };
+static const struct ffa_uuid null_uuid = { .uuid = {0} };
+
+static const struct ffa_partition_info ffa_expected_partition_info[] = {
+ /* Primary partition info */
+ {
+ .id = SP_ID(1),
+ .exec_context = PRIMARY_EXEC_CTX_COUNT,
+ .properties = (FFA_PARTITION_DIRECT_REQ_RECV | FFA_PARTITION_DIRECT_REQ_SEND)
+ },
+ /* Secondary partition info */
+ {
+ .id = SP_ID(2),
+ .exec_context = SECONDARY_EXEC_CTX_COUNT,
+ .properties = (FFA_PARTITION_DIRECT_REQ_RECV | FFA_PARTITION_DIRECT_REQ_SEND)
+ },
+ /* Tertiary partition info */
+ {
+ .id = SP_ID(3),
+ .exec_context = TERTIARY_EXEC_CTX_COUNT,
+ .properties = (FFA_PARTITION_DIRECT_REQ_RECV | FFA_PARTITION_DIRECT_REQ_SEND)
+ },
+ /* Ivy partition info */
+ {
+ .id = SP_ID(4),
+ .exec_context = IVY_EXEC_CTX_COUNT,
+ .properties = (FFA_PARTITION_DIRECT_REQ_RECV | FFA_PARTITION_DIRECT_REQ_SEND)
+ }
+};
/*
* Test FFA_FEATURES interface.
@@ -32,51 +61,40 @@ static void ffa_features_test(void)
{
const char *test_features = "FFA Features interface";
smc_ret_values ffa_ret;
+ unsigned int expected_ret;
const struct ffa_features_test *ffa_feature_test_target;
unsigned int i, test_target_size =
get_ffa_feature_test_target(&ffa_feature_test_target);
+ struct ffa_features_test test_target;
announce_test_section_start(test_features);
for (i = 0U; i < test_target_size; i++) {
- announce_test_start(ffa_feature_test_target[i].test_name);
+ test_target = ffa_feature_test_target[i];
- ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
- expect(ffa_func_id(ffa_ret), ffa_feature_test_target[i].expected_ret);
- if (ffa_feature_test_target[i].expected_ret == FFA_ERROR) {
+ announce_test_start(test_target.test_name);
+
+ ffa_ret = ffa_features(test_target.feature);
+ expected_ret = FFA_VERSION_COMPILED
+ >= test_target.version_added ?
+ test_target.expected_ret : FFA_ERROR;
+
+ expect(ffa_func_id(ffa_ret), expected_ret);
+ if (expected_ret == FFA_ERROR) {
expect(ffa_error_code(ffa_ret), FFA_ERROR_NOT_SUPPORTED);
}
- announce_test_end(ffa_feature_test_target[i].test_name);
+ announce_test_end(test_target.test_name);
}
announce_test_section_end(test_features);
}
-static void ffa_partition_info_helper(struct mailbox_buffers *mb, const uint32_t uuid[4],
- const struct ffa_partition_info *expected,
- const uint16_t expected_size)
-{
- smc_ret_values ret = ffa_partition_info_get(uuid);
- unsigned int i;
- expect(ffa_func_id(ret), FFA_SUCCESS_SMC32);
-
- struct ffa_partition_info *info = (struct ffa_partition_info *)(mb->recv);
- for (i = 0U; i < expected_size; i++) {
- expect(info[i].id, expected[i].id);
- expect(info[i].exec_context, expected[i].exec_context);
- expect(info[i].properties, expected[i].properties);
- }
-
- ret = ffa_rx_release();
- expect(ffa_func_id(ret), FFA_SUCCESS_SMC32);
-}
-
static void ffa_partition_info_wrong_test(void)
{
const char *test_wrong_uuid = "Request wrong UUID";
- uint32_t uuid[4] = {1};
+ const struct ffa_uuid uuid = { .uuid = {1} };
announce_test_start(test_wrong_uuid);
@@ -90,50 +108,20 @@ static void ffa_partition_info_wrong_test(void)
static void ffa_partition_info_get_test(struct mailbox_buffers *mb)
{
const char *test_partition_info = "FFA Partition info interface";
- const char *test_primary = "Get primary partition info";
- const char *test_secondary = "Get secondary partition info";
- const char *test_tertiary = "Get tertiary partition info";
- const char *test_all = "Get all partitions info";
-
- const struct ffa_partition_info expected_info[] = {
- /* Primary partition info */
- {
- .id = SPM_VM_ID_FIRST,
- .exec_context = CACTUS_PRIMARY_EC_COUNT,
- /* Supports receipt of direct message requests. */
- .properties = 1U
- },
- /* Secondary partition info */
- {
- .id = SPM_VM_ID_FIRST + 1U,
- .exec_context = CACTUS_SECONDARY_EC_COUNT,
- .properties = 1U
- },
- /* Tertiary partition info */
- {
- .id = SPM_VM_ID_FIRST + 2U,
- .exec_context = CACTUS_TERTIARY_EC_COUNT,
- .properties = 1U
- }
- };
announce_test_section_start(test_partition_info);
- announce_test_start(test_tertiary);
- ffa_partition_info_helper(mb, tertiary_uuid, &expected_info[2], 1);
- announce_test_end(test_tertiary);
+ expect(ffa_partition_info_helper(mb, sp_uuids[2],
+ &ffa_expected_partition_info[2], 1), true);
- announce_test_start(test_secondary);
- ffa_partition_info_helper(mb, secondary_uuid, &expected_info[1], 1);
- announce_test_end(test_secondary);
+ expect(ffa_partition_info_helper(mb, sp_uuids[1],
+ &ffa_expected_partition_info[1], 1), true);
- announce_test_start(test_primary);
- ffa_partition_info_helper(mb, primary_uuid, &expected_info[0], 1);
- announce_test_end(test_primary);
+ expect(ffa_partition_info_helper(mb, sp_uuids[0],
+ &ffa_expected_partition_info[0], 1), true);
- announce_test_start(test_all);
- ffa_partition_info_helper(mb, null_uuid, expected_info, 3);
- announce_test_end(test_all);
+ expect(ffa_partition_info_helper(mb, null_uuid,
+ ffa_expected_partition_info, 4), true);
ffa_partition_info_wrong_test();
@@ -147,7 +135,7 @@ void ffa_version_test(void)
announce_test_start(test_ffa_version);
smc_ret_values ret = ffa_version(MAKE_FFA_VERSION(FFA_MAJOR, FFA_MINOR));
- uint32_t spm_version = (uint32_t)ret.ret0;
+ spm_version = (uint32_t)ret.ret0;
bool ffa_version_compatible =
((spm_version >> FFA_VERSION_MAJOR_SHIFT) == FFA_MAJOR &&
@@ -163,6 +151,32 @@ void ffa_version_test(void)
announce_test_end(test_ffa_version);
}
+void ffa_spm_id_get_test(void)
+{
+ const char *test_spm_id_get = "FFA_SPM_ID_GET SMC Function";
+
+ announce_test_start(test_spm_id_get);
+
+ if (spm_version >= MAKE_FFA_VERSION(1, 1)) {
+ smc_ret_values ret = ffa_spm_id_get();
+
+ expect(ffa_func_id(ret), FFA_SUCCESS_SMC32);
+
+ ffa_id_t spm_id = ffa_endpoint_id(ret);
+
+ VERBOSE("SPM ID = 0x%x\n", spm_id);
+ /*
+ * Check the SPMC value given in the fvp_spmc_manifest
+ * is returned.
+ */
+ expect(spm_id, SPMC_ID);
+ } else {
+ NOTICE("FFA_SPM_ID_GET not supported in this version of FF-A."
+ " Test skipped.\n");
+ }
+ announce_test_end(test_spm_id_get);
+}
+
void ffa_tests(struct mailbox_buffers *mb)
{
const char *test_ffa = "FFA Interfaces";
@@ -171,6 +185,7 @@ void ffa_tests(struct mailbox_buffers *mb)
ffa_features_test();
ffa_version_test();
+ ffa_spm_id_get_test();
ffa_partition_info_get_test(mb);
announce_test_section_end(test_ffa);
diff --git a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
index e7bce50f..604058ae 100644
--- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
+++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
@@ -24,8 +24,8 @@ CACTUS_CMD_HANDLER(mem_send_cmd, CACTUS_MEM_SEND_CMD)
int ret;
unsigned int mem_attrs;
uint32_t *ptr;
- ffa_vm_id_t source = ffa_dir_msg_source(*args);
- ffa_vm_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
uint32_t mem_func = cactus_req_mem_send_get_mem_func(*args);
uint64_t handle = cactus_mem_send_get_handle(*args);
@@ -107,10 +107,10 @@ CACTUS_CMD_HANDLER(req_mem_send_cmd, CACTUS_REQ_MEM_SEND_CMD)
{
smc_ret_values ffa_ret;
uint32_t mem_func = cactus_req_mem_send_get_mem_func(*args);
- ffa_vm_id_t receiver = cactus_req_mem_send_get_receiver(*args);
+ ffa_id_t receiver = cactus_req_mem_send_get_receiver(*args);
ffa_memory_handle_t handle;
- ffa_vm_id_t vm_id = ffa_dir_msg_dest(*args);
- ffa_vm_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t source = ffa_dir_msg_source(*args);
VERBOSE("%x requested to send memory to %x (func: %x)\n",
source, receiver, mem_func);
diff --git a/spm/cactus/cactus_tests/cactus_tests_smmuv3.c b/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
index ce53dc64..fbf46c80 100644
--- a/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
+++ b/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
@@ -151,8 +151,8 @@ static bool run_smmuv3_test(void)
CACTUS_CMD_HANDLER(smmuv3_cmd, CACTUS_DMA_SMMUv3_CMD)
{
smc_ret_values ffa_ret;
- ffa_vm_id_t vm_id = ffa_dir_msg_dest(*args);
- ffa_vm_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t source = ffa_dir_msg_source(*args);
VERBOSE("Received request through direct message for DMA service\n");
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
index 661684bd..2841b7ce 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -27,7 +27,7 @@
entrypoint-offset = <0x00001000>;
xlat-granule = <0>; /* 4KiB */
boot-order = <0>;
- messaging-method = <0>; /* Direct messaging only */
+ messaging-method = <3>; /* Direct messaging only */
run-time-model = <0>; /* Run to completion */
/* Boot protocol */
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
index ea7d5d6f..37b05768 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -27,7 +27,7 @@
entrypoint-offset = <0x00001000>;
xlat-granule = <0>; /* 4KiB */
boot-order = <0>;
- messaging-method = <0>; /* Direct messaging only */
+ messaging-method = <3>; /* Direct messaging only */
run-time-model = <0>; /* Run to completion */
/* Boot protocol */
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus.dts b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
index 1c28fde4..2db86c70 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
@@ -27,7 +27,7 @@
entrypoint-offset = <0x00001000>;
xlat-granule = <0>; /* 4KiB */
boot-order = <0>;
- messaging-method = <3>; /* Direct messaging with managed exit */
+ messaging-method = <11>; /* Direct messaging with managed exit */
run-time-model = <0>; /* Run to completion */
/* Boot protocol */
diff --git a/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h b/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
index 8940c83f..d35194dc 100644
--- a/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
+++ b/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
@@ -22,10 +22,6 @@
#define PLAT_CACTUS_MEMCPY_BASE ULL(0x7400000)
#define PLAT_CACTUS_MEMCPY_RANGE ULL(0x8000)
-#define CACTUS_PRIMARY_EC_COUNT (8U)
-#define CACTUS_SECONDARY_EC_COUNT (8U)
-#define CACTUS_TERTIARY_EC_COUNT (1U)
-
/* Base address of user and PRIV frames in SMMUv3TestEngine */
#define USR_BASE_FRAME ULL(0x2BFE0000)
#define PRIV_BASE_FRAME ULL(0x2BFF0000)
diff --git a/spm/cactus/plat/arm/tc0/fdts/cactus.dts b/spm/cactus/plat/arm/tc0/fdts/cactus.dts
index bd7c5465..eaca7354 100644
--- a/spm/cactus/plat/arm/tc0/fdts/cactus.dts
+++ b/spm/cactus/plat/arm/tc0/fdts/cactus.dts
@@ -25,7 +25,7 @@
entrypoint-offset = <0x00001000>;
xlat-granule = <0>; /* 4KiB */
boot-order = <0>;
- messaging-method = <0>; /* Direct messaging only */
+ messaging-method = <3>; /* Direct messaging with managed exit */
run-time-model = <1>; /* Run to completion */
/* Boot protocol */
diff --git a/spm/cactus/plat/arm/tc0/include/cactus_platform_def.h b/spm/cactus/plat/arm/tc0/include/cactus_platform_def.h
index 42dd2915..62cb3ed6 100644
--- a/spm/cactus/plat/arm/tc0/include/cactus_platform_def.h
+++ b/spm/cactus/plat/arm/tc0/include/cactus_platform_def.h
@@ -16,9 +16,16 @@
#define CACTUS_PL011_UART_CLK_IN_HZ PL011_UART1_CLK_IN_HZ
#define PLAT_CACTUS_RX_BASE ULL(0xfe300000)
+#define PLAT_CACTUS_CORE_COUNT (8)
-#define CACTUS_PRIMARY_EC_COUNT (8U)
-#define CACTUS_SECONDARY_EC_COUNT (8U)
-#define CACTUS_TERTIARY_EC_COUNT (1U)
+/* Scratch memory used for SMMUv3 driver testing purposes in Cactus SP */
+/* SMMUv3 tests are disabled for TC platform */
+#define PLAT_CACTUS_MEMCPY_BASE ULL(0xfe400000)
+#define PLAT_CACTUS_MEMCPY_RANGE ULL(0x8000)
+
+/* Base address of user and PRIV frames in SMMUv3TestEngine */
+/* SMMUv3 tests are disabled for TC platform */
+#define USR_BASE_FRAME ULL(0x0)
+#define PRIV_BASE_FRAME ULL(0x0)
#endif /* CACTUS_PLATFORM_DEF_H */
diff --git a/spm/cactus_mm/cactus_mm.mk b/spm/cactus_mm/cactus_mm.mk
index 3156c1cf..9d98d626 100644
--- a/spm/cactus_mm/cactus_mm.mk
+++ b/spm/cactus_mm/cactus_mm.mk
@@ -59,9 +59,6 @@ $(eval $(call add_define,CACTUS_MM_DEFINES,ARM_ARCH_MINOR))
$(eval $(call add_define,CACTUS_MM_DEFINES,DEBUG))
$(eval $(call add_define,CACTUS_MM_DEFINES,ENABLE_BTI))
$(eval $(call add_define,CACTUS_MM_DEFINES,ENABLE_PAUTH))
-$(eval $(call add_define,CACTUS_MM_DEFINES,FVP_CLUSTER_COUNT))
-$(eval $(call add_define,CACTUS_MM_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
-$(eval $(call add_define,CACTUS_MM_DEFINES,FVP_MAX_PE_PER_CPU))
$(eval $(call add_define,CACTUS_MM_DEFINES,LOG_LEVEL))
$(eval $(call add_define,CACTUS_MM_DEFINES,PLAT_${PLAT}))
diff --git a/spm/cactus/cactus_debug.c b/spm/common/sp_debug.c
index 30a25278..396253b6 100644
--- a/spm/cactus/cactus_debug.c
+++ b/spm/common/sp_debug.c
@@ -1,15 +1,15 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
+#include <sp_debug.h>
+#include <sp_helpers.h>
#include <spm_helpers.h>
-#include "cactus.h"
-
static int (*putc_impl)(int);
static int putc_hypcall(int c)
@@ -19,6 +19,18 @@ static int putc_hypcall(int c)
return c;
}
+static int putc_svccall(int c)
+{
+ /* TODO svc call */
+ svc_args args = {
+ .fid = SPM_DEBUG_LOG,
+ .arg1 = c
+ };
+ sp_svc(&args);
+
+ return c;
+}
+
static int putc_uart(int c)
{
console_pl011_putc(c);
@@ -34,6 +46,10 @@ void set_putc_impl(enum stdout_route route)
putc_impl = putc_hypcall;
return;
+ case SVC_CALL_AS_STDOUT:
+ putc_impl = putc_svccall;
+ return;
+
case PL011_AS_STDOUT:
default:
break;
diff --git a/spm/common/sp_debug.h b/spm/common/sp_debug.h
new file mode 100644
index 00000000..e35c6027
--- /dev/null
+++ b/spm/common/sp_debug.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+enum stdout_route {
+ PL011_AS_STDOUT = 0,
+ HVC_CALL_AS_STDOUT,
+ SVC_CALL_AS_STDOUT,
+};
+
+void set_putc_impl(enum stdout_route);
diff --git a/spm/common/sp_helpers.h b/spm/common/sp_helpers.h
index 399200a0..9f5400ce 100644
--- a/spm/common/sp_helpers.h
+++ b/spm/common/sp_helpers.h
@@ -9,7 +9,7 @@
#include <stdint.h>
#include <tftf_lib.h>
-#include <ffa_helpers.h>
+#include <spm_common.h>
typedef struct {
u_register_t fid;
diff --git a/spm/ivy/aarch64/ivy_entrypoint.S b/spm/ivy/app/aarch64/ivy_entrypoint.S
index c6cb8b34..d981d6a0 100644
--- a/spm/ivy/aarch64/ivy_entrypoint.S
+++ b/spm/ivy/app/aarch64/ivy_entrypoint.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
diff --git a/spm/ivy/app/ivy.h b/spm/ivy/app/ivy.h
new file mode 100644
index 00000000..a40f7e12
--- /dev/null
+++ b/spm/ivy/app/ivy.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef IVY_H
+#define IVY_H
+
+#include <stdint.h>
+
+/* Linker symbols used to figure out the memory layout of the S-EL1 shim. */
+extern uintptr_t __SHIM_TEXT_START__, __SHIM_TEXT_END__;
+#define SHIM_TEXT_START ((uintptr_t)&__SHIM_TEXT_START__)
+#define SHIM_TEXT_END ((uintptr_t)&__SHIM_TEXT_END__)
+
+extern uintptr_t __SHIM_RODATA_START__, __SHIM_RODATA_END__;
+#define SHIM_RODATA_START ((uintptr_t)&__SHIM_RODATA_START__)
+#define SHIM_RODATA_END ((uintptr_t)&__SHIM_RODATA_END__)
+
+extern uintptr_t __SHIM_DATA_START__, __SHIM_DATA_END__;
+#define SHIM_DATA_START ((uintptr_t)&__SHIM_DATA_START__)
+#define SHIM_DATA_END ((uintptr_t)&__SHIM_DATA_END__)
+
+extern uintptr_t __SHIM_BSS_START__, __SHIM_BSS_END__;
+#define SHIM_BSS_START ((uintptr_t)&__SHIM_BSS_START__)
+#define SHIM_BSS_END ((uintptr_t)&__SHIM_BSS_END__)
+
+/* Linker symbols used to figure out the memory layout of Ivy (S-EL0). */
+extern uintptr_t __TEXT_START__, __TEXT_END__;
+#define IVY_TEXT_START ((uintptr_t)&__TEXT_START__)
+#define IVY_TEXT_END ((uintptr_t)&__TEXT_END__)
+
+extern uintptr_t __RODATA_START__, __RODATA_END__;
+#define IVY_RODATA_START ((uintptr_t)&__RODATA_START__)
+#define IVY_RODATA_END ((uintptr_t)&__RODATA_END__)
+
+extern uintptr_t __DATA_START__, __DATA_END__;
+#define IVY_DATA_START ((uintptr_t)&__DATA_START__)
+#define IVY_DATA_END ((uintptr_t)&__DATA_END__)
+
+extern uintptr_t __BSS_START__, __BSS_END__;
+#define IVY_BSS_START ((uintptr_t)&__BSS_START__)
+#define IVY_BSS_END ((uintptr_t)&__BSS_END__)
+
+#endif /* __IVY_H__ */
diff --git a/spm/ivy/ivy_def.h b/spm/ivy/app/ivy_def.h
index 729c46da..815a59e5 100644
--- a/spm/ivy/ivy_def.h
+++ b/spm/ivy/app/ivy_def.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -12,7 +12,7 @@
*/
/* Up to 2 MiB at an arbitrary address that doesn't overlap the devices. */
-#define IVY_IMAGE_BASE ULL(0x90000000)
+#define IVY_IMAGE_BASE ULL(0x1000)
#define IVY_IMAGE_SIZE ULL(0x200000)
/* Memory reserved for stacks */
diff --git a/spm/ivy/app/ivy_main.c b/spm/ivy/app/ivy_main.c
new file mode 100644
index 00000000..28f93ab9
--- /dev/null
+++ b/spm/ivy/app/ivy_main.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+#include <ffa_helpers.h>
+#include <sp_debug.h>
+#include <sp_helpers.h>
+
+#include "ivy.h"
+
+/* Host machine information injected by the build system in the ELF file. */
+extern const char build_message[];
+extern const char version_string[];
+
+void __dead2 ivy_main(void)
+{
+ u_register_t ret;
+ svc_args args;
+
+ set_putc_impl(SVC_CALL_AS_STDOUT);
+
+ NOTICE("Entering S-EL0 Secure Partition\n");
+ NOTICE("%s\n", build_message);
+ NOTICE("%s\n", version_string);
+
+init:
+ args = (svc_args){.fid = FFA_MSG_WAIT};
+ ret = sp_svc(&args);
+
+ while (1) {
+ if (ret != FFA_MSG_SEND_DIRECT_REQ_SMC32) {
+ ERROR("unknown FF-A request %lx\n", ret);
+ goto init;
+ }
+
+ VERBOSE("Received request: %lx\n", args.arg3);
+
+ args.fid = FFA_MSG_SEND_DIRECT_RESP_SMC32;
+ args.arg1 = 0x80020000;
+ args.arg2 = 0;
+ args.arg3 = 0;
+
+ ret = sp_svc(&args);
+ }
+}
diff --git a/spm/ivy/app/plat/arm/fvp/fdts/ivy.dts b/spm/ivy/app/plat/arm/fvp/fdts/ivy.dts
new file mode 100644
index 00000000..a6d0064e
--- /dev/null
+++ b/spm/ivy/app/plat/arm/fvp/fdts/ivy.dts
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * This file is a Partition Manifest (PM) for a minimal Secure Partition (SP)
+ * that has additional optional properties defined.
+ */
+
+
+/dts-v1/;
+
+/ {
+ compatible = "arm,ffa-manifest-1.0";
+
+ /* Properties */
+ description = "ivy-1";
+ ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */
+ uuid = <0xeaba83d8 0xbaaf4eaf 0x8144f7fd 0xcbe544a7>;
+ execution-ctx-count = <1>;
+ exception-level = <2>; /* S-EL1 */
+ execution-state = <0>; /* AARCH64 */
+ load-address = <0x7600000>;
+ entrypoint-offset = <0x00001000>;
+ xlat-granule = <0>; /* 4KiB */
+ boot-order = <0>;
+ messaging-method = <3>; /* Direct messaging only */
+ run-time-model = <1>; /* SP pre-emptible */
+
+ /* Boot protocol */
+ gp-register-num = <0x0>;
+};
diff --git a/spm/ivy/app/plat/arm/fvp/include/ivy_platform_def.h b/spm/ivy/app/plat/arm/fvp/include/ivy_platform_def.h
new file mode 100644
index 00000000..49c8231f
--- /dev/null
+++ b/spm/ivy/app/plat/arm/fvp/include/ivy_platform_def.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <platform_def.h>
+
+#ifndef CACTUS_PLATFORM_DEF_H
+#define CACTUS_PLATFORM_DEF_H
+
+#define PLAT_ARM_DEVICE0_BASE DEVICE0_BASE
+#define PLAT_ARM_DEVICE0_SIZE DEVICE0_SIZE
+
+#define CACTUS_PL011_UART_BASE PL011_UART2_BASE
+#define CACTUS_PL011_UART_CLK_IN_HZ PL011_UART2_CLK_IN_HZ
+
+#define PLAT_CACTUS_RX_BASE ULL(0x7300000)
+
+#endif /* CACTUS_PLATFORM_DEF_H */
diff --git a/spm/ivy/app/plat/arm/fvp/platform.mk b/spm/ivy/app/plat/arm/fvp/platform.mk
new file mode 100644
index 00000000..1e9a43b3
--- /dev/null
+++ b/spm/ivy/app/plat/arm/fvp/platform.mk
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+FVP_IVY_BASE = spm/ivy/app/plat/arm/fvp
+
+PLAT_INCLUDES += -I${FVP_IVY_BASE}/include/
+
+# Add the FDT source
+IVY_DTS = ${FVP_IVY_BASE}/fdts/ivy.dts
+
+# List of FDTS to copy
+FDTS_CP_LIST = ${FVP_IVY_BASE}/fdts/ivy.dts
diff --git a/spm/ivy/app/plat/arm/tc0/fdts/ivy.dts b/spm/ivy/app/plat/arm/tc0/fdts/ivy.dts
new file mode 100644
index 00000000..42084f43
--- /dev/null
+++ b/spm/ivy/app/plat/arm/tc0/fdts/ivy.dts
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * This file is a Partition Manifest (PM) for a minimal Secure Partition (SP)
+ * that has additional optional properties defined.
+ */
+
+
+/dts-v1/;
+
+/ {
+ compatible = "arm,ffa-manifest-1.0";
+
+ /* Properties */
+ description = "ivy-1";
+ ffa-version = <0x00010000>; /* 31:16 - Major, 15:0 - Minor */
+ uuid = <0xeaba83d8 0xbaaf4eaf 0x8144f7fd 0xcbe544a7>;
+ id = <1>;
+ auxiliary-id = <0xae>;
+ stream-endpoint-ids = <0 1 2 3>;
+ execution-ctx-count = <1>;
+ exception-level = <2>; /* S-EL1 */
+ execution-state = <0>; /* AARCH64 */
+ load-address = <0xfe280000>;
+ entrypoint-offset = <0x00001000>;
+ xlat-granule = <0>; /* 4KiB */
+ boot-order = <0>;
+ messaging-method = <3>; /* Direct messaging only */
+ run-time-model = <1>; /* SP pre-emptible */
+
+ /* Boot protocol */
+ gp-register-num = <0x0>;
+};
diff --git a/spm/ivy/app/plat/arm/tc0/include/ivy_platform_def.h b/spm/ivy/app/plat/arm/tc0/include/ivy_platform_def.h
new file mode 100644
index 00000000..49c8231f
--- /dev/null
+++ b/spm/ivy/app/plat/arm/tc0/include/ivy_platform_def.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <platform_def.h>
+
+#ifndef CACTUS_PLATFORM_DEF_H
+#define CACTUS_PLATFORM_DEF_H
+
+#define PLAT_ARM_DEVICE0_BASE DEVICE0_BASE
+#define PLAT_ARM_DEVICE0_SIZE DEVICE0_SIZE
+
+#define CACTUS_PL011_UART_BASE PL011_UART2_BASE
+#define CACTUS_PL011_UART_CLK_IN_HZ PL011_UART2_CLK_IN_HZ
+
+#define PLAT_CACTUS_RX_BASE ULL(0x7300000)
+
+#endif /* CACTUS_PLATFORM_DEF_H */
diff --git a/spm/ivy/app/plat/arm/tc0/platform.mk b/spm/ivy/app/plat/arm/tc0/platform.mk
new file mode 100644
index 00000000..10342d21
--- /dev/null
+++ b/spm/ivy/app/plat/arm/tc0/platform.mk
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+TC0_IVY_BASE = spm/ivy/app/plat/arm/tc0
+
+PLAT_INCLUDES += -I${TC0_IVY_BASE}/include/
+
+# Add the FDT source
+IVY_DTS = ${TC0_IVY_BASE}/fdts/ivy.dts
+
+# List of FDTS to copy
+FDTS_CP_LIST = ${TC0_IVY_BASE}/fdts/ivy.dts
diff --git a/spm/ivy/ivy.dts b/spm/ivy/ivy.dts
deleted file mode 100644
index 4c5a11a1..00000000
--- a/spm/ivy/ivy.dts
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <sp_res_desc_def.h>
-
-#include "ivy_def.h"
-
-/* 4 KiB pages */
-#define PAGE_SIZE U(0x1000)
-
-/*
- * FVP platform layout. The defines are hardcoded here because including the
- * platform headers have too many dependencies.
- * TODO: Move this to the platform layer.
- */
-#define V2M_IOFPGA_BASE ULL(0x1c000000)
-#define V2M_IOFPGA_SIZE ULL(0x03000000)
-
-/* Aggregate of all devices in the first GB. */
-#define DEVICE0_BASE ULL(0x20000000)
-#define DEVICE0_SIZE ULL(0x0c200000)
-
-/dts-v1/;
-
-/ {
- compatible = "arm,sp_rd";
-
- attribute {
- version = <0x00000001>;
- sp_type = <RD_ATTR_TYPE_UP_MIGRATABLE>;
- pe_mpidr = <0>; /* Unused */
- runtime_el = <RD_ATTR_RUNTIME_SEL0>;
- exec_type = <RD_ATTR_RUNTIME>;
- panic_policy = <RD_ATTR_PANIC_ONESHOT>;
- xlat_granule = <RD_ATTR_XLAT_GRANULE_4KB>;
- binary_size = <IVY_IMAGE_SIZE>;
- load_address = <0x00000000 IVY_IMAGE_BASE>;
- entrypoint = <0x00000000 IVY_IMAGE_BASE>;
- };
-
- memory_regions {
- v2m_iofpga {
- str = "V2M IOFPGA";
- base = <0x00000000 V2M_IOFPGA_BASE>;
- size = <0x00000000 V2M_IOFPGA_SIZE>;
- attr = <RD_MEM_DEVICE>;
- };
-
- device0 {
- str = "Device 0";
- base = <0x00000000 DEVICE0_BASE>;
- size = <0x00000000 DEVICE0_SIZE>;
- attr = <RD_MEM_DEVICE>;
- };
-
- spm_buffer {
- str = "SPM buffer";
- base = <0x00000000 IVY_SPM_BUF_BASE>;
- size = <0x00000000 IVY_SPM_BUF_SIZE>;
- attr = <RD_MEM_NORMAL_SPM_SP_SHARED_MEM>;
- };
-
- ns_buffer {
- str = "NS buffer";
- base = <0x00000000 IVY_NS_BUF_BASE>;
- size = <0x00000000 IVY_NS_BUF_SIZE>;
- attr = <RD_MEM_NORMAL_CLIENT_SHARED_MEM>;
- };
- };
-
- notifications {
- notification_0 {
- attr = <0>;
- pe = <0>;
- };
- };
-
- services {
- test_service_1 {
- uuid = <IVY_SERVICE1_UUID_RD>;
-
- accessibility = <(RD_SERV_ACCESS_SECURE |
- RD_SERV_ACCESS_EL3 |
- RD_SERV_ACCESS_NORMAL)>;
- request_type = <(RD_SERV_SUPPORT_BLOCKING |
- RD_SERV_SUPPORT_NON_BLOCKING)>;
- connection_quota = <10>;
- sec_mem_size = <0>;
- interrupt_num = <0>;
- };
- };
-};
diff --git a/spm/ivy/ivy.h b/spm/ivy/ivy.h
deleted file mode 100644
index c5cac2e0..00000000
--- a/spm/ivy/ivy.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef IVY_H
-#define IVY_H
-
-#include <stdint.h>
-
-/* Linker symbols used to figure out the memory layout of Ivy. */
-extern uintptr_t __TEXT_START__, __TEXT_END__;
-#define IVY_TEXT_START ((uintptr_t)&__TEXT_START__)
-#define IVY_TEXT_END ((uintptr_t)&__TEXT_END__)
-
-extern uintptr_t __RODATA_START__, __RODATA_END__;
-#define IVY_RODATA_START ((uintptr_t)&__RODATA_START__)
-#define IVY_RODATA_END ((uintptr_t)&__RODATA_END__)
-
-extern uintptr_t __DATA_START__, __DATA_END__;
-#define IVY_DATA_START ((uintptr_t)&__DATA_START__)
-#define IVY_DATA_END ((uintptr_t)&__DATA_END__)
-
-extern uintptr_t __BSS_START__, __BSS_END__;
-#define IVY_BSS_START ((uintptr_t)&__BSS_START__)
-#define IVY_BSS_END ((uintptr_t)&__BSS_END__)
-
-#endif /* __IVY_H__ */
diff --git a/spm/ivy/ivy.ld.S b/spm/ivy/ivy.ld.S
index 634db155..0e47c217 100644
--- a/spm/ivy/ivy.ld.S
+++ b/spm/ivy/ivy.ld.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -10,7 +10,7 @@
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
-ENTRY(ivy_entrypoint)
+ENTRY(shim_entrypoint)
SECTIONS
{
@@ -19,6 +19,48 @@ SECTIONS
ASSERT(. == ALIGN(PAGE_SIZE),
"TEXT_START address is not aligned to PAGE_SIZE.")
+ /*----------------- START S-EL1 SHIM ----------------*/
+
+ .shim_text : {
+ __SHIM_TEXT_START__ = .;
+ *spm_shim_entrypoint.o(.text*)
+ *(.vectors)
+ . = NEXT(PAGE_SIZE);
+ __SHIM_TEXT_END__ = .;
+ }
+
+ .shim_rodata : {
+ . = ALIGN(PAGE_SIZE);
+ __SHIM_RODATA_START__ = .;
+
+ . = NEXT(PAGE_SIZE);
+ __SHIM_RODATA_END__ = .;
+ }
+
+ .shim_data : {
+ . = ALIGN(PAGE_SIZE);
+ __SHIM_DATA_START__ = .;
+
+ . = NEXT(PAGE_SIZE);
+ __SHIM_DATA_END__ = .;
+ }
+
+ .shim_bss (NOLOAD) : {
+ . = ALIGN(PAGE_SIZE);
+ __SHIM_BSS_START__ = .;
+
+ *(.bss.shim_stacks)
+ *(.bss.tf_base_xlat_table)
+ *(.bss.tf_mmap)
+ *xlat_tables_context.o(COMMON)
+ *xlat_tables_context.o(xlat_table)
+
+ . = NEXT(PAGE_SIZE);
+ __SHIM_BSS_END__ = .;
+ }
+
+ /*----------------- END S-EL1 SHIM ----------------*/
+
.text : {
__TEXT_START__ = .;
*ivy_entrypoint.o(.text*)
@@ -32,6 +74,17 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
__RODATA_START__ = .;
*(.rodata*)
+
+ /*
+ * Keep the .got section in the RO section as it is patched
+ * prior to enabling the MMU, so having it in RO is better for
+ * security. GOT is a table of addresses so ensure 8-byte alignment.
+ */
+ . = ALIGN(8);
+ __GOT_START__ = .;
+ *(.got)
+ __GOT_END__ = .;
+
. = NEXT(PAGE_SIZE);
__RODATA_END__ = .;
}
@@ -44,6 +97,18 @@ SECTIONS
__DATA_END__ = .;
}
+ /*
+ * .rela.dyn needs to come after .data for the read-elf utility
+ * to parse this section correctly. Ensure 8-byte alignment so
+ * that the fields of RELA data structure are aligned.
+ */
+ . = ALIGN(8);
+ __RELA_START__ = .;
+ .rela.dyn . : {
+ }
+ __RELA_END__ = .;
+
+
.bss (NOLOAD) : {
. = ALIGN(PAGE_SIZE);
__BSS_START__ = .;
diff --git a/spm/ivy/ivy.mk b/spm/ivy/ivy.mk
index a5000496..f58422fc 100644
--- a/spm/ivy/ivy.mk
+++ b/spm/ivy/ivy.mk
@@ -1,51 +1,67 @@
#
-# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
include branch_protection.mk
-include lib/sprt/sprt_client.mk
+include lib/xlat_tables_v2/xlat_tables.mk
-IVY_DTB := $(BUILD_PLAT)/ivy.dtb
+# Include ivy platform Makefile
+IVY_PLAT_PATH := $(shell find spm/ivy/app/plat -wholename '*/${PLAT}')
+ifneq (${IVY_PLAT_PATH},)
+ include ${IVY_PLAT_PATH}/platform.mk
+endif
+
+IVY_DTB := build/${PLAT}/debug/ivy.dtb
IVY_INCLUDES := \
+ -Itftf/framework/include \
-Iinclude \
-Iinclude/common \
-Iinclude/common/${ARCH} \
-Iinclude/lib \
-Iinclude/lib/${ARCH} \
- -Iinclude/lib/sprt \
-Iinclude/lib/utils \
-Iinclude/lib/xlat_tables \
-Iinclude/runtime_services \
-Iinclude/runtime_services/secure_el0_payloads \
- -Ispm/ivy \
- -Ispm/common \
- ${SPRT_LIB_INCLUDES}
+ -Ispm/ivy/app \
+ -Ispm/ivy/shim \
+ -Ispm/common
IVY_SOURCES := \
- $(addprefix spm/ivy/, \
+ $(addprefix spm/ivy/app/, \
aarch64/ivy_entrypoint.S \
ivy_main.c \
) \
+ $(addprefix spm/ivy/shim/, \
+ aarch64/spm_shim_entrypoint.S \
+ aarch64/spm_shim_exceptions.S \
+ shim_main.c \
+ ) \
$(addprefix spm/common/, \
aarch64/sp_arch_helpers.S \
+ sp_debug.c \
sp_helpers.c \
+ spm_helpers.c \
) \
# TODO: Remove dependency on TFTF files.
IVY_SOURCES += \
tftf/framework/debug.c \
- tftf/framework/${ARCH}/asm_debug.S
+ tftf/framework/${ARCH}/asm_debug.S \
+ tftf/tests/runtime_services/secure_service/ffa_helpers.c
IVY_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \
- drivers/console/console.c \
lib/${ARCH}/cache_helpers.S \
lib/${ARCH}/misc_helpers.S \
+ lib/smc/${ARCH}/asm_smc.S \
+ lib/smc/${ARCH}/smc.c \
+ lib/smc/${ARCH}/hvc.c \
lib/locks/${ARCH}/spinlock.S \
lib/utils/mp_printf.c \
- ${SPRT_LIB_SOURCES}
+ ${XLAT_TABLES_LIB_SRCS}
IVY_LINKERFILE := spm/ivy/ivy.ld.S
@@ -57,19 +73,35 @@ $(eval $(call add_define,IVY_DEFINES,DEBUG))
$(eval $(call add_define,IVY_DEFINES,ENABLE_ASSERTIONS))
$(eval $(call add_define,IVY_DEFINES,ENABLE_BTI))
$(eval $(call add_define,IVY_DEFINES,ENABLE_PAUTH))
-$(eval $(call add_define,IVY_DEFINES,FVP_CLUSTER_COUNT))
-$(eval $(call add_define,IVY_DEFINES,FVP_MAX_CPUS_PER_CLUSTER))
-$(eval $(call add_define,IVY_DEFINES,FVP_MAX_PE_PER_CPU))
$(eval $(call add_define,IVY_DEFINES,LOG_LEVEL))
$(eval $(call add_define,IVY_DEFINES,PLAT_${PLAT}))
$(IVY_DTB) : $(BUILD_PLAT)/ivy $(BUILD_PLAT)/ivy/ivy.elf
-$(IVY_DTB) : spm/ivy/ivy.dts
- @echo " DTBGEN spm/ivy/ivy.dts"
+$(IVY_DTB) : $(IVY_DTS)
+ @echo " DTBGEN $@"
${Q}tools/generate_dtb/generate_dtb.sh \
- ivy spm/ivy/ivy.dts $(BUILD_PLAT)
+ ivy ${IVY_DTS} $(BUILD_PLAT)
+ ${Q}tools/generate_json/generate_json.sh \
+ ivy $(BUILD_PLAT)
@echo
@echo "Built $@ successfully"
@echo
ivy: $(IVY_DTB)
+
+# FDTS_CP copies flattened device tree sources
+# $(1) = output directory
+# $(2) = flattened device tree source file to copy
+define FDTS_CP
+ $(eval FDTS := $(addprefix $(1)/,$(notdir $(2))))
+FDTS_LIST += $(FDTS)
+$(FDTS): $(2) $(IVY_DTB)
+ @echo " CP $$<"
+ ${Q}cp $$< $$@
+endef
+
+ifdef FDTS_CP_LIST
+ $(eval files := $(filter %.dts,$(FDTS_CP_LIST)))
+ $(eval $(foreach file,$(files),$(call FDTS_CP,$(BUILD_PLAT),$(file))))
+ivy: $(FDTS_LIST)
+endif
diff --git a/spm/ivy/ivy_main.c b/spm/ivy/ivy_main.c
deleted file mode 100644
index 8542150b..00000000
--- a/spm/ivy/ivy_main.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <assert.h>
-#include <debug.h>
-#include <drivers/console.h>
-#include <drivers/arm/pl011.h>
-#include <errno.h>
-#include <ivy_def.h>
-#include <plat_arm.h>
-#include <platform_def.h>
-#include <sp_helpers.h>
-#include <sprt_client.h>
-#include <sprt_svc.h>
-
-#include "ivy.h"
-#include "ivy_def.h"
-
-/* Host machine information injected by the build system in the ELF file. */
-extern const char build_message[];
-extern const char version_string[];
-
-static void ivy_print_memory_layout(void)
-{
- NOTICE("Secure Partition memory layout:\n");
-
- NOTICE(" Image regions\n");
- NOTICE(" Text region : %p - %p\n",
- (void *)IVY_TEXT_START, (void *)IVY_TEXT_END);
- NOTICE(" Read-only data region : %p - %p\n",
- (void *)IVY_RODATA_START, (void *)IVY_RODATA_END);
- NOTICE(" Data region : %p - %p\n",
- (void *)IVY_DATA_START, (void *)IVY_DATA_END);
- NOTICE(" BSS region : %p - %p\n",
- (void *)IVY_BSS_START, (void *)IVY_BSS_END);
- NOTICE(" Total image memory : %p - %p\n",
- (void *)IVY_IMAGE_BASE,
- (void *)(IVY_IMAGE_BASE + IVY_IMAGE_SIZE));
- NOTICE(" SPM regions\n");
- NOTICE(" SPM <-> SP buffer : %p - %p\n",
- (void *)IVY_SPM_BUF_BASE,
- (void *)(IVY_SPM_BUF_BASE + IVY_SPM_BUF_SIZE));
- NOTICE(" NS <-> SP buffer : %p - %p\n",
- (void *)IVY_NS_BUF_BASE,
- (void *)(IVY_NS_BUF_BASE + IVY_NS_BUF_SIZE));
-}
-
-void ivy_message_handler(struct sprt_queue_entry_message *message)
-{
- u_register_t ret0 = 0U, ret1 = 0U, ret2 = 0U, ret3 = 0U;
-
- if (message->type == SPRT_MSG_TYPE_SERVICE_REQUEST) {
- switch (message->args[1]) {
-
- case IVY_PRINT_MAGIC:
- INFO("IVY: Magic: 0x%x\n", IVY_MAGIC_NUMBER);
- ret0 = SPRT_SUCCESS;
- break;
-
- case IVY_GET_MAGIC:
- ret1 = IVY_MAGIC_NUMBER;
- ret0 = SPRT_SUCCESS;
- break;
-
- case IVY_SLEEP_MS:
- sp_sleep(message->args[2]);
- ret0 = SPRT_SUCCESS;
- break;
-
- default:
- NOTICE("IVY: Unhandled Service ID 0x%x\n",
- (unsigned int)message->args[1]);
- ret0 = SPRT_NOT_SUPPORTED;
- break;
- }
- } else {
- NOTICE("Ivy: Unhandled Service type 0x%x\n",
- (unsigned int)message->type);
- ret0 = SPRT_NOT_SUPPORTED;
- }
-
-
- sprt_message_end(message, ret0, ret1, ret2, ret3);
-}
-
-void __dead2 ivy_main(void)
-{
- console_init(PL011_UART3_BASE,
- PL011_UART3_CLK_IN_HZ,
- PL011_BAUDRATE);
-
- NOTICE("Booting test Secure Partition Ivy\n");
- NOTICE("%s\n", build_message);
- NOTICE("%s\n", version_string);
- NOTICE("Running at S-EL0\n");
-
- ivy_print_memory_layout();
-
- /*
- * Handle secure service requests.
- */
- sprt_initialize_queues((void *)IVY_SPM_BUF_BASE);
-
- while (1) {
- struct sprt_queue_entry_message message;
-
- /*
- * Try to fetch a message from the blocking requests queue. If
- * it is empty, try to fetch from the non-blocking requests
- * queue. Repeat until both of them are empty.
- */
- while (1) {
- int err = sprt_get_next_message(&message,
- SPRT_QUEUE_NUM_BLOCKING);
- if (err == -ENOENT) {
- err = sprt_get_next_message(&message,
- SPRT_QUEUE_NUM_NON_BLOCKING);
- if (err == -ENOENT) {
- break;
- } else {
- assert(err == 0);
- ivy_message_handler(&message);
- }
- } else {
- assert(err == 0);
- ivy_message_handler(&message);
- }
- }
-
- sprt_wait_for_messages();
- }
-}
diff --git a/spm/ivy/shim/aarch64/spm_shim_entrypoint.S b/spm/ivy/shim/aarch64/spm_shim_entrypoint.S
new file mode 100644
index 00000000..55d8dd8a
--- /dev/null
+++ b/spm/ivy/shim/aarch64/spm_shim_entrypoint.S
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <asm_macros.S>
+#include <ivy_def.h>
+#include <platform_def.h>
+
+ .globl shim_entrypoint
+
+.section .bss.shim_stacks
+ .balign CACHE_WRITEBACK_GRANULE
+ .fill IVY_STACKS_SIZE
+shim_stacks_end:
+
+func shim_entrypoint
+
+ /* Setup the stack pointer. */
+ adr x0, shim_stacks_end
+ mov sp, x0
+
+ /* Setup vector base address */
+ adr x0, spm_shim_exceptions_ptr
+ msr vbar_el1, x0
+ isb
+
+ /*
+ * Invalidate the data cache for the shim and whole partition.
+ * This prevents re-use of stale data cache entries from prior
+ * bootloader stages.
+ */
+ adrp x0, __SHIM_TEXT_START__
+ adrp x1, __BSS_END__
+ sub x1, x1, x0
+ bl inv_dcache_range
+
+ /* Enable I-Cache */
+ mrs x0, sctlr_el1
+ orr x0, x0, #SCTLR_I_BIT
+ msr sctlr_el1, x0
+ isb
+
+ /* Relocate symbols */
+shim_pie_fixup:
+ ldr x0, =shim_pie_fixup
+ and x0, x0, #~(0x1000 - 1)
+ mov x1, #IVY_IMAGE_SIZE
+ add x1, x1, x0
+ bl fixup_gdt_reloc
+
+ /* Clear S-EL1 shim BSS */
+ adrp x0, __SHIM_BSS_START__
+ adrp x2, __SHIM_BSS_END__
+ sub x2, x2, x0
+ mov x1, xzr
+ bl memset
+
+ /* Clear S-EL0 partition BSS */
+ adrp x0, __BSS_START__
+ adrp x2, __BSS_END__
+ sub x2, x2, x0
+ mov x1, xzr
+ bl memset
+
+ /* And jump to the C entrypoint. */
+ bl shim_main
+
+ /* Exception return to S-EL0 Ivy application code */
+ adrp x0, ivy_entrypoint
+ msr elr_el1, x0
+
+ /* AArch64 EL0t */
+ mov x0, #((DAIF_FIQ_BIT | DAIF_IRQ_BIT) << SPSR_DAIF_SHIFT)
+ msr spsr_el1, x0
+
+ /* TODO: clear GP/SIMD registers */
+ /* TODO: tune EL0 system registers */
+
+ eret
+
+endfunc shim_entrypoint
diff --git a/spm/ivy/shim/aarch64/spm_shim_exceptions.S b/spm/ivy/shim/aarch64/spm_shim_exceptions.S
new file mode 100644
index 00000000..07527e6e
--- /dev/null
+++ b/spm/ivy/shim/aarch64/spm_shim_exceptions.S
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch.h>
+#include <asm_macros.S>
+
+/* -----------------------------------------------------------------------------
+ * Very simple stackless exception handlers used by the spm shim layer.
+ * -----------------------------------------------------------------------------
+ */
+ .globl spm_shim_exceptions_ptr
+
+vector_base spm_shim_exceptions_ptr
+
+ /* -----------------------------------------------------
+ * Current EL with SP0 : 0x0 - 0x200
+ * -----------------------------------------------------
+ */
+vector_entry_spin sync_exception_sp_el0
+
+vector_entry_spin irq_sp_el0
+
+vector_entry_spin fiq_ep_el0
+
+vector_entry_spin serror_ep_el0
+
+ /* -----------------------------------------------------
+ * Current EL with SPx: 0x200 - 0x400
+ * -----------------------------------------------------
+ */
+vector_entry_spin sync_exception_sp_elx
+
+vector_entry_spin irq_sp_elx
+
+vector_entry_spin fiq_sp_elx
+
+vector_entry_spin serror_sp_elx
+
+ /* -----------------------------------------------------
+ * Lower EL using AArch64 : 0x400 - 0x600. No exceptions
+ * are handled since secure_partition does not implement
+ * a lower EL
+ * -----------------------------------------------------
+ */
+vector_entry sync_exception_aarch64
+ msr tpidr_el1, x30
+ mrs x30, esr_el1
+ ubfx x30, x30, #ESR_EC_SHIFT, #ESR_EC_LENGTH
+
+ cmp x30, #EC_AARCH64_SVC
+ b.eq do_smc
+
+ cmp x30, #EC_AARCH32_SVC
+ b.eq do_smc
+
+ cmp x30, #EC_AARCH64_SYS
+ b.eq handle_sys_trap
+
+ /* Fail in all the other cases */
+ b panic
+
+ /* ---------------------------------------------
+ * Tell SPM that we are done initialising
+ * ---------------------------------------------
+ */
+do_smc:
+ mrs x30, tpidr_el1
+ smc #0
+ eret
+
+ /* AArch64 system instructions trap are handled as a panic for now */
+handle_sys_trap:
+panic:
+ b panic
+end_vector_entry sync_exception_aarch64
+
+vector_entry_spin irq_aarch64
+
+vector_entry_spin fiq_aarch64
+
+vector_entry_spin serror_aarch64
+
+ /* -----------------------------------------------------
+ * Lower EL using AArch32 : 0x600 - 0x800
+ * -----------------------------------------------------
+ */
+vector_entry_spin sync_exception_aarch32
+
+vector_entry_spin irq_aarch32
+
+vector_entry_spin fiq_aarch32
+
+vector_entry_spin serror_aarch32
diff --git a/spm/ivy/shim/shim_main.c b/spm/ivy/shim/shim_main.c
new file mode 100644
index 00000000..97df1cc0
--- /dev/null
+++ b/spm/ivy/shim/shim_main.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <assert.h>
+#include <debug.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
+#include <errno.h>
+#include <ffa_helpers.h>
+#include <lib/aarch64/arch_helpers.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat_arm.h>
+#include <plat/common/platform.h>
+#include <platform_def.h>
+#include <sp_debug.h>
+#include <sp_helpers.h>
+#include <std_svc.h>
+
+#include "ivy.h"
+#include "ivy_def.h"
+
+static void shim_print_memory_layout(void)
+{
+ NOTICE("Secure Partition memory layout:\n");
+
+ NOTICE(" Image regions\n");
+ NOTICE(" Text region : %p - %p\n",
+ (void *)IVY_TEXT_START, (void *)IVY_TEXT_END);
+ NOTICE(" Read-only data region : %p - %p\n",
+ (void *)IVY_RODATA_START, (void *)IVY_RODATA_END);
+ NOTICE(" Data region : %p - %p\n",
+ (void *)IVY_DATA_START, (void *)IVY_DATA_END);
+ NOTICE(" BSS region : %p - %p\n",
+ (void *)IVY_BSS_START, (void *)IVY_BSS_END);
+ NOTICE(" Total image memory : %p - %p\n",
+ (void *)IVY_IMAGE_BASE,
+ (void *)(IVY_IMAGE_BASE + IVY_IMAGE_SIZE));
+ NOTICE(" SPM regions\n");
+ NOTICE(" SPM <-> SP buffer : %p - %p\n",
+ (void *)IVY_SPM_BUF_BASE,
+ (void *)(IVY_SPM_BUF_BASE + IVY_SPM_BUF_SIZE));
+ NOTICE(" NS <-> SP buffer : %p - %p\n",
+ (void *)IVY_NS_BUF_BASE,
+ (void *)(IVY_NS_BUF_BASE + IVY_NS_BUF_SIZE));
+}
+
+static void shim_plat_configure_mmu(void)
+{
+ mmap_add_region(SHIM_TEXT_START,
+ SHIM_TEXT_START,
+ SHIM_TEXT_END - SHIM_TEXT_START,
+ MT_CODE | MT_PRIVILEGED);
+ mmap_add_region(SHIM_RODATA_START,
+ SHIM_RODATA_START,
+ SHIM_RODATA_END - SHIM_RODATA_START,
+ MT_RO_DATA | MT_PRIVILEGED);
+ mmap_add_region(SHIM_DATA_START,
+ SHIM_DATA_START,
+ SHIM_DATA_END - SHIM_DATA_START,
+ MT_RW_DATA | MT_PRIVILEGED);
+ mmap_add_region(SHIM_BSS_START,
+ SHIM_BSS_START,
+ SHIM_BSS_END - SHIM_BSS_START,
+ MT_RW_DATA | MT_PRIVILEGED);
+ mmap_add_region(IVY_TEXT_START,
+ IVY_TEXT_START,
+ IVY_TEXT_END - IVY_TEXT_START,
+ MT_CODE | MT_USER);
+ mmap_add_region(IVY_RODATA_START,
+ IVY_RODATA_START,
+ IVY_RODATA_END - IVY_RODATA_START,
+ MT_RO_DATA | MT_USER);
+ mmap_add_region(IVY_DATA_START,
+ IVY_DATA_START,
+ IVY_DATA_END - IVY_DATA_START,
+ MT_RW_DATA | MT_USER);
+ mmap_add_region(IVY_BSS_START,
+ IVY_BSS_START,
+ IVY_BSS_END - IVY_BSS_START,
+ MT_RW_DATA | MT_USER);
+
+ init_xlat_tables();
+}
+
+int shim_main(void)
+{
+ assert(IS_IN_EL1() != 0);
+
+ /* Initialise console */
+ set_putc_impl(HVC_CALL_AS_STDOUT);
+
+ NOTICE("Booting S-EL1 Shim\n");
+
+ /* Configure and enable Stage-1 MMU, enable D-Cache */
+ shim_plat_configure_mmu();
+ enable_mmu_el1(0);
+
+ shim_print_memory_layout();
+
+ return 0;
+}
diff --git a/tftf/framework/aarch64/exceptions.S b/tftf/framework/aarch64/exceptions.S
index 677b30fe..218cca3b 100644
--- a/tftf/framework/aarch64/exceptions.S
+++ b/tftf/framework/aarch64/exceptions.S
@@ -23,38 +23,38 @@ vector_base tftf_vector
/*
* Current EL with SP0 : 0x0 - 0x200.
*/
-unhandled_exception SynchronousExceptionSP0
-unhandled_exception IrqSP0
-unhandled_exception FiqSP0
-unhandled_exception SErrorSP0
+unhandled_exception sync_exception_sp_el0
+unhandled_exception irq_sp_el0
+unhandled_exception fiq_sp_el0
+unhandled_exception serror_sp_el0
/*
* Current EL with SPx : 0x200 - 0x400.
*/
-unhandled_exception SynchronousExceptionSPx
+unhandled_exception sync_exception_sp_elx
-vector_entry IrqSPx
+vector_entry irq_sp_elx
b irq_vector_entry
-end_vector_entry IrqSPx
+end_vector_entry irq_sp_elx
-unhandled_exception FiqSPx
-unhandled_exception SErrorSPx
+unhandled_exception fiq_sp_elx
+unhandled_exception serror_sp_elx
/*
* Lower EL using AArch64 : 0x400 - 0x600.
*/
-unhandled_exception SynchronousExceptionA64
-unhandled_exception IrqA64
-unhandled_exception FiqA64
-unhandled_exception SErrorA64
+unhandled_exception sync_exception_aarch64
+unhandled_exception irq_aarch64
+unhandled_exception fiq_aarch64
+unhandled_exception serror_aarch64
/*
* Lower EL using AArch32 : 0x600 - 0x800.
*/
-unhandled_exception SynchronousExceptionA32
-unhandled_exception IrqA32
-unhandled_exception FiqA32
-unhandled_exception SErrorA32
+unhandled_exception sync_exception_aarch32
+unhandled_exception irq_aarch32
+unhandled_exception fiq_aarch32
+unhandled_exception serror_aarch32
.macro save_gp_regs
stp x0, x1, [sp, #0x0]
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index d794bebc..fffad679 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -172,7 +172,7 @@ test_result_t check_spmc_testing_set_up(
GET_TFTF_MAILBOX(mb);
for (unsigned int i = 0U; i < ffa_uuids_size; i++)
- SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(*mb, ffa_uuids[i].uuid);
+ SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(*mb, ffa_uuids[i]);
return TEST_RESULT_SUCCESS;
}
diff --git a/tftf/tests/extensions/sve/test_sve.c b/tftf/tests/extensions/sve/test_sve.c
index 235e2b8e..eabc0de4 100644
--- a/tftf/tests/extensions/sve/test_sve.c
+++ b/tftf/tests/extensions/sve/test_sve.c
@@ -8,6 +8,7 @@
#include <arch_helpers.h>
#include <debug.h>
#include <stdlib.h>
+#include <test_helpers.h>
#include <tftf_lib.h>
#include "./test_sve.h"
@@ -32,11 +33,7 @@ static int sve_op_2[SVE_ARRAYSIZE];
*/
test_result_t test_sve_support(void)
{
- /* Check if SVE is implemented and usable */
- if (is_armv8_2_sve_present() == false) {
- tftf_testcase_printf("SVE support absent\n");
- return TEST_RESULT_SKIPPED;
- }
+ SKIP_TEST_IF_SVE_NOT_SUPPORTED();
for (int i = 0; i < SVE_ARRAYSIZE; i++) {
/* Generate a random number between 200 and 299 */
diff --git a/tftf/tests/misc_tests/inject_serror.S b/tftf/tests/misc_tests/inject_serror.S
index d42441dd..fd51f855 100644
--- a/tftf/tests/misc_tests/inject_serror.S
+++ b/tftf/tests/misc_tests/inject_serror.S
@@ -27,6 +27,7 @@ func inject_serror_record
/* Clear SError received flag if necessary */
cbz x3, 1f
str xzr, [x3, #0]
+ dsb st
1:
/* Choose Error record 0 on the PE */
msr ERRSELR_EL1, x0
@@ -52,6 +53,7 @@ func inject_serror_record
2:
wfe
+ dsb st
ldr x0, [x3, #0]
cbz x0, 2b
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 8e7b58c6..8d043a1f 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -55,8 +55,8 @@ smc_ret_values ffa_run(uint32_t dest_id, uint32_t vcpu_id)
* -BUSY: Message target is busy
* -ABORTED: Message target ran into an unexpected error and has aborted
*/
-smc_ret_values ffa_msg_send_direct_req64(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint64_t arg0,
+smc_ret_values ffa_msg_send_direct_req64(ffa_id_t source_id,
+ ffa_id_t dest_id, uint64_t arg0,
uint64_t arg1, uint64_t arg2,
uint64_t arg3, uint64_t arg4)
{
@@ -74,8 +74,8 @@ smc_ret_values ffa_msg_send_direct_req64(ffa_vm_id_t source_id,
return tftf_smc(&args);
}
-smc_ret_values ffa_msg_send_direct_req32(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint32_t arg0,
+smc_ret_values ffa_msg_send_direct_req32(ffa_id_t source_id,
+ ffa_id_t dest_id, uint32_t arg0,
uint32_t arg1, uint32_t arg2,
uint32_t arg3, uint32_t arg4)
{
@@ -93,8 +93,8 @@ smc_ret_values ffa_msg_send_direct_req32(ffa_vm_id_t source_id,
return tftf_smc(&args);
}
-smc_ret_values ffa_msg_send_direct_resp64(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint64_t arg0,
+smc_ret_values ffa_msg_send_direct_resp64(ffa_id_t source_id,
+ ffa_id_t dest_id, uint64_t arg0,
uint64_t arg1, uint64_t arg2,
uint64_t arg3, uint64_t arg4)
{
@@ -112,8 +112,8 @@ smc_ret_values ffa_msg_send_direct_resp64(ffa_vm_id_t source_id,
return tftf_smc(&args);
}
-smc_ret_values ffa_msg_send_direct_resp32(ffa_vm_id_t source_id,
- ffa_vm_id_t dest_id, uint32_t arg0,
+smc_ret_values ffa_msg_send_direct_resp32(ffa_id_t source_id,
+ ffa_id_t dest_id, uint32_t arg0,
uint32_t arg1, uint32_t arg2,
uint32_t arg3, uint32_t arg4)
{
@@ -137,9 +137,9 @@ smc_ret_values ffa_msg_send_direct_resp32(ffa_vm_id_t source_id,
* composite memory region offset.
*/
static void ffa_memory_region_init_header(
- struct ffa_memory_region *memory_region, ffa_vm_id_t sender,
+ struct ffa_memory_region *memory_region, ffa_id_t sender,
ffa_memory_attributes_t attributes, ffa_memory_region_flags_t flags,
- ffa_memory_handle_t handle, uint32_t tag, ffa_vm_id_t receiver,
+ ffa_memory_handle_t handle, uint32_t tag, ffa_id_t receiver,
ffa_memory_access_permissions_t permissions)
{
memory_region->sender = sender;
@@ -168,7 +168,7 @@ static void ffa_memory_region_init_header(
*/
uint32_t ffa_memory_region_init(
struct ffa_memory_region *memory_region, size_t memory_region_max_size,
- ffa_vm_id_t sender, ffa_vm_id_t receiver,
+ ffa_id_t sender, ffa_id_t receiver,
const struct ffa_memory_region_constituent constituents[],
uint32_t constituent_count, uint32_t tag,
ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
@@ -259,7 +259,7 @@ uint32_t ffa_memory_region_init(
*/
uint32_t ffa_memory_retrieve_request_init(
struct ffa_memory_region *memory_region, ffa_memory_handle_t handle,
- ffa_vm_id_t sender, ffa_vm_id_t receiver, uint32_t tag,
+ ffa_id_t sender, ffa_id_t receiver, uint32_t tag,
ffa_memory_region_flags_t flags, enum ffa_data_access data_access,
enum ffa_instruction_access instruction_access,
enum ffa_memory_type type, enum ffa_memory_cacheability cacheability,
@@ -291,7 +291,6 @@ uint32_t ffa_memory_retrieve_request_init(
memory_region->receiver_count * sizeof(struct ffa_memory_access);
}
-
/*
* FFA Version ABI helper.
* Version fields:
@@ -317,6 +316,15 @@ smc_ret_values ffa_id_get(void)
return tftf_smc(&args);
}
+smc_ret_values ffa_spm_id_get(void)
+{
+ smc_args args = {
+ .fid = FFA_SPM_ID_GET
+ };
+
+ return tftf_smc(&args);
+}
+
smc_ret_values ffa_msg_wait(void)
{
smc_args args = {
@@ -349,14 +357,14 @@ smc_ret_values ffa_features(uint32_t feature)
}
/* Get information about VMs or SPs based on UUID */
-smc_ret_values ffa_partition_info_get(const uint32_t uuid[4])
+smc_ret_values ffa_partition_info_get(const struct ffa_uuid uuid)
{
smc_args args = {
.fid = FFA_PARTITION_INFO_GET,
- .arg1 = uuid[0],
- .arg2 = uuid[1],
- .arg3 = uuid[2],
- .arg4 = uuid[3]
+ .arg1 = uuid.uuid[0],
+ .arg2 = uuid.uuid[1],
+ .arg3 = uuid.uuid[2],
+ .arg4 = uuid.uuid[3]
};
return tftf_smc(&args);
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index 179ef1cb..7aa4861a 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -6,12 +6,18 @@
#include <debug.h>
#include <ffa_endpoints.h>
+#include <ffa_svc.h>
+#include <lib/extensions/sve.h>
#include <spm_common.h>
#include <xlat_tables_v2.h>
#define __STR(x) #x
#define STR(x) __STR(x)
-#define SIMD_TWO_VECTORS_BYTES_STR (2 * SIMD_VECTOR_LEN_BYTES)
+
+#define fill_simd_helper(num1, num2) "ldp q"#num1", q"#num2",\
+ [%0], #"STR(2 * SIMD_VECTOR_LEN_BYTES)";"
+#define read_simd_helper(num1, num2) "stp q"#num1", q"#num2",\
+ [%0], #"STR(2 * SIMD_VECTOR_LEN_BYTES)";"
/**
* Helper to log errors after FF-A calls.
@@ -58,27 +64,26 @@ bool is_expected_ffa_return(smc_ret_values ret, uint32_t func_id)
return false;
}
-
void fill_simd_vector_regs(const simd_vector_t v[SIMD_NUM_VECTORS])
{
#ifdef __aarch64__
__asm__ volatile(
- "ldp q0, q1, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q2, q3, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q4, q5, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q6, q7, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q8, q9, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q10, q11, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q12, q13, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q14, q15, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q16, q17, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q18, q19, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q20, q21, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q22, q23, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q24, q25, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q26, q27, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q28, q29, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "ldp q30, q31, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
+ fill_simd_helper(0, 1)
+ fill_simd_helper(2, 3)
+ fill_simd_helper(4, 5)
+ fill_simd_helper(6, 7)
+ fill_simd_helper(8, 9)
+ fill_simd_helper(10, 11)
+ fill_simd_helper(12, 13)
+ fill_simd_helper(14, 15)
+ fill_simd_helper(16, 17)
+ fill_simd_helper(18, 19)
+ fill_simd_helper(20, 21)
+ fill_simd_helper(22, 23)
+ fill_simd_helper(24, 25)
+ fill_simd_helper(26, 27)
+ fill_simd_helper(28, 29)
+ fill_simd_helper(30, 31)
"sub %0, %0, #" STR(SIMD_NUM_VECTORS * SIMD_VECTOR_LEN_BYTES) ";"
: : "r" (v));
#endif
@@ -88,29 +93,113 @@ void read_simd_vector_regs(simd_vector_t v[SIMD_NUM_VECTORS])
{
#ifdef __aarch64__
memset(v, 0, sizeof(simd_vector_t) * SIMD_NUM_VECTORS);
-
__asm__ volatile(
- "stp q0, q1, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q2, q3, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q4, q5, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q6, q7, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q8, q9, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q10, q11, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q12, q13, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q14, q15, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q16, q17, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q18, q19, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q20, q21, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q22, q23, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q24, q25, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q26, q27, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q28, q29, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
- "stp q30, q31, [%0], #" STR(SIMD_TWO_VECTORS_BYTES_STR) ";"
+ read_simd_helper(0, 1)
+ read_simd_helper(2, 3)
+ read_simd_helper(4, 5)
+ read_simd_helper(6, 7)
+ read_simd_helper(8, 9)
+ read_simd_helper(10, 11)
+ read_simd_helper(12, 13)
+ read_simd_helper(14, 15)
+ read_simd_helper(16, 17)
+ read_simd_helper(18, 19)
+ read_simd_helper(20, 21)
+ read_simd_helper(22, 23)
+ read_simd_helper(24, 25)
+ read_simd_helper(26, 27)
+ read_simd_helper(28, 29)
+ read_simd_helper(30, 31)
"sub %0, %0, #" STR(SIMD_NUM_VECTORS * SIMD_VECTOR_LEN_BYTES) ";"
: : "r" (v));
#endif
}
+void fill_sve_vector_regs(const sve_vector_t v[SVE_NUM_VECTORS])
+{
+#ifdef __aarch64__
+ __asm__ volatile(
+ ".arch_extension sve\n"
+ fill_sve_helper(0)
+ fill_sve_helper(1)
+ fill_sve_helper(2)
+ fill_sve_helper(3)
+ fill_sve_helper(4)
+ fill_sve_helper(5)
+ fill_sve_helper(6)
+ fill_sve_helper(7)
+ fill_sve_helper(8)
+ fill_sve_helper(9)
+ fill_sve_helper(10)
+ fill_sve_helper(11)
+ fill_sve_helper(12)
+ fill_sve_helper(13)
+ fill_sve_helper(14)
+ fill_sve_helper(15)
+ fill_sve_helper(16)
+ fill_sve_helper(17)
+ fill_sve_helper(18)
+ fill_sve_helper(19)
+ fill_sve_helper(20)
+ fill_sve_helper(21)
+ fill_sve_helper(22)
+ fill_sve_helper(23)
+ fill_sve_helper(24)
+ fill_sve_helper(25)
+ fill_sve_helper(26)
+ fill_sve_helper(27)
+ fill_sve_helper(28)
+ fill_sve_helper(29)
+ fill_sve_helper(30)
+ fill_sve_helper(31)
+ ".arch_extension nosve\n"
+ : : "r" (v));
+#endif
+}
+
+void read_sve_vector_regs(sve_vector_t v[SVE_NUM_VECTORS])
+{
+#ifdef __aarch64__
+ memset(v, 0, sizeof(sve_vector_t) * SVE_NUM_VECTORS);
+ __asm__ volatile(
+ ".arch_extension sve\n"
+ read_sve_helper(0)
+ read_sve_helper(1)
+ read_sve_helper(2)
+ read_sve_helper(3)
+ read_sve_helper(4)
+ read_sve_helper(5)
+ read_sve_helper(6)
+ read_sve_helper(7)
+ read_sve_helper(8)
+ read_sve_helper(9)
+ read_sve_helper(10)
+ read_sve_helper(11)
+ read_sve_helper(12)
+ read_sve_helper(13)
+ read_sve_helper(14)
+ read_sve_helper(15)
+ read_sve_helper(16)
+ read_sve_helper(17)
+ read_sve_helper(18)
+ read_sve_helper(19)
+ read_sve_helper(20)
+ read_sve_helper(21)
+ read_sve_helper(22)
+ read_sve_helper(23)
+ read_sve_helper(24)
+ read_sve_helper(25)
+ read_sve_helper(26)
+ read_sve_helper(27)
+ read_sve_helper(28)
+ read_sve_helper(29)
+ read_sve_helper(30)
+ read_sve_helper(31)
+ ".arch_extension nosve\n"
+ : : "r" (v));
+#endif
+}
+
/*
* check_spmc_execution_level
*
@@ -166,6 +255,8 @@ static const struct ffa_features_test ffa_feature_test_target[] = {
{"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_ERROR},
{"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
{"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
+ {"FFA_SPM_ID_GET_32 check", FFA_SPM_ID_GET, FFA_SUCCESS_SMC32,
+ MAKE_FFA_VERSION(1, 1)},
{"FFA_MSG_POLL_32 check", FFA_MSG_POLL, FFA_SUCCESS_SMC32},
{"FFA_MSG_WAIT_32 check", FFA_MSG_WAIT, FFA_SUCCESS_SMC32},
{"FFA_YIELD_32 check", FFA_MSG_YIELD, FFA_SUCCESS_SMC32},
@@ -199,7 +290,7 @@ unsigned int get_ffa_feature_test_target(
bool memory_retrieve(struct mailbox_buffers *mb,
struct ffa_memory_region **retrieved, uint64_t handle,
- ffa_vm_id_t sender, ffa_vm_id_t receiver,
+ ffa_id_t sender, ffa_id_t receiver,
uint32_t mem_func)
{
smc_ret_values ret;
@@ -269,7 +360,7 @@ bool memory_retrieve(struct mailbox_buffers *mb,
}
bool memory_relinquish(struct ffa_mem_relinquish *m, uint64_t handle,
- ffa_vm_id_t id)
+ ffa_id_t id)
{
smc_ret_values ret;
@@ -297,7 +388,7 @@ ffa_memory_handle_t memory_send(
uint32_t fragment_length, uint32_t total_length)
{
smc_ret_values ret;
- ffa_vm_id_t receiver =
+ ffa_id_t receiver =
memory_region->receivers[0].receiver_permissions.receiver;
if (fragment_length != total_length) {
@@ -336,7 +427,7 @@ ffa_memory_handle_t memory_send(
*/
ffa_memory_handle_t memory_init_and_send(
struct ffa_memory_region *memory_region, size_t memory_region_max_size,
- ffa_vm_id_t sender, ffa_vm_id_t receiver,
+ ffa_id_t sender, ffa_id_t receiver,
const struct ffa_memory_region_constituent *constituents,
uint32_t constituents_count, uint32_t mem_func)
{
@@ -368,3 +459,53 @@ ffa_memory_handle_t memory_init_and_send(
return memory_send(memory_region, mem_func, fragment_length,
total_length);
}
+
+/**
+ * Sends a ffa_partition_info request and checks the response against the
+ * target.
+ */
+bool ffa_partition_info_helper(struct mailbox_buffers *mb,
+ const struct ffa_uuid uuid,
+ const struct ffa_partition_info *expected,
+ const uint16_t expected_size)
+{
+ bool result = true;
+ smc_ret_values ret = ffa_partition_info_get(uuid);
+
+ if (ffa_func_id(ret) == FFA_SUCCESS_SMC32) {
+ if (ret.ret2 != expected_size) {
+ ERROR("Unexpected number of partitions %ld\n", ret.ret2);
+ return false;
+ }
+ const struct ffa_partition_info *info =
+ (const struct ffa_partition_info *)(mb->recv);
+
+ for (unsigned int i = 0U; i < expected_size; i++) {
+ if (info[i].id != expected[i].id) {
+ ERROR("Wrong ID. Expected %x, got %x\n",
+ expected[i].id,
+ info[i].id);
+ result = false;
+ }
+ if (info[i].exec_context != expected[i].exec_context) {
+ ERROR("Wrong context. Expected %d, got %d\n",
+ expected[i].exec_context,
+ info[i].exec_context);
+ result = false;
+ }
+ if (info[i].properties != expected[i].properties) {
+ ERROR("Wrong properties. Expected %d, got %d\n",
+ expected[i].properties,
+ info[i].properties);
+ result = false;
+ }
+ }
+ }
+
+ ret = ffa_rx_release();
+ if (is_ffa_call_error(ret)) {
+ ERROR("Failed to release RX buffer\n");
+ result = false;
+ }
+ return result;
+}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
index 0a722e49..1b9abe95 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_direct_messaging.c
@@ -27,8 +27,8 @@ static const struct ffa_uuid expected_sp_uuids[] = {
static event_t cpu_booted[PLATFORM_CORE_COUNT];
-static test_result_t send_cactus_echo_cmd(ffa_vm_id_t sender,
- ffa_vm_id_t dest,
+static test_result_t send_cactus_echo_cmd(ffa_id_t sender,
+ ffa_id_t dest,
uint64_t value)
{
smc_ret_values ret;
@@ -92,9 +92,9 @@ test_result_t test_ffa_direct_messaging(void)
* otherwise.
* For the CACTUS_SUCCESS response, the test returns TEST_RESULT_SUCCESS.
*/
-static test_result_t send_cactus_req_echo_cmd(ffa_vm_id_t sender,
- ffa_vm_id_t dest,
- ffa_vm_id_t echo_dest,
+static test_result_t send_cactus_req_echo_cmd(ffa_id_t sender,
+ ffa_id_t dest,
+ ffa_id_t echo_dest,
uint64_t value)
{
smc_ret_values ret;
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_features.c b/tftf/tests/runtime_services/secure_service/test_ffa_features.c
deleted file mode 100644
index e4cd845f..00000000
--- a/tftf/tests/runtime_services/secure_service/test_ffa_features.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <spm_common.h>
-#include <test_helpers.h>
-#include <tftf_lib.h>
-
-test_result_t test_ffa_features(void)
-{
- SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);
-
- /* Check if SPMC is OP-TEE at S-EL1 */
- if (check_spmc_execution_level()) {
- /* FFA_FEATURES is not yet supported in OP-TEE */
- return TEST_RESULT_SUCCESS;
- }
-
- smc_ret_values ffa_ret;
- const struct ffa_features_test *ffa_feature_test_target;
- unsigned int i, test_target_size =
- get_ffa_feature_test_target(&ffa_feature_test_target);
-
- for (i = 0U; i < test_target_size; i++) {
- ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
- if (ffa_func_id(ffa_ret) != ffa_feature_test_target[i].expected_ret) {
- tftf_testcase_printf("%s returned %x, expected %x\n",
- ffa_feature_test_target[i].test_name,
- ffa_func_id(ffa_ret),
- ffa_feature_test_target[i].expected_ret);
- return TEST_RESULT_FAIL;
- }
- if ((ffa_feature_test_target[i].expected_ret == FFA_ERROR) &&
- (ffa_error_code(ffa_ret) != FFA_ERROR_NOT_SUPPORTED)) {
- tftf_testcase_printf("%s failed for the wrong reason: "
- "returned %x, expected %x\n",
- ffa_feature_test_target[i].test_name,
- ffa_error_code(ffa_ret),
- FFA_ERROR_NOT_SUPPORTED);
- return TEST_RESULT_FAIL;
- }
- }
-
- return TEST_RESULT_SUCCESS;
-}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c b/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c
index f126c57d..46a7349b 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_memory_sharing.c
@@ -130,8 +130,8 @@ test_result_t test_mem_donate_sp(void)
* Cactus SP should reply to TFTF on whether the test succeeded or not.
*/
static test_result_t test_req_mem_send_sp_to_sp(uint32_t mem_func,
- ffa_vm_id_t sender_sp,
- ffa_vm_id_t receiver_sp)
+ ffa_id_t sender_sp,
+ ffa_id_t receiver_sp)
{
smc_ret_values ret;
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c b/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
deleted file mode 100644
index 1b47c5f9..00000000
--- a/tftf/tests/runtime_services/secure_service/test_ffa_rxtx_map.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <debug.h>
-
-#include <test_helpers.h>
-#include <xlat_tables_defs.h>
-
-static struct mailbox_buffers mb;
-
-static test_result_t test_ffa_rxtx_map(uint32_t expected_return)
-{
- smc_ret_values ret;
-
- /**********************************************************************
- * Verify that FFA is there and that it has the correct version.
- **********************************************************************/
- SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);
-
- /**********************************************************************
- * If OP-TEE is SPMC skip this test.
- **********************************************************************/
- if (check_spmc_execution_level()) {
- VERBOSE("OP-TEE as SPMC at S-EL1. Skipping test!\n");
- return TEST_RESULT_SKIPPED;
- }
-
- /*
- * Declare RXTX buffers, assign them to the mailbox and call
- * FFA_RXTX_MAP.
- */
- CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
- if (ffa_func_id(ret) != expected_return) {
- ERROR("Failed to map RXTX buffers %x!\n", ffa_error_code(ret));
- return TEST_RESULT_FAIL;
- }
-
- return TEST_RESULT_SUCCESS;
-}
-
-/**
- * Test mapping RXTX buffers from NWd.
- * This test also sets the Mailbox for other SPM related tests that need to use
- * RXTX buffers.
- */
-test_result_t test_ffa_rxtx_map_success(void)
-{
- test_result_t ret = test_ffa_rxtx_map(FFA_SUCCESS_SMC32);
-
- if (ret == TEST_RESULT_SUCCESS) {
- INFO("Set RXTX Mailbox for remaining spm tests!\n");
- set_tftf_mailbox(&mb);
- }
- return ret;
-}
-
-/**
- * Test to verify that 2nd call to FFA_RXTX_MAP should fail.
- */
-test_result_t test_ffa_rxtx_map_fail(void)
-{
- INFO("This test expects error log.\n");
- return test_ffa_rxtx_map(FFA_ERROR);
-}
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c b/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
new file mode 100644
index 00000000..572db985
--- /dev/null
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_setup_and_discovery.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <debug.h>
+
+#include <ffa_endpoints.h>
+#include <ffa_helpers.h>
+#include <ffa_svc.h>
+#include <spm_common.h>
+#include <test_helpers.h>
+#include <tftf_lib.h>
+#include <xlat_tables_defs.h>
+
+static bool should_skip_version_test;
+
+static struct mailbox_buffers mb;
+
+static const struct ffa_uuid sp_uuids[] = {
+ {PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}
+ };
+static const struct ffa_uuid null_uuid = { .uuid = {0} };
+
+static const struct ffa_partition_info ffa_expected_partition_info[] = {
+ /* Primary partition info */
+ {
+ .id = SP_ID(1),
+ .exec_context = PRIMARY_EXEC_CTX_COUNT,
+ .properties = FFA_PARTITION_DIRECT_REQ_RECV
+ },
+ /* Secondary partition info */
+ {
+ .id = SP_ID(2),
+ .exec_context = SECONDARY_EXEC_CTX_COUNT,
+ .properties = FFA_PARTITION_DIRECT_REQ_RECV
+ },
+ /* Tertiary partition info */
+ {
+ .id = SP_ID(3),
+ .exec_context = TERTIARY_EXEC_CTX_COUNT,
+ .properties = FFA_PARTITION_DIRECT_REQ_RECV
+ },
+ /* Ivy partition info */
+ {
+ .id = SP_ID(4),
+ .exec_context = IVY_EXEC_CTX_COUNT,
+ .properties = FFA_PARTITION_DIRECT_REQ_RECV
+ }
+};
+
+/*
+ * Using FFA version expected for SPM.
+ */
+#define SPM_VERSION MAKE_FFA_VERSION(FFA_VERSION_MAJOR, FFA_VERSION_MINOR)
+
+/******************************************************************************
+ * FF-A Features ABI Tests
+ ******************************************************************************/
+
+test_result_t test_ffa_features(void)
+{
+ SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);
+
+ /* Check if SPMC is OP-TEE at S-EL1 */
+ if (check_spmc_execution_level()) {
+ /* FFA_FEATURES is not yet supported in OP-TEE */
+ return TEST_RESULT_SUCCESS;
+ }
+
+ smc_ret_values ffa_ret;
+ unsigned int expected_ret;
+ const struct ffa_features_test *ffa_feature_test_target;
+ unsigned int i, test_target_size =
+ get_ffa_feature_test_target(&ffa_feature_test_target);
+ struct ffa_features_test test_target;
+
+ for (i = 0U; i < test_target_size; i++) {
+ test_target = ffa_feature_test_target[i];
+ ffa_ret = ffa_features(test_target.feature);
+ expected_ret = FFA_VERSION_COMPILED
+ >= test_target.version_added ?
+ test_target.expected_ret : FFA_ERROR;
+ if (ffa_func_id(ffa_ret) != expected_ret) {
+ tftf_testcase_printf("%s returned %x, expected %x\n",
+ test_target.test_name,
+ ffa_func_id(ffa_ret),
+ expected_ret);
+ return TEST_RESULT_FAIL;
+ }
+ if ((expected_ret == FFA_ERROR) &&
+ (ffa_error_code(ffa_ret) != FFA_ERROR_NOT_SUPPORTED)) {
+ tftf_testcase_printf("%s failed for the wrong reason: "
+ "returned %x, expected %x\n",
+ test_target.test_name,
+ ffa_error_code(ffa_ret),
+ FFA_ERROR_NOT_SUPPORTED);
+ return TEST_RESULT_FAIL;
+ }
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+/******************************************************************************
+ * FF-A Version ABI Tests
+ ******************************************************************************/
+
+/*
+ * Calls FFA Version ABI, and checks if the result as expected.
+ */
+static test_result_t test_ffa_version(uint32_t input_version,
+ uint32_t expected_return)
+{
+ if (should_skip_version_test) {
+ return TEST_RESULT_SKIPPED;
+ }
+
+ smc_ret_values ret_values = ffa_version(input_version);
+
+ uint32_t spm_version = (uint32_t)(0xFFFFFFFF & ret_values.ret0);
+
+ if (spm_version == expected_return) {
+ return TEST_RESULT_SUCCESS;
+ }
+
+ tftf_testcase_printf("Input Version: 0x%x\n"
+ "Return: 0x%x\nExpected: 0x%x\n",
+ input_version, spm_version, expected_return);
+
+ return TEST_RESULT_FAIL;
+}
+
+/*
+ * @Test_Aim@ Validate what happens when using same version as SPM.
+ */
+test_result_t test_ffa_version_equal(void)
+{
+ /*
+ * FFA_VERSION interface is used to check that SPM functionality is
+ * supported. On FFA_VERSION invocation from TFTF, the SPMD returns
+ * either NOT_SUPPORTED or the SPMC version value provided in the SPMC
+ * manifest. The variable "should_skip_test" is set to true when the
+ * SPMD returns NOT_SUPPORTED or a mismatched version, which means that
+ * a TFTF physical FF-A endpoint version (SPM_VERSION) does not match
+ * the SPMC's physical FF-A endpoint version. This prevents running the
+ * subsequent FF-A version tests (and break the test flow), as they're
+ * not relevant when the SPMD is not present within BL31
+ * (FFA_VERSION returns NOT_SUPPORTED).
+ */
+ test_result_t ret = test_ffa_version(SPM_VERSION, SPM_VERSION);
+
+ if (ret != TEST_RESULT_SUCCESS) {
+ should_skip_version_test = true;
+ ret = TEST_RESULT_SKIPPED;
+ }
+ return ret;
+}
+
+/*
+ * @Test_Aim@ Validate what happens when setting bit 31 in
+ * 'input_version'. As per spec, FFA version is 31 bits long.
+ * Bit 31 set is an invalid input.
+ */
+test_result_t test_ffa_version_bit31(void)
+{
+ return test_ffa_version(FFA_VERSION_BIT31_MASK | SPM_VERSION,
+ FFA_ERROR_NOT_SUPPORTED);
+}
+
+/*
+ * @Test_Aim@ Validate what happens for bigger version than SPM's.
+ */
+test_result_t test_ffa_version_bigger(void)
+{
+ return test_ffa_version(MAKE_FFA_VERSION(FFA_VERSION_MAJOR + 1, 0),
+ SPM_VERSION);
+}
+
+/*
+ * @Test_Aim@ Validate what happens for smaller version than SPM's.
+ */
+test_result_t test_ffa_version_smaller(void)
+{
+ return test_ffa_version(MAKE_FFA_VERSION(0, 9), SPM_VERSION);
+}
+
+/******************************************************************************
+ * FF-A RXTX ABI Tests
+ ******************************************************************************/
+
+static test_result_t test_ffa_rxtx_map(uint32_t expected_return)
+{
+ smc_ret_values ret;
+
+ /**********************************************************************
+ * Verify that FFA is there and that it has the correct version.
+ **********************************************************************/
+ SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 0);
+
+ /**********************************************************************
+ * If OP-TEE is SPMC skip this test.
+ **********************************************************************/
+ if (check_spmc_execution_level()) {
+ VERBOSE("OP-TEE as SPMC at S-EL1. Skipping test!\n");
+ return TEST_RESULT_SKIPPED;
+ }
+
+ /*
+ * Declare RXTX buffers, assign them to the mailbox and call
+ * FFA_RXTX_MAP.
+ */
+ CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
+ if (ffa_func_id(ret) != expected_return) {
+ ERROR("Failed to map RXTX buffers %x!\n", ffa_error_code(ret));
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+/**
+ * Test mapping RXTX buffers from NWd.
+ * This test also sets the Mailbox for other SPM related tests that need to use
+ * RXTX buffers.
+ */
+test_result_t test_ffa_rxtx_map_success(void)
+{
+ test_result_t ret = test_ffa_rxtx_map(FFA_SUCCESS_SMC32);
+
+ if (ret == TEST_RESULT_SUCCESS) {
+ INFO("Set RXTX Mailbox for remaining spm tests!\n");
+ set_tftf_mailbox(&mb);
+ }
+ return ret;
+}
+
+/**
+ * Test to verify that 2nd call to FFA_RXTX_MAP should fail.
+ */
+test_result_t test_ffa_rxtx_map_fail(void)
+{
+ INFO("This test expects error log.\n");
+ return test_ffa_rxtx_map(FFA_ERROR);
+}
+
+/******************************************************************************
+ * FF-A SPM_ID_GET ABI Tests
+ ******************************************************************************/
+
+test_result_t test_ffa_spm_id_get(void)
+{
+ SKIP_TEST_IF_FFA_VERSION_LESS_THAN(1, 1);
+
+ smc_ret_values ffa_ret = ffa_spm_id_get();
+
+ if (is_ffa_call_error(ffa_ret)) {
+ ERROR("FFA_SPM_ID_GET call failed! Error code: 0x%x\n",
+ ffa_error_code(ffa_ret));
+ return TEST_RESULT_FAIL;
+ }
+
+ /* Check the SPMC value given in the fvp_spmc_manifest is returned */
+ ffa_id_t spm_id = ffa_endpoint_id(ffa_ret);
+
+ if (spm_id != SPMC_ID) {
+ ERROR("Expected SPMC_ID of 0x%x\n received: 0x%x\n",
+ SPMC_ID, spm_id);
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
+
+/******************************************************************************
+ * FF-A PARTITION_INFO_GET ABI Tests
+ ******************************************************************************/
+
+/**
+ * Attempt to get the SP partition information for individual partitions as well
+ * as all secure partitions.
+ */
+test_result_t test_ffa_partition_info(void)
+{
+ /***********************************************************************
+ * Check if SPMC has ffa_version and expected FFA endpoints are deployed.
+ **********************************************************************/
+ CHECK_SPMC_TESTING_SETUP(1, 0, sp_uuids);
+
+ GET_TFTF_MAILBOX(mb);
+
+ if (!ffa_partition_info_helper(&mb, sp_uuids[0],
+ &ffa_expected_partition_info[0], 1)) {
+ return TEST_RESULT_FAIL;
+ }
+ if (!ffa_partition_info_helper(&mb, sp_uuids[1],
+ &ffa_expected_partition_info[1], 1)) {
+ return TEST_RESULT_FAIL;
+ }
+ if (!ffa_partition_info_helper(&mb, sp_uuids[2],
+ &ffa_expected_partition_info[2], 1)) {
+ return TEST_RESULT_FAIL;
+ }
+ if (!ffa_partition_info_helper(&mb, null_uuid,
+ ffa_expected_partition_info, 4)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+} \ No newline at end of file
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_version.c b/tftf/tests/runtime_services/secure_service/test_ffa_version.c
deleted file mode 100644
index 41eca5ad..00000000
--- a/tftf/tests/runtime_services/secure_service/test_ffa_version.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <ffa_svc.h>
-#include <test_helpers.h>
-#include <tftf_lib.h>
-
-/*
- * Using FFA version expected for SPM.
- */
-#define SPM_VERSION MAKE_FFA_VERSION(FFA_VERSION_MAJOR, FFA_VERSION_MINOR)
-
-static bool should_skip_test;
-
-/*
- * Calls FFA Version ABI, and checks if the result as expected.
- */
-static test_result_t test_ffa_version(uint32_t input_version, uint32_t expected_return)
-{
- if (should_skip_test) {
- return TEST_RESULT_SKIPPED;
- }
-
- smc_ret_values ret_values = ffa_version(input_version);
-
- uint32_t spm_version = (uint32_t)(0xFFFFFFFF & ret_values.ret0);
-
- if (spm_version == expected_return) {
- return TEST_RESULT_SUCCESS;
- }
-
- tftf_testcase_printf("Input Version: 0x%x\nReturn: 0x%x\nExpected: 0x%x\n",
- input_version, spm_version, expected_return);
-
- return TEST_RESULT_FAIL;
-}
-
-/*
- * @Test_Aim@ Validate what happens when using same version as SPM.
- */
-test_result_t test_ffa_version_equal(void)
-{
- /*
- * FFA_VERSION interface is used to check that SPM functionality is supported.
- * On FFA_VERSION invocation from TFTF, the SPMD returns either NOT_SUPPORTED or
- * the SPMC version value provided in the SPMC manifest. The variable "should_skip_test"
- * is set to true when the SPMD returns NOT_SUPPORTED or a mismatched version, which
- * means that a TFTF physical FF-A endpoint version (SPM_VERSION) does not match the
- * SPMC's physical FF-A endpoint version. This prevents running the subsequent FF-A
- * version tests (and break the test flow), as they're not relevant when the SPMD is
- * not present within BL31 (FFA_VERSION returns NOT_SUPPORTED).
- */
- test_result_t ret = test_ffa_version(SPM_VERSION, SPM_VERSION);
- if (ret != TEST_RESULT_SUCCESS) {
- should_skip_test = true;
- ret = TEST_RESULT_SKIPPED;
- }
- return ret;
-}
-
-/*
- * @Test_Aim@ Validate what happens when setting bit 31 in
- * 'input_version'. As per spec, FFA version is 31 bits long.
- * Bit 31 set is an invalid input.
- */
-test_result_t test_ffa_version_bit31(void)
-{
- return test_ffa_version(FFA_VERSION_BIT31_MASK | SPM_VERSION, FFA_ERROR_NOT_SUPPORTED);
-}
-
-/*
- * @Test_Aim@ Validate what happens for bigger version than SPM's.
- */
-test_result_t test_ffa_version_bigger(void)
-{
- return test_ffa_version(MAKE_FFA_VERSION(FFA_VERSION_MAJOR + 1, 0), SPM_VERSION);
-}
-
-/*
- * @Test_Aim@ Validate what happens for smaller version than SPM's.
- */
-test_result_t test_ffa_version_smaller(void)
-{
- return test_ffa_version(MAKE_FFA_VERSION(0, 9), SPM_VERSION);
-}
diff --git a/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c b/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c
index f57fa243..655f9d94 100644
--- a/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c
+++ b/tftf/tests/runtime_services/secure_service/test_spm_cpu_features.c
@@ -14,15 +14,11 @@
static const struct ffa_uuid expected_sp_uuids[] = { {PRIMARY_UUID} };
-static test_result_t simd_vector_compare(simd_vector_t a[SIMD_NUM_VECTORS],
- simd_vector_t b[SIMD_NUM_VECTORS])
+static test_result_t fp_vector_compare(uint8_t *a, uint8_t *b,
+ size_t vector_size, uint8_t vectors_num)
{
- for (unsigned int num = 0U; num < SIMD_NUM_VECTORS; num++) {
- if (memcmp(a[num], b[num], sizeof(simd_vector_t)) != 0) {
- ERROR("Vectors not equal: a:0x%llx b:0x%llx\n",
- (uint64_t)a[num][0], (uint64_t)b[num][0]);
- return TEST_RESULT_FAIL;
- }
+ if (memcmp(a, b, vector_size * vectors_num) != 0) {
+ return TEST_RESULT_FAIL;
}
return TEST_RESULT_SUCCESS;
}
@@ -35,8 +31,6 @@ static test_result_t simd_vector_compare(simd_vector_t a[SIMD_NUM_VECTORS],
*/
test_result_t test_simd_vectors_preserved(void)
{
- SKIP_TEST_IF_AARCH32();
-
/**********************************************************************
* Verify that FFA is there and that it has the correct version.
**********************************************************************/
@@ -50,7 +44,6 @@ test_result_t test_simd_vectors_preserved(void)
for (unsigned int num = 0U; num < SIMD_NUM_VECTORS; num++) {
memset(simd_vectors_send[num], 0x11 * num, sizeof(simd_vector_t));
}
-
fill_simd_vector_regs(simd_vectors_send);
smc_ret_values ret = cactus_req_simd_fill_send_cmd(SENDER, RECEIVER);
@@ -65,5 +58,50 @@ test_result_t test_simd_vectors_preserved(void)
read_simd_vector_regs(simd_vectors_receive);
- return simd_vector_compare(simd_vectors_send, simd_vectors_receive);
+ return fp_vector_compare((uint8_t *)simd_vectors_send,
+ (uint8_t *)simd_vectors_receive,
+ sizeof(simd_vector_t), SIMD_NUM_VECTORS);
+}
+
+/*
+ * Tests that SVE vectors are preserved during the context switches between
+ * normal world and the secure world.
+ * Fills the SVE vectors with known values, requests SP to fill the vectors
+ * with a different values, checks that the context is restored on return.
+ */
+test_result_t test_sve_vectors_preserved(void)
+{
+ SKIP_TEST_IF_SVE_NOT_SUPPORTED();
+
+ /**********************************************************************
+ * Verify that FFA is there and that it has the correct version.
+ **********************************************************************/
+ CHECK_SPMC_TESTING_SETUP(1, 0, expected_sp_uuids);
+
+ sve_vector_t sve_vectors_send[SVE_NUM_VECTORS],
+ sve_vectors_receive[SVE_NUM_VECTORS];
+
+ /* 0x11 is just a dummy value to be distinguished from the value in the
+ * secure world. */
+ for (unsigned int num = 0U; num < SVE_NUM_VECTORS; num++) {
+ memset(sve_vectors_send[num], 0x11 * num, sizeof(sve_vector_t));
+ }
+
+ fill_sve_vector_regs(sve_vectors_send);
+
+ smc_ret_values ret = cactus_req_simd_fill_send_cmd(SENDER, RECEIVER);
+
+ if (!is_ffa_direct_response(ret)) {
+ return TEST_RESULT_FAIL;
+ }
+
+ if (cactus_get_response(ret) == CACTUS_ERROR) {
+ return TEST_RESULT_FAIL;
+ }
+
+ read_sve_vector_regs(sve_vectors_receive);
+
+ return fp_vector_compare((uint8_t *)sve_vectors_send,
+ (uint8_t *)sve_vectors_receive,
+ sizeof(sve_vector_t), SVE_NUM_VECTORS);
}
diff --git a/tftf/tests/tests-spm.mk b/tftf/tests/tests-spm.mk
index e62e03d9..dc99337b 100644
--- a/tftf/tests/tests-spm.mk
+++ b/tftf/tests/tests-spm.mk
@@ -9,11 +9,9 @@ TESTS_SOURCES += \
ffa_helpers.c \
spm_common.c \
test_ffa_direct_messaging.c \
- test_ffa_features.c \
test_ffa_interrupts.c \
test_ffa_memory_sharing.c \
- test_ffa_rxtx_map.c \
- test_ffa_version.c \
+ test_ffa_setup_and_discovery.c \
test_spm_cpu_features.c \
test_spm_smmu.c \
)
diff --git a/tftf/tests/tests-spm.xml b/tftf/tests/tests-spm.xml
index 32efc161..360e32d7 100644
--- a/tftf/tests/tests-spm.xml
+++ b/tftf/tests/tests-spm.xml
@@ -7,27 +7,30 @@
-->
<testsuites>
+ <testsuite name="FF-A Setup and Discovery"
+ description="Test FF-A Setup and Discovery interfaces" >
+ <testcase name="Test FFA_FEATURES"
+ function="test_ffa_features" />
- <testsuite name="FF-A Version"
- description="Test FF-A Version ABI" >
-
- <testcase name="Same FFA version as SPM"
- function="test_ffa_version_equal" />
- <testcase name="Setting bit 31 in input version"
- function="test_ffa_version_bit31"/>
- <testcase name="Bigger FFA version than SPM"
- function="test_ffa_version_bigger" />
- <testcase name="Smaller FFA version than SPM"
- function="test_ffa_version_smaller" />
-
- </testsuite>
+ <testcase name="Same FFA version as SPM"
+ function="test_ffa_version_equal" />
+ <testcase name="Setting bit 31 in input version"
+ function="test_ffa_version_bit31"/>
+ <testcase name="Bigger FFA version than SPM"
+ function="test_ffa_version_bigger" />
+ <testcase name="Smaller FFA version than SPM"
+ function="test_ffa_version_smaller" />
- <testsuite name="FF-A RXTX Mapping"
- description="Test to FF-A RXTX mapping ABI" >
<testcase name="FF-A RXTX Map API success"
function="test_ffa_rxtx_map_success" />
<testcase name="FF-A RXTX Map API consecutive"
function="test_ffa_rxtx_map_fail" />
+
+ <testcase name="Test FFA_SPM_ID_GET"
+ function="test_ffa_spm_id_get" />
+
+ <testcase name="Test FFA_PARTITION_INFO_GET"
+ function="test_ffa_partition_info" />
</testsuite>
<testsuite name="FF-A Direct messaging"
@@ -66,16 +69,12 @@
function="test_req_mem_donate_sp_to_sp" />
</testsuite>
- <testsuite name="FF-A features"
- description="Test FFA_FEATURES ABI" >
- <testcase name="Test FFA_FEATURES"
- function="test_ffa_features" />
- </testsuite>
-
<testsuite name="SIMD,SVE Registers context"
description="Validate context switch between NWd and SWd" >
<testcase name="Check that SIMD registers context is preserved"
function="test_simd_vectors_preserved" />
+ <testcase name="Check that SVE registers context is preserved"
+ function="test_sve_vectors_preserved" />
</testsuite>
<testsuite name="FF-A Interrupt"
@@ -89,4 +88,5 @@
<testcase name="Check DMA command by SMMUv3TestEngine completes"
function="test_smmu_spm" />
</testsuite>
+
</testsuites>
diff --git a/tools/generate_json/generate_json.sh b/tools/generate_json/generate_json.sh
index f46cf158..3a3c04f6 100755
--- a/tools/generate_json/generate_json.sh
+++ b/tools/generate_json/generate_json.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
-# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -28,7 +28,11 @@ if [ "$1" == "cactus" ]; then
\t\"pm\": \"$1-secondary.dts\",\n \
\t\"owner\": \"Plat\"\n\t},\n\n\t\"$1-tertiary\" : {\n \
\t\"image\": \"$1.bin\",\n \
- \t\"pm\": \"$1-tertiary.dts\" \n \
+ \t\"pm\": \"$1-tertiary.dts\", \n \
+ \t\"owner\": \"Plat\"\n\t},\n\n\t\"ivy\" : {\n \
+ \t\"image\": \"ivy.bin\",\n \
+ \t\"pm\": \"ivy.dts\", \n \
+ \t\"owner\": \"Plat\"\n \
}\n}" \
> "$GENERATED_JSON"
else