Commit 1e360905 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Greg Kroah-Hartman

powerpc/64s: Fix idle wakeup potential to clobber registers

commit 6d98ce0b upstream.

We concluded there may be a window where the idle wakeup code could get
to pnv_wakeup_tb_loss() (which clobbers non-volatile GPRs), but the
hardware may set SRR1[46:47] to 01b (no state loss) which would result
in the wakeup code failing to restore non-volatile GPRs.

I was not able to trigger this condition with trivial tests on real
hardware or simulator, but the ISA (at least 2.07) seems to allow for
it, and Gautham says that it can happen if there is an exception pending
when the sleep/winkle instruction is executed.

Fixes: 17065671 ("powerpc/kvm: make hypervisor state restore a function")
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Acked-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9a9dc3ec
...@@ -439,9 +439,23 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) ...@@ -439,9 +439,23 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
_GLOBAL(pnv_wakeup_tb_loss) _GLOBAL(pnv_wakeup_tb_loss)
ld r1,PACAR1(r13) ld r1,PACAR1(r13)
/* /*
* Before entering any idle state, the NVGPRs are saved in the stack * Before entering any idle state, the NVGPRs are saved in the stack.
* and they are restored before switching to the process context. Hence * If there was a state loss, or PACA_NAPSTATELOST was set, then the
* until they are restored, they are free to be used. * NVGPRs are restored. If we are here, it is likely that state is lost,
* but not guaranteed -- neither ISA207 nor ISA300 tests to reach
* here are the same as the test to restore NVGPRS:
* PACA_THREAD_IDLE_STATE test for ISA207, PSSCR test for ISA300,
* and SRR1 test for restoring NVGPRs.
*
* We are about to clobber NVGPRs now, so set NAPSTATELOST to
* guarantee they will always be restored. This might be tightened
* with careful reading of specs (particularly for ISA300) but this
* is already a slow wakeup path and it's simpler to be safe.
*/
li r0,1
stb r0,PACA_NAPSTATELOST(r13)
/*
* *
* Save SRR1 and LR in NVGPRs as they might be clobbered in * Save SRR1 and LR in NVGPRs as they might be clobbered in
* opal_call() (called in CHECK_HMI_INTERRUPT). SRR1 is required * opal_call() (called in CHECK_HMI_INTERRUPT). SRR1 is required
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment