Skip to content

Commit 7bcaad1

Browse files
author
Vasily Gorbik
committed
s390: avoid misusing CALL_ON_STACK for task stack setup
CALL_ON_STACK is intended to be used for temporary stack switching with potential return to the caller. When CALL_ON_STACK is misused to switch from nodat stack to task stack back_chain information would later lead stack unwinder from task stack into (per cpu) nodat stack which is reused for other purposes. This would yield confusing unwinding result or errors. To avoid that introduce CALL_ON_STACK_NORETURN to be used instead. It makes sure that back_chain is zeroed and unwinder finishes gracefully ending up at task pt_regs. Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 7579425 commit 7bcaad1

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎arch/s390/include/asm/stacktrace.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,15 @@ struct stack_frame {
124124
r2; \
125125
})
126126

127+
#define CALL_ON_STACK_NORETURN(fn, stack) \
128+
({ \
129+
asm volatile( \
130+
" la 15,0(%[_stack])\n" \
131+
" xc %[_bc](8,15),%[_bc](15)\n" \
132+
" brasl 14,%[_fn]\n" \
133+
::[_bc] "i" (offsetof(struct stack_frame, back_chain)), \
134+
[_stack] "a" (stack), [_fn] "X" (fn)); \
135+
BUG(); \
136+
})
137+
127138
#endif /* _ASM_S390_STACKTRACE_H */

‎arch/s390/kernel/setup.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ early_initcall(async_stack_realloc);
355355

356356
void __init arch_call_rest_init(void)
357357
{
358-
struct stack_frame *frame;
359358
unsigned long stack;
360359

361360
stack = stack_alloc();
@@ -368,13 +367,7 @@ void __init arch_call_rest_init(void)
368367
set_task_stack_end_magic(current);
369368
stack += STACK_INIT_OFFSET;
370369
S390_lowcore.kernel_stack = stack;
371-
frame = (struct stack_frame *) stack;
372-
memset(frame, 0, sizeof(*frame));
373-
/* Branch to rest_init on the new stack, never returns */
374-
asm volatile(
375-
" la 15,0(%[_frame])\n"
376-
" jg rest_init\n"
377-
: : [_frame] "a" (frame));
370+
CALL_ON_STACK_NORETURN(rest_init, stack);
378371
}
379372

380373
static void __init setup_lowcore_dat_off(void)

‎arch/s390/kernel/smp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ static void __no_sanitize_address smp_start_secondary(void *cpuvoid)
876876
S390_lowcore.restart_source = -1UL;
877877
__ctl_load(S390_lowcore.cregs_save_area, 0, 15);
878878
__load_psw_mask(PSW_KERNEL_BITS | PSW_MASK_DAT);
879-
CALL_ON_STACK(smp_init_secondary, S390_lowcore.kernel_stack, 0);
879+
CALL_ON_STACK_NORETURN(smp_init_secondary, S390_lowcore.kernel_stack);
880880
}
881881

882882
/* Upping and downing of CPUs */

0 commit comments

Comments
 (0)