I know we can use wrmsr
and rdmsr
instruction to set the performance counter and read the general purpose performance counter register.
However, my question is:
Do we need to reset the general purpose performance counter register before we issue the wrmsr
?
In other words, for the following code, do we need to reset the performance counter before the following code? If we have to, how can we reset it?
mov $0x0001010E, %eax # Write selector value to EAX
xor %edx, %edx # Zero EDX
mov $0x187, %ecx # Write logical register id to ECX (IA32_PERFEVTSEL1)
wrmsr