Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 #ifndef __XEN_PUBLIC_XENPMU_H__
0003 #define __XEN_PUBLIC_XENPMU_H__
0004 
0005 #include "xen.h"
0006 
0007 #define XENPMU_VER_MAJ    0
0008 #define XENPMU_VER_MIN    1
0009 
0010 /*
0011  * ` enum neg_errnoval
0012  * ` HYPERVISOR_xenpmu_op(enum xenpmu_op cmd, struct xenpmu_params *args);
0013  *
0014  * @cmd  == XENPMU_* (PMU operation)
0015  * @args == struct xenpmu_params
0016  */
0017 /* ` enum xenpmu_op { */
0018 #define XENPMU_mode_get        0 /* Also used for getting PMU version */
0019 #define XENPMU_mode_set        1
0020 #define XENPMU_feature_get     2
0021 #define XENPMU_feature_set     3
0022 #define XENPMU_init            4
0023 #define XENPMU_finish          5
0024 #define XENPMU_lvtpc_set       6
0025 #define XENPMU_flush           7
0026 
0027 /* ` } */
0028 
0029 /* Parameters structure for HYPERVISOR_xenpmu_op call */
0030 struct xen_pmu_params {
0031     /* IN/OUT parameters */
0032     struct {
0033         uint32_t maj;
0034         uint32_t min;
0035     } version;
0036     uint64_t val;
0037 
0038     /* IN parameters */
0039     uint32_t vcpu;
0040     uint32_t pad;
0041 };
0042 
0043 /* PMU modes:
0044  * - XENPMU_MODE_OFF:   No PMU virtualization
0045  * - XENPMU_MODE_SELF:  Guests can profile themselves
0046  * - XENPMU_MODE_HV:    Guests can profile themselves, dom0 profiles
0047  *                      itself and Xen
0048  * - XENPMU_MODE_ALL:   Only dom0 has access to VPMU and it profiles
0049  *                      everyone: itself, the hypervisor and the guests.
0050  */
0051 #define XENPMU_MODE_OFF           0
0052 #define XENPMU_MODE_SELF          (1<<0)
0053 #define XENPMU_MODE_HV            (1<<1)
0054 #define XENPMU_MODE_ALL           (1<<2)
0055 
0056 /*
0057  * PMU features:
0058  * - XENPMU_FEATURE_INTEL_BTS: Intel BTS support (ignored on AMD)
0059  */
0060 #define XENPMU_FEATURE_INTEL_BTS  1
0061 
0062 /*
0063  * Shared PMU data between hypervisor and PV(H) domains.
0064  *
0065  * The hypervisor fills out this structure during PMU interrupt and sends an
0066  * interrupt to appropriate VCPU.
0067  * Architecture-independent fields of xen_pmu_data are WO for the hypervisor
0068  * and RO for the guest but some fields in xen_pmu_arch can be writable
0069  * by both the hypervisor and the guest (see arch-$arch/pmu.h).
0070  */
0071 struct xen_pmu_data {
0072     /* Interrupted VCPU */
0073     uint32_t vcpu_id;
0074 
0075     /*
0076      * Physical processor on which the interrupt occurred. On non-privileged
0077      * guests set to vcpu_id;
0078      */
0079     uint32_t pcpu_id;
0080 
0081     /*
0082      * Domain that was interrupted. On non-privileged guests set to
0083      * DOMID_SELF.
0084      * On privileged guests can be DOMID_SELF, DOMID_XEN, or, when in
0085      * XENPMU_MODE_ALL mode, domain ID of another domain.
0086      */
0087     domid_t  domain_id;
0088 
0089     uint8_t pad[6];
0090 
0091     /* Architecture-specific information */
0092     struct xen_pmu_arch pmu;
0093 };
0094 
0095 #endif /* __XEN_PUBLIC_XENPMU_H__ */