Il 29/05/2014 22:44, James Hogan ha scritto:
Yes, I agree with your analysis and had considered something like this,
although it doesn't particularly appeal to my sense of perfectionism :).
I can see that. But I think the simplification of the code is worth it.
It is hard to explain why the invalid times-goes-backwards case can
happen if env->count_save_time is overwritten with data from another
machine. I think the explanation is that (due to
timers_state.cpu_ticks_enabled) the value of "cpu_get_clock_at(now) -
env->count_save_time" does not depend on get_clock(), but the code
doesn't have any comment for that.
Rather than adding comments, we might as well force it to be always zero
and just write get_clock() to COUNT_RESUME.
Finally, having to serialize env->count_save_time makes harder to
support migration from TCG to KVM and back.
It would be race free though, and if you're stopping the VM at all you
expect to lose some time anyway.
Since you mentioned perfectionism, :) your code also loses some time;
COUNT_RESUME is written based on when the CPU state becomes clean, not
on when the CPU was restarted.
Paolo