Reputation: 21
I am a newbie trying to make sense of how MSR emulation works in QEMU/KVM. I am trying to add support for my own MSR in the guest machine, without involving the actual host MSR, hence, I need emulation. Currently, trying to access this MSR from the guest kernel results in a #GP exception (cuz its not supported).
My goal is to be able to intercept the access to this MSR in KVM (or perhaps QEMU), then redirect it to simply reading/writing freely to an emulated MSR (without really affecting the guest for now), then return the result to the guest.
The problem is that I can't find where in the KVM source code the guest's rdmsr/wrmsr instructions are intercepted and handled. Also, how does KVM differentiate between MSRs that are going to be emulated or virtualized? Thanks!
[EDIT]: I found what seems to be KVM MSR interception in this file:
In functions vmx_get_msr()
/ vmx_set_msr()
.
Upvotes: 2
Views: 40