s390/nmi: rework register validation handling
authorHeiko Carstens <hca@linux.ibm.com>
Sun, 27 Nov 2022 08:45:26 +0000 (09:45 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 6 Dec 2022 15:18:23 +0000 (16:18 +0100)
commitf9e5938ace2cc8ecf15815649481266017135757
tree0a5166afe0ff59439a125436b43a8a30426a9b5b
parent5720aab289e138463bb499a42681c1c526030756
s390/nmi: rework register validation handling

If a machine check happens in kernel mode, and the machine check
interruption code indicates that e.g. vector register contents in the
machine check area are not valid, the logic is to kill current.

The idea behind this was that if within kernel context vector
registers are not used then it is sufficient to kill the current user
space process to avoid that it continues with potentially corrupt
register contents. This however does not necessarily work, since the
current code does not take into account that a machine check can also
happen when a kernel thread is running (= no user space context), and
in addition there is no way to distinguish between the "previous" and
"next" user process task, if the machine check happens when a task
switch happens.

Given that machine checks with invalid saved register contents in the
machine check save area are extremely rare, simplify the logic: if
register contents are invalid and the previous context was kernel
mode, stop the whole machine. If the previous context was user mode,
kill the corresponding task.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/kernel/nmi.c