From: Alexandru Elisei <alexandru.elisei@xxxxxxx> For the boot CPU, the entire stack is zeroed in the entry code. For the secondaries, only struct thread_info, which lives at the bottom of the stack, is zeroed in thread_info_init(). Be consistent and zero the entire stack for the secondaries. This should also improve reproducibility of the testsuite, as all the stacks will start with the same contents, which is zero. And now that all the stacks are zeroed in the entry code, there is no need to explicitely zero struct thread_info in thread_info_init(). Reviewed-by: Nikos Nikoleris <nikos.nikoleris@xxxxxxx> Reviewed-by: Andrew Jones <andrew.jones@xxxxxxxxx> Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> Signed-off-by: Shaoqin Huang <shahuang@xxxxxxxxxx> --- arm/cstart.S | 6 ++++++ arm/cstart64.S | 11 +++++++---- lib/arm/processor.c | 1 - lib/arm64/processor.c | 1 - 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/arm/cstart.S b/arm/cstart.S index b24ecabc..2ecebd1d 100644 --- a/arm/cstart.S +++ b/arm/cstart.S @@ -151,7 +151,13 @@ secondary_entry: */ ldr r1, =secondary_data ldr r0, [r1] + mov r2, r0 + lsr r2, #THREAD_SHIFT + lsl r2, #THREAD_SHIFT + add r3, r2, #THREAD_SIZE + zero_range r2, r3, r4, r5 mov sp, r0 + bl exceptions_init bl enable_vfp diff --git a/arm/cstart64.S b/arm/cstart64.S index a8ad6dc8..5ba2fb27 100644 --- a/arm/cstart64.S +++ b/arm/cstart64.S @@ -14,10 +14,6 @@ #include <asm/thread_info.h> #include <asm/sysreg.h> -#ifdef CONFIG_EFI -#include "efi/crt0-efi-aarch64.S" -#else - .macro zero_range, tmp1, tmp2 9998: cmp \tmp1, \tmp2 b.eq 9997f @@ -26,6 +22,10 @@ 9997: .endm +#ifdef CONFIG_EFI +#include "efi/crt0-efi-aarch64.S" +#else + .section .init /* @@ -162,6 +162,9 @@ secondary_entry: /* set the stack */ adrp x0, secondary_data ldr x0, [x0, :lo12:secondary_data] + and x1, x0, #THREAD_MASK + add x2, x1, #THREAD_SIZE + zero_range x1, x2 mov sp, x0 /* finish init in C code */ diff --git a/lib/arm/processor.c b/lib/arm/processor.c index 9d575968..ceff1c0a 100644 --- a/lib/arm/processor.c +++ b/lib/arm/processor.c @@ -117,7 +117,6 @@ void do_handle_exception(enum vector v, struct pt_regs *regs) void thread_info_init(struct thread_info *ti, unsigned int flags) { - memset(ti, 0, sizeof(struct thread_info)); ti->cpu = mpidr_to_cpu(get_mpidr()); ti->flags = flags; } diff --git a/lib/arm64/processor.c b/lib/arm64/processor.c index 5bcad679..a8ef8c59 100644 --- a/lib/arm64/processor.c +++ b/lib/arm64/processor.c @@ -233,7 +233,6 @@ void install_vector_handler(enum vector v, vector_fn fn) static void __thread_info_init(struct thread_info *ti, unsigned int flags) { - memset(ti, 0, sizeof(struct thread_info)); ti->cpu = mpidr_to_cpu(get_mpidr()); ti->flags = flags; } -- 2.40.1