<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 21, 2016 at 5:03 AM, Paul Mackerras <span dir="ltr"><<a href="mailto:paulus@ozlabs.org" target="_blank">paulus@ozlabs.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Commit 8117ac6a6c2f ("powerpc/powernv: Switch off MMU before entering<br>
nap/sleep/rvwinkle mode", 2014-12-10) fixed a race condition where one<br>
thread entering a KVM guest could switch the MMU context to the guest<br>
while another thread was still in host kernel context with the MMU on.<br>
That commit moved the point where a thread entering a power-saving<br>
mode set its kvm_hstate.hwthread_state field in its PACA to<br>
KVM_HWTHREAD_IN_IDLE from a point where the MMU was on to after the<br>
MMU had been switched off.  That commit also added a comment<br>
explaining that we have to switch to real mode before setting<br>
hwthread_state to avoid this race.<br>
<br>
Nevertheless, commit 4eae2c9ae54a ("powerpc/powernv: Make<br>
pnv_powersave_common more generic", 2016-07-08) subsequently moved<br>
the setting of hwthread_state back to a point where the MMU is on,<br>
thus reintroducing the race, despite the comment saying that this<br>
should not be done being included in full in the context lines of<br>
the patch that did it.<br>
<br>
This fixes the race again and adds a bigger and shoutier comment<br>
explaining the potential race condition.<br>
<br>
Cc: <a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a> # v4.8<br>
Fixes: 4eae2c9ae54a<br>
Signed-off-by: Paul Mackerras <<a href="mailto:paulus@ozlabs.org">paulus@ozlabs.org</a>><br>
---<br></blockquote><div><br></div><div>Serious oversight on my part. Thanks for fixing this.</div><div><br></div><div>Reviewed-by: Shreyas B. Prabhu <<a href="mailto:shreyasbp@gmail.com">shreyasbp@gmail.com</a>></div><div><br></div><div>Thanks,</div><div>Shreyas</div></div>
</div></div>