powerpc/book3s/mce: Move add_taint() later in virtual mode
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Tue, 18 Apr 2017 16:38:17 +0000 (22:08 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 May 2017 12:30:14 +0000 (14:30 +0200)
commita86b9ecf1158b62f97587e498f336952dc9c0231
treedbaa5bf22f77c00b6077a90a512ee9a2a4e69116
parentf3ffc64bf3dd4878fe2fe36a5a30880604a441dc
powerpc/book3s/mce: Move add_taint() later in virtual mode

commit d93b0ac01a9ce276ec39644be47001873d3d183c upstream.

machine_check_early() gets called in real mode. The very first time when
add_taint() is called, it prints a warning which ends up calling opal
call (that uses OPAL_CALL wrapper) for writing it to console. If we get a
very first machine check while we are in opal we are doomed. OPAL_CALL
overwrites the PACASAVEDMSR in r13 and in this case when we are done with
MCE handling the original opal call will use this new MSR on it's way
back to opal_return. This usually leads to unexpected behaviour or the
kernel to panic. Instead move the add_taint() call later in the virtual
mode where it is safe to call.

This is broken with current FW level. We got lucky so far for not getting
very first MCE hit while in OPAL. But easily reproducible on Mambo.

Fixes: 27ea2c420cad ("powerpc: Set the correct kernel taint on machine check errors.")
Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kernel/mce.c
arch/powerpc/kernel/traps.c