s390/stack: fix possible register corruption with stack switch helper
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 18 Jun 2021 14:58:47 +0000 (16:58 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 21 Jun 2021 09:19:18 +0000 (11:19 +0200)
commit67147e96a332b56c7206238162771d82467f86c0
tree8641c17c4af3f413489ec76c23a1cd4b32892f1a
parent9e3d62d55bf455d4f9fdf2ede5c8756410c64102
s390/stack: fix possible register corruption with stack switch helper

The CALL_ON_STACK macro is used to call a C function from inline
assembly, and therefore must consider the C ABI, which says that only
registers 6-13, and 15 are non-volatile (restored by the called
function).

The inline assembly incorrectly marks all registers used to pass
parameters to the called function as read-only input operands, instead
of operands that are read and written to. This might result in
register corruption depending on usage, compiler, and compile options.

Fix this by marking all operands used to pass parameters as read/write
operands. To keep the code simple even register 6, if used, is marked
as read-write operand.

Fixes: ff340d2472ec ("s390: add stack switch helper")
Cc: <stable@kernel.org> # 4.20
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/stacktrace.h