/* SPDX-License-Identifier: MIT */1#ifndef __XEN_PUBLIC_XENPMU_H__2#define __XEN_PUBLIC_XENPMU_H__34#include "xen.h"56#define XENPMU_VER_MAJ 07#define XENPMU_VER_MIN 189/*10* ` enum neg_errnoval11* ` HYPERVISOR_xenpmu_op(enum xenpmu_op cmd, struct xenpmu_params *args);12*13* @cmd == XENPMU_* (PMU operation)14* @args == struct xenpmu_params15*/16/* ` enum xenpmu_op { */17#define XENPMU_mode_get 0 /* Also used for getting PMU version */18#define XENPMU_mode_set 119#define XENPMU_feature_get 220#define XENPMU_feature_set 321#define XENPMU_init 422#define XENPMU_finish 523#define XENPMU_lvtpc_set 624#define XENPMU_flush 72526/* ` } */2728/* Parameters structure for HYPERVISOR_xenpmu_op call */29struct xen_pmu_params {30/* IN/OUT parameters */31struct {32uint32_t maj;33uint32_t min;34} version;35uint64_t val;3637/* IN parameters */38uint32_t vcpu;39uint32_t pad;40};4142/* PMU modes:43* - XENPMU_MODE_OFF: No PMU virtualization44* - XENPMU_MODE_SELF: Guests can profile themselves45* - XENPMU_MODE_HV: Guests can profile themselves, dom0 profiles46* itself and Xen47* - XENPMU_MODE_ALL: Only dom0 has access to VPMU and it profiles48* everyone: itself, the hypervisor and the guests.49*/50#define XENPMU_MODE_OFF 051#define XENPMU_MODE_SELF (1<<0)52#define XENPMU_MODE_HV (1<<1)53#define XENPMU_MODE_ALL (1<<2)5455/*56* PMU features:57* - XENPMU_FEATURE_INTEL_BTS: Intel BTS support (ignored on AMD)58*/59#define XENPMU_FEATURE_INTEL_BTS 16061/*62* Shared PMU data between hypervisor and PV(H) domains.63*64* The hypervisor fills out this structure during PMU interrupt and sends an65* interrupt to appropriate VCPU.66* Architecture-independent fields of xen_pmu_data are WO for the hypervisor67* and RO for the guest but some fields in xen_pmu_arch can be writable68* by both the hypervisor and the guest (see arch-$arch/pmu.h).69*/70struct xen_pmu_data {71/* Interrupted VCPU */72uint32_t vcpu_id;7374/*75* Physical processor on which the interrupt occurred. On non-privileged76* guests set to vcpu_id;77*/78uint32_t pcpu_id;7980/*81* Domain that was interrupted. On non-privileged guests set to82* DOMID_SELF.83* On privileged guests can be DOMID_SELF, DOMID_XEN, or, when in84* XENPMU_MODE_ALL mode, domain ID of another domain.85*/86domid_t domain_id;8788uint8_t pad[6];8990/* Architecture-specific information */91struct xen_pmu_arch pmu;92};9394#endif /* __XEN_PUBLIC_XENPMU_H__ */959697