So, the problem is cause by stop_vm(RUN_STATE_PAUSED), in this case the env->tsc is not updated, which lead to the issue. Is that right?
I think so.
If the cpu_clean_all_dirty() is needed just for the APIC status reason, I think we can do the cpu_synchronize_all_states() in do_vm_stop and after vm_state_notify() when the RUN_STATE_PAUSED is hit, at this point all the device models is stopped, there is no outdated APIC status.
Yes, cpu_clean_all_dirty() was needed because without it, the second call to cpu_synchronize_all_states() (which is done inside qemu_savevm_state_complete() and after kvmclock) does nothing.
I want to write a patch to fix this issue in another way, could help to verify it in you environment, very appreciate if you could.
Sure, I'll test it. Both issues were quite easy to reproduce. -- mg