trace.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /******************************************************************************
  2. * include/public/trace.h
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to
  6. * deal in the Software without restriction, including without limitation the
  7. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. * sell copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. *
  22. * Mark Williamson, (C) 2004 Intel Research Cambridge
  23. * Copyright (C) 2005 Bin Ren
  24. */
  25. #ifndef __XEN_PUBLIC_TRACE_H__
  26. #define __XEN_PUBLIC_TRACE_H__
  27. #define TRACE_EXTRA_MAX 7
  28. #define TRACE_EXTRA_SHIFT 28
  29. /* Trace classes */
  30. #define TRC_CLS_SHIFT 16
  31. #define TRC_GEN 0x0001f000 /* General trace */
  32. #define TRC_SCHED 0x0002f000 /* Xen Scheduler trace */
  33. #define TRC_DOM0OP 0x0004f000 /* Xen DOM0 operation trace */
  34. #define TRC_HVM 0x0008f000 /* Xen HVM trace */
  35. #define TRC_MEM 0x0010f000 /* Xen memory trace */
  36. #define TRC_PV 0x0020f000 /* Xen PV traces */
  37. #define TRC_SHADOW 0x0040f000 /* Xen shadow tracing */
  38. #define TRC_PM 0x0080f000 /* Xen power management trace */
  39. #define TRC_ALL 0x0ffff000
  40. #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff)
  41. #define TRC_HD_CYCLE_FLAG (1UL<<31)
  42. #define TRC_HD_INCLUDES_CYCLE_COUNT(x) ( !!( (x) & TRC_HD_CYCLE_FLAG ) )
  43. #define TRC_HD_EXTRA(x) (((x)>>TRACE_EXTRA_SHIFT)&TRACE_EXTRA_MAX)
  44. /* Trace subclasses */
  45. #define TRC_SUBCLS_SHIFT 12
  46. /* trace subclasses for SVM */
  47. #define TRC_HVM_ENTRYEXIT 0x00081000 /* VMENTRY and #VMEXIT */
  48. #define TRC_HVM_HANDLER 0x00082000 /* various HVM handlers */
  49. #define TRC_SCHED_MIN 0x00021000 /* Just runstate changes */
  50. #define TRC_SCHED_VERBOSE 0x00028000 /* More inclusive scheduling */
  51. /* Trace events per class */
  52. #define TRC_LOST_RECORDS (TRC_GEN + 1)
  53. #define TRC_TRACE_WRAP_BUFFER (TRC_GEN + 2)
  54. #define TRC_TRACE_CPU_CHANGE (TRC_GEN + 3)
  55. #define TRC_SCHED_RUNSTATE_CHANGE (TRC_SCHED_MIN + 1)
  56. #define TRC_SCHED_DOM_ADD (TRC_SCHED_VERBOSE + 1)
  57. #define TRC_SCHED_DOM_REM (TRC_SCHED_VERBOSE + 2)
  58. #define TRC_SCHED_SLEEP (TRC_SCHED_VERBOSE + 3)
  59. #define TRC_SCHED_WAKE (TRC_SCHED_VERBOSE + 4)
  60. #define TRC_SCHED_YIELD (TRC_SCHED_VERBOSE + 5)
  61. #define TRC_SCHED_BLOCK (TRC_SCHED_VERBOSE + 6)
  62. #define TRC_SCHED_SHUTDOWN (TRC_SCHED_VERBOSE + 7)
  63. #define TRC_SCHED_CTL (TRC_SCHED_VERBOSE + 8)
  64. #define TRC_SCHED_ADJDOM (TRC_SCHED_VERBOSE + 9)
  65. #define TRC_SCHED_SWITCH (TRC_SCHED_VERBOSE + 10)
  66. #define TRC_SCHED_S_TIMER_FN (TRC_SCHED_VERBOSE + 11)
  67. #define TRC_SCHED_T_TIMER_FN (TRC_SCHED_VERBOSE + 12)
  68. #define TRC_SCHED_DOM_TIMER_FN (TRC_SCHED_VERBOSE + 13)
  69. #define TRC_SCHED_SWITCH_INFPREV (TRC_SCHED_VERBOSE + 14)
  70. #define TRC_SCHED_SWITCH_INFNEXT (TRC_SCHED_VERBOSE + 15)
  71. #define TRC_MEM_PAGE_GRANT_MAP (TRC_MEM + 1)
  72. #define TRC_MEM_PAGE_GRANT_UNMAP (TRC_MEM + 2)
  73. #define TRC_MEM_PAGE_GRANT_TRANSFER (TRC_MEM + 3)
  74. #define TRC_PV_HYPERCALL (TRC_PV + 1)
  75. #define TRC_PV_TRAP (TRC_PV + 3)
  76. #define TRC_PV_PAGE_FAULT (TRC_PV + 4)
  77. #define TRC_PV_FORCED_INVALID_OP (TRC_PV + 5)
  78. #define TRC_PV_EMULATE_PRIVOP (TRC_PV + 6)
  79. #define TRC_PV_EMULATE_4GB (TRC_PV + 7)
  80. #define TRC_PV_MATH_STATE_RESTORE (TRC_PV + 8)
  81. #define TRC_PV_PAGING_FIXUP (TRC_PV + 9)
  82. #define TRC_PV_GDT_LDT_MAPPING_FAULT (TRC_PV + 10)
  83. #define TRC_PV_PTWR_EMULATION (TRC_PV + 11)
  84. #define TRC_PV_PTWR_EMULATION_PAE (TRC_PV + 12)
  85. /* Indicates that addresses in trace record are 64 bits */
  86. #define TRC_64_FLAG (0x100)
  87. #define TRC_SHADOW_NOT_SHADOW (TRC_SHADOW + 1)
  88. #define TRC_SHADOW_FAST_PROPAGATE (TRC_SHADOW + 2)
  89. #define TRC_SHADOW_FAST_MMIO (TRC_SHADOW + 3)
  90. #define TRC_SHADOW_FALSE_FAST_PATH (TRC_SHADOW + 4)
  91. #define TRC_SHADOW_MMIO (TRC_SHADOW + 5)
  92. #define TRC_SHADOW_FIXUP (TRC_SHADOW + 6)
  93. #define TRC_SHADOW_DOMF_DYING (TRC_SHADOW + 7)
  94. #define TRC_SHADOW_EMULATE (TRC_SHADOW + 8)
  95. #define TRC_SHADOW_EMULATE_UNSHADOW_USER (TRC_SHADOW + 9)
  96. #define TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ (TRC_SHADOW + 10)
  97. #define TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED (TRC_SHADOW + 11)
  98. #define TRC_SHADOW_WRMAP_BF (TRC_SHADOW + 12)
  99. #define TRC_SHADOW_PREALLOC_UNPIN (TRC_SHADOW + 13)
  100. #define TRC_SHADOW_RESYNC_FULL (TRC_SHADOW + 14)
  101. #define TRC_SHADOW_RESYNC_ONLY (TRC_SHADOW + 15)
  102. /* trace events per subclass */
  103. #define TRC_HVM_VMENTRY (TRC_HVM_ENTRYEXIT + 0x01)
  104. #define TRC_HVM_VMEXIT (TRC_HVM_ENTRYEXIT + 0x02)
  105. #define TRC_HVM_VMEXIT64 (TRC_HVM_ENTRYEXIT + TRC_64_FLAG + 0x02)
  106. #define TRC_HVM_PF_XEN (TRC_HVM_HANDLER + 0x01)
  107. #define TRC_HVM_PF_XEN64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x01)
  108. #define TRC_HVM_PF_INJECT (TRC_HVM_HANDLER + 0x02)
  109. #define TRC_HVM_PF_INJECT64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x02)
  110. #define TRC_HVM_INJ_EXC (TRC_HVM_HANDLER + 0x03)
  111. #define TRC_HVM_INJ_VIRQ (TRC_HVM_HANDLER + 0x04)
  112. #define TRC_HVM_REINJ_VIRQ (TRC_HVM_HANDLER + 0x05)
  113. #define TRC_HVM_IO_READ (TRC_HVM_HANDLER + 0x06)
  114. #define TRC_HVM_IO_WRITE (TRC_HVM_HANDLER + 0x07)
  115. #define TRC_HVM_CR_READ (TRC_HVM_HANDLER + 0x08)
  116. #define TRC_HVM_CR_READ64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x08)
  117. #define TRC_HVM_CR_WRITE (TRC_HVM_HANDLER + 0x09)
  118. #define TRC_HVM_CR_WRITE64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x09)
  119. #define TRC_HVM_DR_READ (TRC_HVM_HANDLER + 0x0A)
  120. #define TRC_HVM_DR_WRITE (TRC_HVM_HANDLER + 0x0B)
  121. #define TRC_HVM_MSR_READ (TRC_HVM_HANDLER + 0x0C)
  122. #define TRC_HVM_MSR_WRITE (TRC_HVM_HANDLER + 0x0D)
  123. #define TRC_HVM_CPUID (TRC_HVM_HANDLER + 0x0E)
  124. #define TRC_HVM_INTR (TRC_HVM_HANDLER + 0x0F)
  125. #define TRC_HVM_NMI (TRC_HVM_HANDLER + 0x10)
  126. #define TRC_HVM_SMI (TRC_HVM_HANDLER + 0x11)
  127. #define TRC_HVM_VMMCALL (TRC_HVM_HANDLER + 0x12)
  128. #define TRC_HVM_HLT (TRC_HVM_HANDLER + 0x13)
  129. #define TRC_HVM_INVLPG (TRC_HVM_HANDLER + 0x14)
  130. #define TRC_HVM_INVLPG64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x14)
  131. #define TRC_HVM_MCE (TRC_HVM_HANDLER + 0x15)
  132. #define TRC_HVM_IO_ASSIST (TRC_HVM_HANDLER + 0x16)
  133. #define TRC_HVM_IO_ASSIST64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x16)
  134. #define TRC_HVM_MMIO_ASSIST (TRC_HVM_HANDLER + 0x17)
  135. #define TRC_HVM_MMIO_ASSIST64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x17)
  136. #define TRC_HVM_CLTS (TRC_HVM_HANDLER + 0x18)
  137. #define TRC_HVM_LMSW (TRC_HVM_HANDLER + 0x19)
  138. #define TRC_HVM_LMSW64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x19)
  139. /* trace subclasses for power management */
  140. #define TRC_PM_FREQ 0x00801000 /* xen cpu freq events */
  141. #define TRC_PM_IDLE 0x00802000 /* xen cpu idle events */
  142. /* trace events for per class */
  143. #define TRC_PM_FREQ_CHANGE (TRC_PM_FREQ + 0x01)
  144. #define TRC_PM_IDLE_ENTRY (TRC_PM_IDLE + 0x01)
  145. #define TRC_PM_IDLE_EXIT (TRC_PM_IDLE + 0x02)
  146. /* This structure represents a single trace buffer record. */
  147. struct t_rec {
  148. uint32_t event:28;
  149. uint32_t extra_u32:3; /* # entries in trailing extra_u32[] array */
  150. uint32_t cycles_included:1; /* u.cycles or u.no_cycles? */
  151. union {
  152. struct {
  153. uint32_t cycles_lo, cycles_hi; /* cycle counter timestamp */
  154. uint32_t extra_u32[7]; /* event data items */
  155. } cycles;
  156. struct {
  157. uint32_t extra_u32[7]; /* event data items */
  158. } nocycles;
  159. } u;
  160. };
  161. /*
  162. * This structure contains the metadata for a single trace buffer. The head
  163. * field, indexes into an array of struct t_rec's.
  164. */
  165. struct t_buf {
  166. /* Assume the data buffer size is X. X is generally not a power of 2.
  167. * CONS and PROD are incremented modulo (2*X):
  168. * 0 <= cons < 2*X
  169. * 0 <= prod < 2*X
  170. * This is done because addition modulo X breaks at 2^32 when X is not a
  171. * power of 2:
  172. * (((2^32 - 1) % X) + 1) % X != (2^32) % X
  173. */
  174. uint32_t cons; /* Offset of next item to be consumed by control tools. */
  175. uint32_t prod; /* Offset of next item to be produced by Xen. */
  176. /* Records follow immediately after the meta-data header. */
  177. };
  178. #endif /* __XEN_PUBLIC_TRACE_H__ */
  179. /*
  180. * Local variables:
  181. * mode: C
  182. * c-set-style: "BSD"
  183. * c-basic-offset: 4
  184. * tab-width: 4
  185. * indent-tabs-mode: nil
  186. * End:
  187. */
  188. */