I am using KVM-QEMU in Intel platform. And I am wondering how is the PMC/PMU being virtualized in KVM?
My understanding of vPMC is as follows.
Since PMU is a shared physical resource, so hypervisor shall context save/restore PMC configurations and counters during VMExit/VMEnter.
But in my testing, I got confused.
(In my host Linux, the MSR of IA32_PERF_FIXed_CTRL is set to 0xb0)
First of all, in a launched VM,
I 'wrmsr IA32_PERF_FIXed_CTRL 0x0b
', to enable FIXed_CTR0
in VM.
Then, I logged the MSR of IA32_PERF_FIXed_CTRL at VMExit, and found FIXed_CTR0 is not enabled.
I think it is because when VMExit happens, it is already in the host context, so the MSR of IA32_PERF_FIXed_CTRL is the one of host, not the host.
But the question is where is that MSR for the VM being saved in host, and when and where the VM's MSR is being restored to CPU during VMEnter???
Hope my question is clear.
Thanks,