Hello all,
After a lot of digging, I am back after haveing discovered what was wrong with my initial code to get the performance monitoring interrupt (PMI) fired on qemu-kvm.
I decided to post it here for it may help others.
To recall the problem, I was not able to catch the PMI in my guest when it runs on qemu (kvm-enabled, cpu = host) whereas it works fine on a real machine.
Linuxyne gave us a similar code that works fine both on qemu and on real machine. So I was a bit confuse; why I was not able to catch the PMI with my former code if they were similar.
After some digging, it happens that, when running on qemu, to get the PMI works, you have to set the counter's initial value (MSR_PERF_FIXED_CTR0: 0x38d) before setting the instruction counting mode (MSR_PERF_FIXED_CTRL: 0x309). Whereas on the real machine, the order does not matter (As far as I know).
Can anyone confirm this? Is this a well desired behaviour?
However, there is another problem concerning getting multiple PMIs, but I shall detail this in another thread.
Conclusion : This code worksQuote:
; set counter value.
mov edx, 0xffff
mov eax, 0xffff0000
mov ecx, 0x309
wrmsr
; set counting mode
xor edx, edx
mov eax, 0xa
mov ecx, 0x38d
wrmsr
whereas this one does notQuote:
; set counting mode
xor edx, edx
mov eax, 0xa
mov ecx, 0x38d
wrmsr
; set counter value.
mov edx, 0xffff
mov eax, 0xffff0000
mov ecx, 0x309
wrmsr