On 12/14/2015 07:09 PM, Paolo Bonzini wrote:


On 14/12/2015 16:33, Andrey Smetanin wrote:
It's possible that guest send us Hyper-V EOM at the middle
of Hyper-V SynIC timer running, so we start processing of Hyper-V
SynIC timers in vcpu context and stop the Hyper-V SynIC timer
uncoditionally and lose time expiration which Windows 2012R2 guest
expects.

The patch fixes such situation by not stopping Hyper-V SynIC timer
at all, because it's safe to restart it without stop in vcpu context
and timer callback always returns HRTIMER_NORESTART.

Can you summarize with a "picture" what is the bad race?
host                                    guest
                                        start periodic stimer
start periodic timer
timer expires after 15ms
send expiration message into guest
restart periodic timer
                                        ....doing something....
timer expires again after 15 ms
msg slot is still not cleared so
setup ->msg_pending
restart periodic timer
                                        ....doing something....
                                        process timer msg and clear slot
                                        so ->msg_pending was set:
                                                send EOM into host
received EOM
queued call of kvm_hv_process_stimers()
by KVM_REQ_HV_STIMER

kvm_hv_process_stimers():
        ...
        stimer_stop()
        if (time_now >= stimer->exp_time)
                stimer_expiration(stimer);
But time_now  < stimer->exp_time, so stimer_expiration is not called
in this case and timer is not restarted. so guest lose timer.

The patch seems safe, but I'd like to have a better understanding of
what goes wrong.

Paolo


Reply via email to