logger module first version

Just provide print_record() method to log informations.
logger.h and logger_main.c are the main file of the module.
mmap.c handles how to map the page in kernel out to user space.
log_util.h is a helper file.
logger_pro.c is the code of userspace program to log info into file.

Bugs:
- When unmmap(), there may be a bug warning in the kernel log, but it seems to be fine.
Second version of log module
Change the calling method from function pointer to inner module.
Now logger is a sub-module of kvm module

After insmod kvm and kvm-intel, execute load_logger.sh to add the device file.
The third version of Logger module

All the files of logger now are under arch/x86/kvm/
There are three files:
logger.h,logger.c and logger_mmap.c

No need to modify arch/x86/Kbuild
Logger is still a sub-module of kvm module
The last version of non-blocked mmap logger module

change some flags to try to fix the bad-page-map bug, but fail
First Block Mmap Version of Logger Module

add block mode: when there is not enough data to mmap, block the user program
Bug to fix: How to swap out all the log in logger? At last, maybe there is not enough data to mmap
Logger Module with TimeStamp Functionality

can be configured to add timestamp at the front of each message
Add ioctl() to logger module

ioctl(LOGGER_FLUSH) will flush the last incomplete page out by filling
it with '\0'
add the call in record_ctrl.c
Change the blocked method from mmap() to read()

Now mmap() won't be block and read() will be blocked.If there are enough data
read() just return and then hope that the userspace program will call mmap() to
read the data. Otherwise, read will be blocked.
This method fix a bug that will blcok the landscape_sys when opening a new shell
window.
Auto add /dev/logger and Fix Bad Page Map

Now logger module can add /dev/logger file automatically.
And change the map method from vm_fault to mmap() using remap_pfn_page().
Add some interface to record_ctrl.c

Signed-off-by: tanle <tamlokveer@gmail.com>
Modify record_ctrl.c.

Make record_ctrl.c to be more tidy. And now <enable> will start
logging automatically.

Signed-off-by: tanle <tamlokveer@gmail.com>
Change related printk to print_record

Change log related printk to print_record, see record_ctrl.c for
detailed interfaces.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Basic framework for A/D bit logging

This patch builds a basic framework for A/D bit logging, whichi contains:
1. Memslot based SPT walking: walk every gfn registered in KVM memslots
2. SPT based walking: walk SPT directly from EPTP (vcpu->arch.mmu.root_hpa)
3. Add an interface to control logging mode, defines kvm_record_mode, which
contains two mode: KVM_RECORD_HARDWARE_WALK_MMU and KVM_RECORD_HARDWARE_WALK_MEMSLOT,
according to 1 and 2. This interface is not propagated to userspace API. Do it in
following patches.
4. Add a compiling macro RECORD_DEBUG which controls memory access msg pringing.
Please turn off when comparing the speed of hardware and software mode currently,
because hardware mode will log some additional message. After A/D bit logging
supported, the output of these two modes are expected the same.

Besides, two hardware logging modes cannot log memory accesses out of guest memory
range, while software mode can. KVM tends to map these gfn to an illegal hpa
(e.g. 0x8000000000000000).

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Bug fix: Add a switch in sync type

Add a switch of software/hardware logging mode in sync commit type.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Add userspace interface to control kvm_record_mode and print_log

Add userspace interface for record_ctrl.c to control record mode
and the switch of print memory access log to kernel log.

See details in ./record_ctrl.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Bug Fix : kvm_record_mode confused in sync/unsync type

Fix bugs:
1. tm_walk_mmu should be off in SOFT mode
2. tm_walk_mmu should be added in PREEMPTION type
3. mmu should be zapped periodically in unsync type

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
A test patch with the correction of AD_bit

Test patch.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Remove test information and change printk to print_record

Remove test information, change message printing to print_record.

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Bug Fix: Error setting spte in memslot_walk_spt

Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
Remove printing log of UNTOUCHED spte entry

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

This patch add VMEXIT sampling when KVM_RECORD. vcpu->nr_vmexit records total VMEXIT
and vcpu->nr_sync records synchronization VMEXIT.

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