KVM: PPC: Book3S HV: Fix decrementer timeouts with non-zero TB offset
authorPaul Mackerras <paulus@samba.org>
Mon, 24 Mar 2014 23:47:07 +0000 (10:47 +1100)
committerPaul Mackerras <paulus@samba.org>
Sat, 29 Mar 2014 08:58:39 +0000 (19:58 +1100)
commitc5fb80d3b24f6280bd6f608d8f2a02139a0fabaf
tree10489a033c49027a48c20161dd23a2270244febd
parent797f9c07eb4cbc2d0ff27fac165a0b885da38840
KVM: PPC: Book3S HV: Fix decrementer timeouts with non-zero TB offset

Commit c7699822bc21 ("KVM: PPC: Book3S HV: Make physical thread 0 do
the MMU switching") reordered the guest entry/exit code so that most
of the guest register save/restore code happened in guest MMU context.
A side effect of that is that the timebase still contains the guest
timebase value at the point where we compute and use vcpu->arch.dec_expires,
and therefore that is now a guest timebase value rather than a host
timebase value.  That in turn means that the timeouts computed in
kvmppc_set_timer() are wrong if the timebase offset for the guest is
non-zero.  The consequence of that is things such as "sleep 1" in a
guest after migration may sleep for much longer than they should.

This fixes the problem by converting between guest and host timebase
values as necessary, by adding or subtracting the timebase offset.
This also fixes an incorrect comment.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Scott Wood <scottwood@freescale.com>
arch/powerpc/kvm/book3s_hv_rmhandlers.S