xenpmu.h 2.4 KB

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