]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/x86/kvm/pmu_amd.c
KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch
[mirror_ubuntu-artful-kernel.git] / arch / x86 / kvm / pmu_amd.c
1 /*
2 * KVM PMU support for AMD
3 *
4 * Copyright 2015, Red Hat, Inc. and/or its affiliates.
5 *
6 * Author:
7 * Wei Huang <wei@redhat.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 * Implementation is based on pmu_intel.c file
13 */
14 #include <linux/types.h>
15 #include <linux/kvm_host.h>
16 #include <linux/perf_event.h>
17 #include "x86.h"
18 #include "cpuid.h"
19 #include "lapic.h"
20 #include "pmu.h"
21
22 static unsigned amd_find_arch_event(struct kvm_pmu *pmu,
23 u8 event_select,
24 u8 unit_mask)
25 {
26 return PERF_COUNT_HW_MAX;
27 }
28
29 /* return PERF_COUNT_HW_MAX as AMD doesn't have fixed events */
30 static unsigned amd_find_fixed_event(int idx)
31 {
32 return PERF_COUNT_HW_MAX;
33 }
34
35 static bool amd_pmc_is_enabled(struct kvm_pmc *pmc)
36 {
37 return false;
38 }
39
40 static struct kvm_pmc *amd_pmc_idx_to_pmc(struct kvm_pmu *pmu, int pmc_idx)
41 {
42 return NULL;
43 }
44
45 /* returns 0 if idx's corresponding MSR exists; otherwise returns 1. */
46 static int amd_is_valid_msr_idx(struct kvm_vcpu *vcpu, unsigned idx)
47 {
48 return 1;
49 }
50
51 /* idx is the ECX register of RDPMC instruction */
52 static struct kvm_pmc *amd_msr_idx_to_pmc(struct kvm_vcpu *vcpu, unsigned idx)
53 {
54 return NULL;
55 }
56
57 static bool amd_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr)
58 {
59 return false;
60 }
61
62 static int amd_pmu_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *data)
63 {
64 return 1;
65 }
66
67 static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
68 {
69 return 1;
70 }
71
72 static void amd_pmu_refresh(struct kvm_vcpu *vcpu)
73 {
74 }
75
76 static void amd_pmu_init(struct kvm_vcpu *vcpu)
77 {
78 }
79
80 static void amd_pmu_reset(struct kvm_vcpu *vcpu)
81 {
82 }
83
84 struct kvm_pmu_ops amd_pmu_ops = {
85 .find_arch_event = amd_find_arch_event,
86 .find_fixed_event = amd_find_fixed_event,
87 .pmc_is_enabled = amd_pmc_is_enabled,
88 .pmc_idx_to_pmc = amd_pmc_idx_to_pmc,
89 .msr_idx_to_pmc = amd_msr_idx_to_pmc,
90 .is_valid_msr_idx = amd_is_valid_msr_idx,
91 .is_valid_msr = amd_is_valid_msr,
92 .get_msr = amd_pmu_get_msr,
93 .set_msr = amd_pmu_set_msr,
94 .refresh = amd_pmu_refresh,
95 .init = amd_pmu_init,
96 .reset = amd_pmu_reset,
97 };