2 * Permission is hereby granted, free of charge, to any person obtaining a copy
3 * of this software and associated documentation files (the "Software"), to
4 * deal in the Software without restriction, including without limitation the
5 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6 * sell copies of the Software, and to permit persons to whom the Software is
7 * furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
20 * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
23 #ifndef __XEN_PUBLIC_PMU_H__
24 #define __XEN_PUBLIC_PMU_H__
27 #if defined(__i386__) || defined(__x86_64__)
28 #include "arch-x86/pmu.h"
29 #elif defined (__arm__) || defined (__aarch64__)
32 #error "Unsupported architecture"
35 #define XENPMU_VER_MAJ 0
36 #define XENPMU_VER_MIN 1
40 * ` HYPERVISOR_xenpmu_op(enum xenpmu_op cmd, struct xenpmu_params *args);
42 * @cmd == XENPMU_* (PMU operation)
43 * @args == struct xenpmu_params
45 /* ` enum xenpmu_op { */
46 #define XENPMU_mode_get 0 /* Also used for getting PMU version */
47 #define XENPMU_mode_set 1
48 #define XENPMU_feature_get 2
49 #define XENPMU_feature_set 3
51 #define XENPMU_finish 5
52 #define XENPMU_lvtpc_set 6
53 #define XENPMU_flush 7 /* Write cached MSR values to HW */
56 /* Parameters structure for HYPERVISOR_xenpmu_op call */
57 struct xen_pmu_params {
58 /* IN/OUT parameters */
69 typedef struct xen_pmu_params xen_pmu_params_t;
70 DEFINE_XEN_GUEST_HANDLE(xen_pmu_params_t);
73 * - XENPMU_MODE_OFF: No PMU virtualization
74 * - XENPMU_MODE_SELF: Guests can profile themselves
75 * - XENPMU_MODE_HV: Guests can profile themselves, dom0 profiles
77 * - XENPMU_MODE_ALL: Only dom0 has access to VPMU and it profiles
78 * everyone: itself, the hypervisor and the guests.
80 #define XENPMU_MODE_OFF 0
81 #define XENPMU_MODE_SELF (1<<0)
82 #define XENPMU_MODE_HV (1<<1)
83 #define XENPMU_MODE_ALL (1<<2)
87 * - XENPMU_FEATURE_INTEL_BTS: Intel BTS support (ignored on AMD)
89 #define XENPMU_FEATURE_INTEL_BTS 1
92 * Shared PMU data between hypervisor and PV(H) domains.
94 * The hypervisor fills out this structure during PMU interrupt and sends an
95 * interrupt to appropriate VCPU.
96 * Architecture-independent fields of xen_pmu_data are WO for the hypervisor
97 * and RO for the guest but some fields in xen_pmu_arch can be writable
98 * by both the hypervisor and the guest (see arch-$arch/pmu.h).
100 struct xen_pmu_data {
101 /* Interrupted VCPU */
105 * Physical processor on which the interrupt occurred. On non-privileged
106 * guests set to vcpu_id;
111 * Domain that was interrupted. On non-privileged guests set to DOMID_SELF.
112 * On privileged guests can be DOMID_SELF, DOMID_XEN, or, when in
113 * XENPMU_MODE_ALL mode, domain ID of another domain.
119 /* Architecture-specific information */
120 struct xen_pmu_arch pmu;
123 #endif /* __XEN_PUBLIC_PMU_H__ */
128 * c-file-style: "BSD"
131 * indent-tabs-mode: nil