blob: ca42301949b593e1ea9390e40a45c1acf8449812 [file] [log] [blame]
Boris Ostrovsky5f141542015-08-10 16:34:33 -04001#ifndef __XEN_PUBLIC_XENPMU_H__
2#define __XEN_PUBLIC_XENPMU_H__
3
4#include "xen.h"
5
6#define XENPMU_VER_MAJ 0
7#define XENPMU_VER_MIN 1
8
9/*
10 * ` enum neg_errnoval
11 * ` HYPERVISOR_xenpmu_op(enum xenpmu_op cmd, struct xenpmu_params *args);
12 *
13 * @cmd == XENPMU_* (PMU operation)
14 * @args == struct xenpmu_params
15 */
16/* ` enum xenpmu_op { */
17#define XENPMU_mode_get 0 /* Also used for getting PMU version */
18#define XENPMU_mode_set 1
19#define XENPMU_feature_get 2
20#define XENPMU_feature_set 3
21#define XENPMU_init 4
22#define XENPMU_finish 5
23
24/* ` } */
25
26/* Parameters structure for HYPERVISOR_xenpmu_op call */
27struct xen_pmu_params {
28 /* IN/OUT parameters */
29 struct {
30 uint32_t maj;
31 uint32_t min;
32 } version;
33 uint64_t val;
34
35 /* IN parameters */
36 uint32_t vcpu;
37 uint32_t pad;
38};
39
40/* PMU modes:
41 * - XENPMU_MODE_OFF: No PMU virtualization
42 * - XENPMU_MODE_SELF: Guests can profile themselves
43 * - XENPMU_MODE_HV: Guests can profile themselves, dom0 profiles
44 * itself and Xen
45 * - XENPMU_MODE_ALL: Only dom0 has access to VPMU and it profiles
46 * everyone: itself, the hypervisor and the guests.
47 */
48#define XENPMU_MODE_OFF 0
49#define XENPMU_MODE_SELF (1<<0)
50#define XENPMU_MODE_HV (1<<1)
51#define XENPMU_MODE_ALL (1<<2)
52
53/*
54 * PMU features:
55 * - XENPMU_FEATURE_INTEL_BTS: Intel BTS support (ignored on AMD)
56 */
57#define XENPMU_FEATURE_INTEL_BTS 1
58
Boris Ostrovsky65d0cf02015-08-10 16:34:34 -040059/*
60 * Shared PMU data between hypervisor and PV(H) domains.
61 *
62 * The hypervisor fills out this structure during PMU interrupt and sends an
63 * interrupt to appropriate VCPU.
64 * Architecture-independent fields of xen_pmu_data are WO for the hypervisor
65 * and RO for the guest but some fields in xen_pmu_arch can be writable
66 * by both the hypervisor and the guest (see arch-$arch/pmu.h).
67 */
68struct xen_pmu_data {
69 /* Interrupted VCPU */
70 uint32_t vcpu_id;
71
72 /*
73 * Physical processor on which the interrupt occurred. On non-privileged
74 * guests set to vcpu_id;
75 */
76 uint32_t pcpu_id;
77
78 /*
79 * Domain that was interrupted. On non-privileged guests set to
80 * DOMID_SELF.
81 * On privileged guests can be DOMID_SELF, DOMID_XEN, or, when in
82 * XENPMU_MODE_ALL mode, domain ID of another domain.
83 */
84 domid_t domain_id;
85
86 uint8_t pad[6];
87
88 /* Architecture-specific information */
89 struct xen_pmu_arch pmu;
90};
91
Boris Ostrovsky5f141542015-08-10 16:34:33 -040092#endif /* __XEN_PUBLIC_XENPMU_H__ */