fix: increase hypervisor/spmc per core stack size
There is a latent issue related with per core stack size being too small
and triggering randomly depending on test configurations.
This change increases the per core stack size from one to two pages
hopefully leaving enough room for long function call chains and local
stack allocations.
MTE is able to detect a stack overflow in certain conditions. A better
improvement will be to insert unmapped guard pages inbetween core
stacks.
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: Ic864b5ff998f17e99339b9f6d3297866fa00e011
diff --git a/inc/hf/cpu.h b/inc/hf/cpu.h
index 25eab3b..74d61c1 100644
--- a/inc/hf/cpu.h
+++ b/inc/hf/cpu.h
@@ -8,6 +8,10 @@
#pragma once
+#define STACK_SIZE (8192)
+
+#if !defined(__ASSEMBLER__)
+
#include "hf/arch/cpu.h"
/* TODO: Fix alignment such that `cpu` structs are in different cache lines. */
@@ -34,3 +38,5 @@
struct cpu *cpu_find(cpu_id_t id);
uint8_t *cpu_get_buffer(struct cpu *c);
uint32_t cpu_get_buffer_size(struct cpu *c);
+
+#endif
diff --git a/src/arch/aarch64/hypervisor/hypervisor_entry.S b/src/arch/aarch64/hypervisor/hypervisor_entry.S
index 0627706..a8dfffa 100644
--- a/src/arch/aarch64/hypervisor/hypervisor_entry.S
+++ b/src/arch/aarch64/hypervisor/hypervisor_entry.S
@@ -7,6 +7,7 @@
*/
#include "hf/arch/offsets.h"
+#include "hf/cpu.h"
#include "msr.h"
.macro get_core_affinity reg1 reg2
@@ -19,8 +20,7 @@
.macro init_stack_zero_tag
#if ENABLE_MTE
mov x1, sp
- /* TODO: assume stack size is one page. */
- sub x2, x1, #4096
+ sub x2, x1, #STACK_SIZE
/* Assume 16 bytes tag granule size. */
0: stz2g x2, [x2], #32
cmp x2, x1
diff --git a/src/cpu.c b/src/cpu.c
index ea65f15..30cf2fc 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -20,8 +20,6 @@
#include "system/sys/cdefs.h"
-#define STACK_SIZE PAGE_SIZE
-
/**
* The stacks to be used by the CPUs.
*