Change the logics of the synchronization before recording

Add tm_unsync_pre_record to do the synchronization before enabling record.
Move all the synchronization logic out from vmx_check_rr_commit and
tm_unsync_commit. Note that when beginning recording, we should first handle
exit, then sync, then make a checkpoint and switch into the guest at last.

Signed-off-by: Le Tan <tamlokveer@gmail.com>
Change to GFP_ATOMIC in kvm_record_memory_cow

In kvm_record_memory_cow, change the parameter of kmalloc from GFP_KERNEL to
GFP_ATOMIC, because this function will be called while holding a spinlock.
This fixes the bug that when running with too many cores the vm will crash
because of deadlock.

Signed-off-by: Le Tan <tamlokveer@gmail.com>
Add profile module and change check reason

Add profile module.
Change check reason, from every reason to only three reasons.

Signed-off-by: Chunqi Li
Bug Fix: Fix tsc bug in profiling

Fix tsc exceed bug in profiling.

Signed-off-by: Chunqi Li
Add vmexit reason profiling

Signed-off-by: Chunqi Li
Bug Fix: Reset preemption value when rollback

Move the set point of premption timer from tm_unsync_commit to vmx_check_rr_commit.
Thus both commit and rollback will reset VMX_PREEMPTION_TIMER_VALUE.

Signed-off-by: Chunqi Li
Bug Fix: Some benchmark will cause reboot

Everythin is OK if we check every vmexit. I think the reason is that if we don't check some exits,
vcpu will execute some unreasonable instructions and cause shutdown and reboot.

Since ept violation and pause instruction consumes more than 99% vmexits, we check all the other
exits except these two.

Signed-off-by: Chunqi Li
OPTIMIZATION: Check commit when a vmexit is close to preemption timeout

Doesn't have much speed up. WTF!

Signed-off-by: Chunqi Li