xenpmu.h 2.5 KB

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