diff options
author | Avi Kivity <avi@redhat.com> | 2011-11-10 07:57:23 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 04:24:35 -0500 |
commit | 022cd0e84020eec8b589bc119699c935c7b29584 (patch) | |
tree | 255dbe0fd7fdfb00bd23b23000d69a1a7d8144bf /arch/x86/kvm | |
parent | f5132b01386b5a67f1ff673bb2b96a507a3f7e41 (diff) |
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')
-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) | |||
760 | } | 760 | } |
761 | EXPORT_SYMBOL_GPL(kvm_get_dr); | 761 | EXPORT_SYMBOL_GPL(kvm_get_dr); |
762 | 762 | ||
763 | bool kvm_rdpmc(struct kvm_vcpu *vcpu) | ||
764 | { | ||
765 | u32 ecx = kvm_register_read(vcpu, VCPU_REGS_RCX); | ||
766 | u64 data; | ||
767 | int err; | ||
768 | |||
769 | err = kvm_pmu_read_pmc(vcpu, ecx, &data); | ||
770 | if (err) | ||
771 | return err; | ||
772 | kvm_register_write(vcpu, VCPU_REGS_RAX, (u32)data); | ||
773 | kvm_register_write(vcpu, VCPU_REGS_RDX, data >> 32); | ||
774 | return err; | ||
775 | } | ||
776 | EXPORT_SYMBOL_GPL(kvm_rdpmc); | ||
777 | |||
763 | /* | 778 | /* |
764 | * List of msr numbers which we expose to userspace through KVM_GET_MSRS | 779 | * List of msr numbers which we expose to userspace through KVM_GET_MSRS |
765 | * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. | 780 | * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. |