From 0c071b128f047f40de5ffb5aaf2cb7fee3255593 Mon Sep 17 00:00:00 2001 From: He Sheng Date: Fri, 19 Aug 2022 16:42:27 +0800 Subject: [PATCH] sw64: init sp with kernel stack top for idle thread Sunway inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5PNF1 -------------------------------- For secondary CPU, it has to do ($sp - THREAD_SIZE) to find current thread_info. Signed-off-by: He Sheng Signed-off-by: Gu Zitao --- arch/sw_64/kernel/asm-offsets.c | 1 + arch/sw_64/kernel/head.S | 7 +++---- arch/sw_64/kernel/smp.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/sw_64/kernel/asm-offsets.c b/arch/sw_64/kernel/asm-offsets.c index 86ed5b8c216e..12b3311c1bcb 100644 --- a/arch/sw_64/kernel/asm-offsets.c +++ b/arch/sw_64/kernel/asm-offsets.c @@ -218,4 +218,5 @@ void foo(void) OFFSET(TASK_THREAD_S5, task_struct, thread.s[5]); OFFSET(TASK_THREAD_S6, task_struct, thread.s[6]); BLANK(); + DEFINE(ASM_THREAD_SIZE, THREAD_SIZE); } diff --git a/arch/sw_64/kernel/head.S b/arch/sw_64/kernel/head.S index 4b2db3891dcb..3dfb95c91d70 100644 --- a/arch/sw_64/kernel/head.S +++ b/arch/sw_64/kernel/head.S @@ -24,7 +24,7 @@ __start: /* We need to get current_task_info loaded up... */ ldi $8, init_thread_union /* ... and find our stack ... */ - ldi $30, 0x4000 - PT_REGS_SIZE($8) + ldi $30, ASM_THREAD_SIZE($8) /* ... and then we can clear bss data. */ ldi $2, __bss_start ldi $3, __bss_stop @@ -51,7 +51,7 @@ __start: ldl $29, 0($30) addl $29, $0, $29 /* Repoint the sp into the new kernel image */ - ldi $30, 0x4000 - PT_REGS_SIZE($8) + ldi $30, ASM_THREAD_SIZE($8) #endif /* ... and then we can start the kernel. */ call $26, sw64_start_kernel @@ -84,8 +84,7 @@ __smp_callin: s8addl $0, $2, $2 ldl $30, 0($2) # Get ksp of idle thread - ldi $8, 0x3fff # Find "current". - bic $30, $8, $8 + ldi $8, -ASM_THREAD_SIZE($30) # Find "current" call $26, smp_callin sys_call HMC_halt diff --git a/arch/sw_64/kernel/smp.c b/arch/sw_64/kernel/smp.c index b66608c4934b..f74b172ecb25 100644 --- a/arch/sw_64/kernel/smp.c +++ b/arch/sw_64/kernel/smp.c @@ -159,7 +159,7 @@ static int secondary_cpu_start(int cpuid, struct task_struct *idle) /* * Precalculate the target ksp. */ - tidle_ksp[cpuid] = idle->stack + sizeof(union thread_union) - 16; + tidle_ksp[cpuid] = idle->stack + THREAD_SIZE; DBGS("Starting secondary cpu %d: state 0x%lx\n", cpuid, idle->state); -- GitLab