I'm trying to more or less accurately determine for how many CPU cycles a function in a program running under QEMU (x86_64) (with the -enable-kvm
flag set if that matters) executes for.
Following the instructions in this Intel white paper, it seems that in order to get the most accurate readings I need to use some combination of the rdtsc
, rdtscp
and cpuid
instructions.
There are two issues with this:
On my host machine (also x86_64), the
rdtscp
instruction is supported but under QEMU it's not. I have failed to find information on this, is this feature generally absent under QEMU?It seems that both
rdtsc
andrdtscp
might cause VM exists, interfering with the accuracy of my measurements. How can I tell whether this is the case and is there a way I can prevent it?