Re: Regarding TSC scaling in a KVM environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 13, 2022 at 11:43:20AM +0530, Arnabjyoti Kalita wrote:
> Dear all,
> 
> How do I know if TSC scaling is being done when a VM is running in KVM
> mode? If TSC scaling is being done, how do I calculate the multiplier
> that needs to be added to host TSC to get guest TSC?

You can check vmx_write_tsc_offset/vmx_write_tsc_multiplier, and then
follow Intel SDM to calculate guest TSC:

(Guest) RDTSC first computes the product of the value of the (Host)
IA32_TIME_STAMP_COUNTER MSR and the value of the TSC multiplier. It
then shifts the value of the product right 48 bits and loads EAX:EDX
with the sum of that shifted value and the value of the TSC offset.

> 
> For more context, I am running IntelPT and collecting Intel PT traces
> when a VM Is running in KVM mode and I see that the TSC values differ
> by a multiplier when the VM is running in root mode (between a vmexit
> and next vmentry) vs non-root mode (between a vmentry and next
> vmexit). I use QEMU - 5.2.0 to run a guest and I use an Intel
> Kaby-Lake microarchitecture.
> 
> For e.g. The first TSC packet that I get from Intel PT when guest is
> in root mode is 0xb24d498c651
> while the first TSC packet that I get from Intel PT when guest is in
> non-root mode is 0x4b41048e77.

TSC value in Intel PT packet in non-root mode follows the same
calculation above.

Chao
> 
> Best Regards,
> Arnabjyoti Kalita



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux