test(spm): run ffa_tests on ivy
Move cactus_test_ffa.c to a common directory for SPs so the
ivy partition can also run the same tests.
We also create a sp_platform_def.h file which contains various
plaform defines required for the tests. This header is defined
in both cactus and ivy directories and then fvp and tc0
subdirectories within those. The appropriate header for the sp
and platform being built is then included in the build scripts.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: If65d099d43cd930ef730539b5ad1596e686f788a
diff --git a/spm/cactus/aarch64/cactus_entrypoint.S b/spm/cactus/aarch64/cactus_entrypoint.S
index 6ca342a..6eff65e 100644
--- a/spm/cactus/aarch64/cactus_entrypoint.S
+++ b/spm/cactus/aarch64/cactus_entrypoint.S
@@ -1,13 +1,12 @@
/*
- * Copyright (c) 2017-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch.h>
#include <asm_macros.S>
-#include <cactus_def.h>
-#include <cactus_platform_def.h>
+#include <sp_def.h>
.globl cactus_entrypoint
.globl secondary_cold_entry
@@ -15,7 +14,7 @@
/* Provision one stack per Execution Context (or vCPU) */
.section .bss.stacks
.balign CACHE_WRITEBACK_GRANULE
- .fill CACTUS_STACKS_SIZE * PLAT_CACTUS_CORE_COUNT
+ .fill SP_STACKS_SIZE * PLAT_SP_CORE_COUNT
stacks_end:
func cactus_entrypoint
@@ -38,7 +37,7 @@
/* Setup the stack pointer. */
adr x1, stacks_end
- mov x2, #CACTUS_STACKS_SIZE
+ mov x2, #SP_STACKS_SIZE
mul x2, x0, x2
sub sp, x1, x2
@@ -81,7 +80,7 @@
pie_fixup:
ldr x0, =pie_fixup
and x0, x0, #~(0x1000 - 1)
- mov x1, #CACTUS_IMAGE_SIZE
+ mov x1, #SP_IMAGE_SIZE
add x1, x1, x0
bl fixup_gdt_reloc
diff --git a/spm/cactus/cactus.ld.S b/spm/cactus/cactus.ld.S
index 50fc576..afd72cb 100644
--- a/spm/cactus/cactus.ld.S
+++ b/spm/cactus/cactus.ld.S
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2017-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <cactus_def.h>
+#include <sp_def.h>
#include <platform_def.h>
#include <xlat_tables_defs.h>
@@ -14,7 +14,7 @@
SECTIONS
{
- . = CACTUS_IMAGE_BASE;
+ . = SP_IMAGE_BASE;
ASSERT(. == ALIGN(PAGE_SIZE),
"TEXT_START address is not aligned to PAGE_SIZE.")
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 6e6f2da..ce65035 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -27,7 +27,8 @@
-Iinclude/plat/common \
-Iinclude/runtime_services \
-Ispm/cactus \
- -Ispm/common
+ -Ispm/common \
+ -Ispm/common/sp_tests
CACTUS_SOURCES := \
$(addprefix spm/cactus/, \
@@ -41,11 +42,13 @@
sp_helpers.c \
spm_helpers.c \
) \
+ $(addprefix spm/common/sp_tests/, \
+ sp_test_ffa.c \
+ ) \
$(addprefix spm/cactus/cactus_tests/, \
cactus_message_loop.c \
cactus_test_cpu_features.c \
cactus_test_direct_messaging.c \
- cactus_test_ffa.c \
cactus_test_interrupts.c \
cactus_test_memory_sharing.c \
cactus_tests_smmuv3.c \
diff --git a/spm/cactus/cactus_def.h b/spm/cactus/cactus_def.h
deleted file mode 100644
index 190f063..0000000
--- a/spm/cactus/cactus_def.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef CACTUS_DEF_H
-#define CACTUS_DEF_H
-
-#include <utils_def.h>
-
-/*
- * Layout of the Secure Partition image.
- */
-
-/* Up to 2 MiB at an arbitrary address that doesn't overlap the devices. */
-#define CACTUS_IMAGE_BASE ULL(0x1000)
-#define CACTUS_IMAGE_SIZE ULL(0x200000)
-
-/* Memory reserved for stacks */
-#define CACTUS_STACKS_SIZE ULL(0x1000)
-
-/*
- * RX/TX buffer used by VM's in SPM for memory sharing
- * Each VM allocated 2 pages, one for RX and one for TX buffer.
- */
-#define CACTUS_RX_BASE PLAT_CACTUS_RX_BASE
-#define CACTUS_TX_BASE CACTUS_RX_BASE + PAGE_SIZE
-#define CACTUS_RX_TX_SIZE PAGE_SIZE * 2
-
-/*
- * RX/TX buffer helpers.
- */
-#define get_sp_rx_start(sp_id) (CACTUS_RX_BASE + (((sp_id & 0x7FFFU) - 1U) * CACTUS_RX_TX_SIZE))
-#define get_sp_rx_end(sp_id) (CACTUS_RX_BASE + (((sp_id & 0x7FFFU) - 1U) * CACTUS_RX_TX_SIZE) + PAGE_SIZE)
-#define get_sp_tx_start(sp_id) (CACTUS_TX_BASE + (((sp_id & 0x7FFFU) - 1U) * CACTUS_RX_TX_SIZE))
-#define get_sp_tx_end(sp_id) (CACTUS_TX_BASE + (((sp_id & 0x7FFFU) - 1U) * CACTUS_RX_TX_SIZE) + PAGE_SIZE)
-
-#endif /* CACTUS_DEF_H */
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 56cf21d..f610a3f 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -9,7 +9,6 @@
#include <debug.h>
#include <cactus_message_loop.h>
-#include <cactus_platform_def.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
#include <lib/aarch64/arch_helpers.h>
@@ -26,8 +25,8 @@
#include <spm_helpers.h>
#include <std_svc.h>
-#include "cactus_def.h"
-#include "cactus_tests.h"
+#include "sp_def.h"
+#include "sp_tests.h"
#include "cactus.h"
/* Host machine information injected by the build system in the ELF file. */
@@ -199,12 +198,12 @@
mmap_add_region(get_sp_rx_start(vm_id),
get_sp_rx_start(vm_id),
- (CACTUS_RX_TX_SIZE / 2),
+ (SP_RX_TX_SIZE / 2),
MT_RO_DATA);
mmap_add_region(get_sp_tx_start(vm_id),
get_sp_tx_start(vm_id),
- (CACTUS_RX_TX_SIZE / 2),
+ (SP_RX_TX_SIZE / 2),
MT_RW_DATA);
mmap_add(cactus_mmap);
diff --git a/spm/cactus/cactus_tests.h b/spm/cactus/cactus_tests.h
deleted file mode 100644
index 1039ba5..0000000
--- a/spm/cactus/cactus_tests.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2017-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef CACTUS_TESTS_H
-#define CACTUS_TESTS_H
-
-#include <spm_common.h>
-
-/*
- * Test functions
- */
-
-void ffa_tests(struct mailbox_buffers *mb);
-
-/*
- * Test other things like the version number returned by SPM.
- */
-void misc_tests(void);
-
-/*
- * The Arm TF is responsible for setting up system registers on behalf of the
- * Secure Partition. For example, TF is supposed to allow Secure Partitions to
- * perform cache maintenance operations (by setting the SCTLR_EL1.UCI bit).
- *
- * This function attempts to verify that we indeed have access to these system
- * features from S-EL0. These tests report their results on the UART. They do
- * not recover from a failure : when an error is encountered they will most
- * likely trigger an exception into S-EL1.
- */
-void system_setup_tests(void);
-
-/*
- * Exercise the SP_MEMORY_ATTRIBUTES_SET_AARCH64 SMC interface. A variety of
- * valid and invalid requests to change memory attributes are tested.
- *
- * These tests report their results on the UART. They do not recover from a
- * failure : when an error is encountered they endlessly loop.
- */
-void mem_attr_changes_tests(void);
-
-#endif /* CACTUS_TESTS_H */
diff --git a/spm/cactus/cactus_tests/cactus_test_ffa.c b/spm/cactus/cactus_tests/cactus_test_ffa.c
deleted file mode 100644
index 7e6bf9e..0000000
--- a/spm/cactus/cactus_tests/cactus_test_ffa.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-#include <assert.h>
-#include <debug.h>
-#include <errno.h>
-
-#include <cactus_def.h>
-#include <cactus_platform_def.h>
-#include <ffa_endpoints.h>
-#include <sp_helpers.h>
-#include <spm_helpers.h>
-#include <spm_common.h>
-
-#include <lib/libc/string.h>
-
-/* FFA version test helpers */
-#define FFA_MAJOR 1U
-#define FFA_MINOR 1U
-
-static uint32_t spm_version;
-
-static const struct ffa_uuid sp_uuids[] = {
- {PRIMARY_UUID}, {SECONDARY_UUID}, {TERTIARY_UUID}, {IVY_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 |
- FFA_PARTITION_NOTIFICATION),
- .uuid = sp_uuids[0]
- },
- /* Secondary partition info */
- {
- .id = SP_ID(2),
- .exec_context = SECONDARY_EXEC_CTX_COUNT,
- .properties = (FFA_PARTITION_DIRECT_REQ_RECV |
- FFA_PARTITION_DIRECT_REQ_SEND |
- FFA_PARTITION_NOTIFICATION),
- .uuid = sp_uuids[1]
- },
- /* Tertiary partition info */
- {
- .id = SP_ID(3),
- .exec_context = TERTIARY_EXEC_CTX_COUNT,
- .properties = (FFA_PARTITION_DIRECT_REQ_RECV |
- FFA_PARTITION_DIRECT_REQ_SEND |
- FFA_PARTITION_NOTIFICATION),
- .uuid = sp_uuids[2]
- },
- /* Ivy partition info */
- {
- .id = SP_ID(4),
- .exec_context = IVY_EXEC_CTX_COUNT,
- .properties = (FFA_PARTITION_DIRECT_REQ_RECV |
- FFA_PARTITION_DIRECT_REQ_SEND),
- .uuid = sp_uuids[3]
- }
-};
-
-/*
- * Test FFA_FEATURES interface.
- */
-static void ffa_features_test(void)
-{
- const char *test_features = "FFA Features interface";
- struct ffa_value 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++) {
- test_target = ffa_feature_test_target[i];
-
- 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(test_target.test_name);
- }
-
- announce_test_section_end(test_features);
-}
-
-static void ffa_partition_info_wrong_test(void)
-{
- const char *test_wrong_uuid = "Request wrong UUID";
- const struct ffa_uuid uuid = { .uuid = {1} };
-
- announce_test_start(test_wrong_uuid);
-
- struct ffa_value ret = ffa_partition_info_get(uuid);
- expect(ffa_func_id(ret), FFA_ERROR);
- expect(ffa_error_code(ret), FFA_ERROR_INVALID_PARAMETER);
-
- announce_test_end(test_wrong_uuid);
-}
-
-static void ffa_partition_info_get_test(struct mailbox_buffers *mb)
-{
- const char *test_partition_info = "FFA Partition info interface";
-
- announce_test_section_start(test_partition_info);
-
- expect(ffa_partition_info_helper(mb, sp_uuids[2],
- &ffa_expected_partition_info[2], 1), true);
-
- expect(ffa_partition_info_helper(mb, sp_uuids[1],
- &ffa_expected_partition_info[1], 1), true);
-
- expect(ffa_partition_info_helper(mb, sp_uuids[0],
- &ffa_expected_partition_info[0], 1), true);
-
- expect(ffa_partition_info_helper(mb, null_uuid,
- ffa_expected_partition_info,
- ARRAY_SIZE(ffa_expected_partition_info)), true);
-
- ffa_partition_info_wrong_test();
-
- announce_test_section_end(test_partition_info);
-}
-
-void ffa_version_test(void)
-{
- const char *test_ffa_version = "FFA Version interface";
-
- announce_test_start(test_ffa_version);
-
- struct ffa_value ret = ffa_version(MAKE_FFA_VERSION(FFA_MAJOR,
- FFA_MINOR));
-
- spm_version = (uint32_t)ret.fid;
-
- bool ffa_version_compatible =
- ((spm_version >> FFA_VERSION_MAJOR_SHIFT) == FFA_MAJOR &&
- (spm_version & FFA_VERSION_MINOR_MASK) >= FFA_MINOR);
-
- VERBOSE("FFA_VERSION returned %u.%u; Compatible: %i\n",
- spm_version >> FFA_VERSION_MAJOR_SHIFT,
- spm_version & FFA_VERSION_MINOR_MASK,
- (int)ffa_version_compatible);
-
- expect((int)ffa_version_compatible, (int)true);
-
- 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)) {
- struct ffa_value 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";
-
- announce_test_section_start(test_ffa);
-
- 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 e67ff42..d5e43d8 100644
--- a/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
+++ b/spm/cactus/cactus_tests/cactus_test_memory_sharing.c
@@ -4,14 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <cactus_def.h>
-#include <cactus_platform_def.h>
+#include <sp_def.h>
#include "cactus_message_loop.h"
#include "cactus_test_cmds.h"
-#include "cactus_tests.h"
#include <debug.h>
#include <ffa_helpers.h>
#include <sp_helpers.h>
+#include "sp_tests.h"
#include <xlat_tables_defs.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
#include <sync.h>
diff --git a/spm/cactus/cactus_tests/cactus_test_notifications.c b/spm/cactus/cactus_tests/cactus_test_notifications.c
index 947c8e0..d8b88ed 100644
--- a/spm/cactus/cactus_tests/cactus_test_notifications.c
+++ b/spm/cactus/cactus_tests/cactus_test_notifications.c
@@ -6,7 +6,8 @@
#include "cactus_message_loop.h"
#include "cactus_test_cmds.h"
-#include "cactus_tests.h"
+#include "sp_tests.h"
+
#include <ffa_helpers.h>
#include <debug.h>
diff --git a/spm/cactus/cactus_tests/cactus_tests_smmuv3.c b/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
index fac9514..3e6740b 100644
--- a/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
+++ b/spm/cactus/cactus_tests/cactus_tests_smmuv3.c
@@ -9,14 +9,14 @@
#include <arch_helpers.h>
#include "cactus.h"
#include "cactus_message_loop.h"
-#include <cactus_platform_def.h>
+#include <sp_platform_def.h>
#include "cactus_test_cmds.h"
-#include "cactus_tests.h"
#include <debug.h>
#include <ffa_helpers.h>
#include <mmio.h>
#include "smmuv3_test_engine.h"
#include <sp_helpers.h>
+#include "sp_tests.h"
#include <spm_common.h>
/* Source and target address for memcopy operation */
diff --git a/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h b/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
similarity index 66%
rename from spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
rename to spm/cactus/plat/arm/fvp/include/sp_platform_def.h
index a356577..0b23189 100644
--- a/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
+++ b/spm/cactus/plat/arm/fvp/include/sp_platform_def.h
@@ -1,13 +1,22 @@
/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+/*
+ * This file contains common defines for a secure partition. The correct
+ * platform_def.h header file is selected according to the secure partition
+ * and platform being built using the make scripts.
+ */
+
+#ifndef SP_PLATFORM_DEF_H
+#define SP_PLATFORM_DEF_H
+
#include <platform_def.h>
-#ifndef CACTUS_PLATFORM_DEF_H
-#define CACTUS_PLATFORM_DEF_H
+#define PLAT_SP_RX_BASE ULL(0x7300000)
+#define PLAT_SP_CORE_COUNT U(8)
#define PLAT_ARM_DEVICE0_BASE DEVICE0_BASE
#define PLAT_ARM_DEVICE0_SIZE DEVICE0_SIZE
@@ -15,9 +24,6 @@
#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)
-#define PLAT_CACTUS_CORE_COUNT (8U)
-
/* Scratch memory used for SMMUv3 driver testing purposes in Cactus SP */
#define PLAT_CACTUS_MEMCPY_BASE ULL(0x7400000)
#define PLAT_CACTUS_MEMCPY_RANGE ULL(0x8000)
@@ -32,4 +38,4 @@
#define CACTUS_SP3_MEM_SHARE_BASE 0x7502000
#define CACTUS_SP3_NS_MEM_SHARE_BASE 0x880080001000ULL
-#endif /* CACTUS_PLATFORM_DEF_H */
+#endif /* SP_PLATFORM_DEF_H */
diff --git a/spm/cactus/plat/arm/tc0/include/cactus_platform_def.h b/spm/cactus/plat/arm/tc0/include/sp_platform_def.h
similarity index 72%
rename from spm/cactus/plat/arm/tc0/include/cactus_platform_def.h
rename to spm/cactus/plat/arm/tc0/include/sp_platform_def.h
index e5d83d6..3d288e6 100644
--- a/spm/cactus/plat/arm/tc0/include/cactus_platform_def.h
+++ b/spm/cactus/plat/arm/tc0/include/sp_platform_def.h
@@ -4,10 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+/*
+ * This file contains common defines for a secure partition. The correct
+ * platform_def.h header file is selected according to the secure partition
+ * and platform being built using the make scripts.
+ */
+
+#ifndef SP_PLATFORM_DEF_H
+#define SP_PLATFORM_DEF_H
+
#include <platform_def.h>
-#ifndef CACTUS_PLATFORM_DEF_H
-#define CACTUS_PLATFORM_DEF_H
+#define PLAT_SP_RX_BASE ULL(0xfe300000)
+#define PLAT_SP_CORE_COUNT U(8)
#define PLAT_ARM_DEVICE0_BASE TC0_DEVICE0_BASE
#define PLAT_ARM_DEVICE0_SIZE TC0_DEVICE0_SIZE
@@ -15,9 +24,6 @@
#define CACTUS_PL011_UART_BASE PL011_UART1_BASE
#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)
-
/* 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)
@@ -34,4 +40,4 @@
#define CACTUS_SP3_MEM_SHARE_BASE 0xfe502000
#define CACTUS_SP3_NS_MEM_SHARE_BASE 0x880080001000ULL
-#endif /* CACTUS_PLATFORM_DEF_H */
+#endif /* SP_PLATFORM_DEF_H */