(*p)->detect() {对于KVM来说,调用是函数kvm_detect[arch\x86\kernel\kvm.c] 当detect_hypervisor_vendor返回虚拟化环境是KVM后,接下来就会拷贝kvm的一些初始化函数地址,并执行其中的init_platform,进而调用kvmclock的初始化函数,代码如下。 void__initinit_hypervisor_platform(void){h=detect_hypervisor_vendor()...
在虚拟机中输入如下命令编辑/boot/grub/menu.list,在kernel行的最后添加“no-kvmclock”,如图1所示:# vim /boot/grub/menu.lst图1 添加no-kvmclock内核参数点击放大重启虚拟机,重启后确认虚拟机使用的当前时钟源是tsc,以及可用时钟源不包括kvm-clock:# cat /sys/devices/system/clocksource/clocksource0/current_...
另一条线索向下,当guest kernel中发生写msr时,会导致wrmsr_vmexit,研究在该vmexit中,会怎样处理对应msr.可以看到,在guest启动内核时就调用了kvmclock_init(),将vcpu0的pvti结构的物理地址写入了对应msr, 并注册了将其余vcpu的pvti结构的物理地址写入对应msr的回调函数kvm_setup_secondary_clock....
LISA Patched Kernel. Contribute to lisa-project/lisa-kernel development by creating an account on GitHub.
From: Avi Kivity Wallclock writing uses an unprotected global variable to hold the version; this can cause one guest to interfere with another if both write their wallclock at the same time.
//system_time = kernel_ns + v->kvm->arch.kvmclock_offset//系统启动后的时间减去VM init的时间,即guest init后到现在的时间u64 system_time;//KVMCLOCK时钟频率固定在1GHZu32 tsc_to_system_mul;s8 tsc_shift;u8 flags;u8 pad[2];} __attribute__((__packed__)); /* 32 bytes */ struct ...