Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390: fix register clobbering in CALL_ON_STACK

CALL_ON_STACK defines and initializes register variables. Inline
assembly which follows might trigger compiler to generate memory access
for "stack" argument (e.g. in case of S390_lowcore.nodat_stack). This
memory access produces a function call under kasan with outline
instrumentation which clobbers registers.

Switch "stack" argument in CALL_ON_STACK helper to use memory reference
constraint and perform load instead.

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

+2 -2
+2 -2
arch/s390/include/asm/stacktrace.h
··· 112 112 \ 113 113 asm volatile( \ 114 114 " la %[_prev],0(15)\n" \ 115 - " la 15,0(%[_stack])\n" \ 115 + " lg 15,%[_stack]\n" \ 116 116 " stg %[_frame],%[_bc](15)\n" \ 117 117 " brasl 14,%[_fn]\n" \ 118 118 " la 15,0(%[_prev])\n" \ 119 119 : [_prev] "=&a" (prev), CALL_FMT_##nr \ 120 - [_stack] "a" (stack), \ 120 + [_stack] "R" (stack), \ 121 121 [_bc] "i" (offsetof(struct stack_frame, back_chain)), \ 122 122 [_frame] "d" (frame), \ 123 123 [_fn] "X" (fn) : CALL_CLOBBER_##nr); \