powerpc/64s/exception: Fix machine check no-loss idle wakeup
authorNicholas Piggin <npiggin@gmail.com>
Fri, 8 May 2020 04:33:53 +0000 (14:33 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:47 +0000 (17:48 +0200)
commit8d3e40df7cef71615a51d083977ad010a0154413
treebf525298f129ca4db79f1346fee030fa6f6dc8b4
parentcabecf2cb63c9cb7fe0fbaa09a4c026ce5dfa350
powerpc/64s/exception: Fix machine check no-loss idle wakeup

[ Upstream commit 8a5054d8cbbe03c68dcb0957c291c942132e4101 ]

The architecture allows for machine check exceptions to cause idle
wakeups which resume at the 0x200 address which has to return via
the idle wakeup code, but the early machine check handler is run
first.

The case of a no state-loss sleep is broken because the early
handler uses non-volatile register r1 , which is needed for the wakeup
protocol, but it is not restored.

Fix this by loading r1 from the MCE exception frame before returning
to the idle wakeup code. Also update the comment which has become
stale since the idle rewrite in C.

This crash was found and fix confirmed with a machine check injection
test in qemu powernv model (which is not upstream in qemu yet).

Fixes: 10d91611f426d ("powerpc/64s: Reimplement book3s idle code in C")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200508043408.886394-2-npiggin@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kernel/exceptions-64s.S