s390/mem_detect: fix tprot() program check new psw handling
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 14 Jun 2021 20:09:20 +0000 (22:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:05:44 +0000 (16:05 +0200)
commita50b56ffc0c88c15dacab89cf72a1ce912bdfe6e
tree1ea5303abfb6808c594346ffba5aac12796fd5ef
parent7e1e0235b3db32b190dc7b47434587075580caff
s390/mem_detect: fix tprot() program check new psw handling

[ Upstream commit da9057576785aaab52e706e76c0475c85b77ec14 ]

The tprot() inline asm temporarily changes the program check new psw
to redirect a potential program check on the diag instruction.
Restoring of the program check new psw is done in C code behind the
inline asm.

This can be problematic, especially if the function is inlined, since
the compiler can reorder instructions in such a way that a different
instruction, which may result in a program check, might be executed
before the program check new psw has been restored.

To avoid such a scenario move restoring into the inline asm. For
consistency reasons move also saving of the original program check new
psw into the inline asm.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/s390/boot/mem_detect.c