fix(hftest): define stacks for all secondary cores
The hftest common libraries was reusing the same stack section
for all secondary cores.
This means some tests would fail unexpectidly.
Adding a function to common.c and service_common.c, which have
the same purpose in the target they are used in, to retrieve
the buffers for the secondary core stacks defined globally.
Signed-off-by: J-Alves <joao.alves@arm.com>
Signed-off-by: K-Meakin <karl.meakin@arm.com>
Change-Id: If93aed330a88c3b52e5771d09911296f2c6214ed
diff --git a/test/hftest/common.c b/test/hftest/common.c
index 1f85694..7aeda22 100644
--- a/test/hftest/common.c
+++ b/test/hftest/common.c
@@ -27,6 +27,8 @@
static struct hftest_context global_context;
+static alignas(PAGE_SIZE) uint8_t secondary_ec_stack[MAX_CPUS][PAGE_SIZE];
+
struct hftest_context *hftest_get_context(void)
{
return &global_context;
@@ -295,6 +297,12 @@
return index;
}
+uint8_t *hftest_get_secondary_ec_stack(size_t id)
+{
+ assert(id < MAX_CPUS);
+ return secondary_ec_stack[id];
+}
+
/**
* Get the ID of the CPU with the given index.
*/
diff --git a/test/hftest/power_mgmt.c b/test/hftest/power_mgmt.c
index 7b8c041..787a7fe 100644
--- a/test/hftest/power_mgmt.c
+++ b/test/hftest/power_mgmt.c
@@ -22,12 +22,6 @@
struct spinlock lock;
};
-/*
- * Stack for secondary execution contexts.
- * Used in tests for MP partitions where multicore functionality is tested.
- */
-alignas(PAGE_SIZE) uint8_t secondary_ec_stack[MAX_CPUS - 1][PAGE_SIZE];
-
static noreturn void cpu_entry(uintptr_t arg)
{
/*
@@ -56,18 +50,18 @@
arch_cpu_stop();
}
-bool hftest_cpu_start(cpu_id_t id, cpu_entry_point *entry, uintptr_t arg)
+bool hftest_cpu_start(cpu_id_t id, const uint8_t *secondary_ec_stack,
+ cpu_entry_point *entry, uintptr_t arg)
{
struct cpu_start_state s;
struct arch_cpu_start_state s_arch;
- size_t stack_size = sizeof(secondary_ec_stack[0]);
/*
* Config for arch_cpu_start() which will start a new CPU and
* immediately jump to cpu_entry(). This function must guarantee that
* the state struct is not be freed until cpu_entry() is called.
*/
- s_arch.initial_sp = (uintptr_t)secondary_ec_stack + stack_size;
+ s_arch.initial_sp = (uintptr_t)secondary_ec_stack;
s_arch.entry = cpu_entry;
s_arch.arg = (uintptr_t)&s;
diff --git a/test/hftest/service_common.c b/test/hftest/service_common.c
index b277b38..f0ab701 100644
--- a/test/hftest/service_common.c
+++ b/test/hftest/service_common.c
@@ -29,6 +29,14 @@
static struct hftest_context global_context;
+static alignas(PAGE_SIZE) uint8_t secondary_ec_stack[MAX_CPUS][PAGE_SIZE];
+
+uint8_t *hftest_get_secondary_ec_stack(size_t id)
+{
+ assert(id < MAX_CPUS);
+ return secondary_ec_stack[id];
+}
+
struct hftest_context *hftest_get_context(void)
{
return &global_context;