Add the control interface of KVM_RECORD.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add record_ctrl.c, a userspace record control program.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Synchronization vmexit of all vcpus

When vm boots to login, use ./record_ctrl enable and kvm will trap
all vcpus simultaneously. The first trapped vcpu is named MASTER,
and will send IPI to all other vcpus to trap, then release together.

NOTICE: DO NOT enable record at boot time!!!! Only one vcpu is enabled
at boot time and IPI will fail to response.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Log memory access in every quantum

Log every first read/write and first write after reads in every quantum.
Sync after every quantums and kvm->arch.mmu_valid_gen++ to flush all
mmu pages in tm_commit().

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add user designed preemption value

Now record_ctrl can design preemption value when enable record.
Remove some useless variants of preemption in struct vcpu_vmx.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Reset tm_turn when disable record

Move tm_turn from vcpu to kvm.
Reset tm_turn when disable record.
Remove some comments in tm_commit.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Fix a bug in kvm_mmu_get_page

A bug in kvm_mmu_page, when a kvm_mmu_page is allocated and re-walked by another
access, it will be ignored in for_each_gfn_sp(vcpu->kvm, sp, gfn), which should
be taken.

Remove some wired comments in __direct_map.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Redesign the code and sync mechanism in tm_commit

Redesign the sync mechanism with semaphore in tm_commit. Rewrite the codes
in tm_commit totally.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Some bugs fixed

Some bugs fixed in tm_commit.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add param "kick" to tm_commit

Add "kick" param to tm_commit. If kick=1, other vcpus in this KVM will be
kicked by calling kvm_vcpu_kick, otherwise not.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Change interfaces to call preemption timer

Change the interface to call preemption timer, prepare for new method of sync. Add a
global variant kvm_record_type to indicate the type of sync method.

Redesign the error path in tm_commit().

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add timer mode to periodically trap all vcpus

Change the entry and the interfaces of different types of recording.
Timer mode to trap all vcpus outward periodiclly.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add mmu_vcpu_valid_gen for each vcpu

Add mmu_vcpu_valid_gen for each vcpu and change is_obsolete_sp(), if the value
of vcpu->mmu_vcpu_valid_gen added, all the mmu pages related to this vcpu will
be invalic.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Optimization of the sync in tm_commit

Keep kicking off vcpus in tm_commit.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add new type unsync preemption

Add a new type of profiling: unsync preemption. This is related to
the unsync model of TM.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add type to record_ctrl interface

Redesign record_ctrl tools. Run "gcc -o record_ctrl record_ctrl.c" to compile
and "./record_ctrl" to see its usage.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>