diff options
author | Avi Kivity <avi@redhat.com> | 2011-11-10 14:57:23 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 11:24:35 +0200 |
commit | 022cd0e84020eec8b589bc119699c935c7b29584 (patch) | |
tree | 255dbe0fd7fdfb00bd23b23000d69a1a7d8144bf /arch/x86/kvm/x86.c | |
parent | f5132b01386b5a67f1ff673bb2b96a507a3f7e41 (diff) | |
download | lwn-022cd0e84020eec8b589bc119699c935c7b29584.tar.gz lwn-022cd0e84020eec8b589bc119699c935c7b29584.zip |
KVM: Add generic RDPMC support
Add a helper function that emulates the RDPMC instruction operation.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 08ae951ecc5c..27d18b7617f3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -760,6 +760,21 @@ int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val) } EXPORT_SYMBOL_GPL(kvm_get_dr); +bool kvm_rdpmc(struct kvm_vcpu *vcpu) +{ + u32 ecx = kvm_register_read(vcpu, VCPU_REGS_RCX); + u64 data; + int err; + + err = kvm_pmu_read_pmc(vcpu, ecx, &data); + if (err) + return err; + kvm_register_write(vcpu, VCPU_REGS_RAX, (u32)data); + kvm_register_write(vcpu, VCPU_REGS_RDX, data >> 32); + return err; +} +EXPORT_SYMBOL_GPL(kvm_rdpmc); + /* * List of msr numbers which we expose to userspace through KVM_GET_MSRS * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. |