]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/64: Re-fix race condition between going idle and entering guest
authorPaul Mackerras <paulus@ozlabs.org>
Fri, 21 Oct 2016 09:03:05 +0000 (20:03 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 24 Oct 2016 08:29:36 +0000 (19:29 +1100)
commitc4df832cfcdf3ddb12f53e629ca06f488bc22fe7
treeeaf5e055eaea82bbb34a947e6c072bca764c9a37
parent34f07b03cfdd072292f00828c4104d3eecb9553c
powerpc/64: Re-fix race condition between going idle and entering guest

Commit cb93d611c9b5 ("powerpc/powernv: Switch off MMU before entering
nap/sleep/rvwinkle mode", 2014-12-10) fixed a race condition where one
thread entering a KVM guest could switch the MMU context to the guest
while another thread was still in host kernel context with the MMU on.
That commit moved the point where a thread entering a power-saving
mode set its kvm_hstate.hwthread_state field in its PACA to
KVM_HWTHREAD_IN_IDLE from a point where the MMU was on to after the
MMU had been switched off.  That commit also added a comment
explaining that we have to switch to real mode before setting
hwthread_state to avoid this race.

Nevertheless, commit b991d1cce4f7 ("powerpc/powernv: Make
pnv_powersave_common more generic", 2016-07-08) subsequently moved
the setting of hwthread_state back to a point where the MMU is on,
thus reintroducing the race, despite the comment saying that this
should not be done being included in full in the context lines of
the patch that did it.

This fixes the race again and adds a bigger and shoutier comment
explaining the potential race condition.

Fixes: b991d1cce4f7 ("powerpc/powernv: Make pnv_powersave_common more generic")
Cc: stable@vger.kernel.org # v4.8+
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Reviewed-by: Shreyas B. Prabhu <shreyasbp@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/idle_book3s.S