kvm.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
  2. #define _TRACE_KVM_MAIN_H
  3. #include <linux/tracepoint.h>
  4. #undef TRACE_SYSTEM
  5. #define TRACE_SYSTEM kvm
  6. #define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
  7. #define kvm_trace_exit_reason \
  8. ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL), \
  9. ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN), \
  10. ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR), \
  11. ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
  12. ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI)
  13. TRACE_EVENT(kvm_userspace_exit,
  14. TP_PROTO(__u32 reason, int errno),
  15. TP_ARGS(reason, errno),
  16. TP_STRUCT__entry(
  17. __field( __u32, reason )
  18. __field( int, errno )
  19. ),
  20. TP_fast_assign(
  21. __entry->reason = reason;
  22. __entry->errno = errno;
  23. ),
  24. TP_printk("reason %s (%d)",
  25. __entry->errno < 0 ?
  26. (__entry->errno == -EINTR ? "restart" : "error") :
  27. __print_symbolic(__entry->reason, kvm_trace_exit_reason),
  28. __entry->errno < 0 ? -__entry->errno : __entry->reason)
  29. );
  30. #if defined(__KVM_HAVE_IOAPIC)
  31. TRACE_EVENT(kvm_set_irq,
  32. TP_PROTO(unsigned int gsi, int level, int irq_source_id),
  33. TP_ARGS(gsi, level, irq_source_id),
  34. TP_STRUCT__entry(
  35. __field( unsigned int, gsi )
  36. __field( int, level )
  37. __field( int, irq_source_id )
  38. ),
  39. TP_fast_assign(
  40. __entry->gsi = gsi;
  41. __entry->level = level;
  42. __entry->irq_source_id = irq_source_id;
  43. ),
  44. TP_printk("gsi %u level %d source %d",
  45. __entry->gsi, __entry->level, __entry->irq_source_id)
  46. );
  47. #define kvm_deliver_mode \
  48. {0x0, "Fixed"}, \
  49. {0x1, "LowPrio"}, \
  50. {0x2, "SMI"}, \
  51. {0x3, "Res3"}, \
  52. {0x4, "NMI"}, \
  53. {0x5, "INIT"}, \
  54. {0x6, "SIPI"}, \
  55. {0x7, "ExtINT"}
  56. TRACE_EVENT(kvm_ioapic_set_irq,
  57. TP_PROTO(__u64 e, int pin, bool coalesced),
  58. TP_ARGS(e, pin, coalesced),
  59. TP_STRUCT__entry(
  60. __field( __u64, e )
  61. __field( int, pin )
  62. __field( bool, coalesced )
  63. ),
  64. TP_fast_assign(
  65. __entry->e = e;
  66. __entry->pin = pin;
  67. __entry->coalesced = coalesced;
  68. ),
  69. TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
  70. __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e,
  71. __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode),
  72. (__entry->e & (1<<11)) ? "logical" : "physical",
  73. (__entry->e & (1<<15)) ? "level" : "edge",
  74. (__entry->e & (1<<16)) ? "|masked" : "",
  75. __entry->coalesced ? " (coalesced)" : "")
  76. );
  77. TRACE_EVENT(kvm_msi_set_irq,
  78. TP_PROTO(__u64 address, __u64 data),
  79. TP_ARGS(address, data),
  80. TP_STRUCT__entry(
  81. __field( __u64, address )
  82. __field( __u64, data )
  83. ),
  84. TP_fast_assign(
  85. __entry->address = address;
  86. __entry->data = data;
  87. ),
  88. TP_printk("dst %u vec %x (%s|%s|%s%s)",
  89. (u8)(__entry->address >> 12), (u8)__entry->data,
  90. __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode),
  91. (__entry->address & (1<<2)) ? "logical" : "physical",
  92. (__entry->data & (1<<15)) ? "level" : "edge",
  93. (__entry->address & (1<<3)) ? "|rh" : "")
  94. );
  95. #define kvm_irqchips \
  96. {KVM_IRQCHIP_PIC_MASTER, "PIC master"}, \
  97. {KVM_IRQCHIP_PIC_SLAVE, "PIC slave"}, \
  98. {KVM_IRQCHIP_IOAPIC, "IOAPIC"}
  99. TRACE_EVENT(kvm_ack_irq,
  100. TP_PROTO(unsigned int irqchip, unsigned int pin),
  101. TP_ARGS(irqchip, pin),
  102. TP_STRUCT__entry(
  103. __field( unsigned int, irqchip )
  104. __field( unsigned int, pin )
  105. ),
  106. TP_fast_assign(
  107. __entry->irqchip = irqchip;
  108. __entry->pin = pin;
  109. ),
  110. TP_printk("irqchip %s pin %u",
  111. __print_symbolic(__entry->irqchip, kvm_irqchips),
  112. __entry->pin)
  113. );
  114. #endif /* defined(__KVM_HAVE_IOAPIC) */
  115. #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
  116. #define KVM_TRACE_MMIO_READ 1
  117. #define KVM_TRACE_MMIO_WRITE 2
  118. #define kvm_trace_symbol_mmio \
  119. { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
  120. { KVM_TRACE_MMIO_READ, "read" }, \
  121. { KVM_TRACE_MMIO_WRITE, "write" }
  122. TRACE_EVENT(kvm_mmio,
  123. TP_PROTO(int type, int len, u64 gpa, u64 val),
  124. TP_ARGS(type, len, gpa, val),
  125. TP_STRUCT__entry(
  126. __field( u32, type )
  127. __field( u32, len )
  128. __field( u64, gpa )
  129. __field( u64, val )
  130. ),
  131. TP_fast_assign(
  132. __entry->type = type;
  133. __entry->len = len;
  134. __entry->gpa = gpa;
  135. __entry->val = val;
  136. ),
  137. TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
  138. __print_symbolic(__entry->type, kvm_trace_symbol_mmio),
  139. __entry->len, __entry->gpa, __entry->val)
  140. );
  141. #define kvm_fpu_load_symbol \
  142. {0, "unload"}, \
  143. {1, "load"}
  144. TRACE_EVENT(kvm_fpu,
  145. TP_PROTO(int load),
  146. TP_ARGS(load),
  147. TP_STRUCT__entry(
  148. __field( u32, load )
  149. ),
  150. TP_fast_assign(
  151. __entry->load = load;
  152. ),
  153. TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
  154. );
  155. TRACE_EVENT(kvm_age_page,
  156. TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
  157. TP_ARGS(hva, slot, ref),
  158. TP_STRUCT__entry(
  159. __field( u64, hva )
  160. __field( u64, gfn )
  161. __field( u8, referenced )
  162. ),
  163. TP_fast_assign(
  164. __entry->hva = hva;
  165. __entry->gfn =
  166. slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
  167. __entry->referenced = ref;
  168. ),
  169. TP_printk("hva %llx gfn %llx %s",
  170. __entry->hva, __entry->gfn,
  171. __entry->referenced ? "YOUNG" : "OLD")
  172. );
  173. #ifdef CONFIG_KVM_ASYNC_PF
  174. DECLARE_EVENT_CLASS(kvm_async_get_page_class,
  175. TP_PROTO(u64 gva, u64 gfn),
  176. TP_ARGS(gva, gfn),
  177. TP_STRUCT__entry(
  178. __field(__u64, gva)
  179. __field(u64, gfn)
  180. ),
  181. TP_fast_assign(
  182. __entry->gva = gva;
  183. __entry->gfn = gfn;
  184. ),
  185. TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
  186. );
  187. DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page,
  188. TP_PROTO(u64 gva, u64 gfn),
  189. TP_ARGS(gva, gfn)
  190. );
  191. DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault,
  192. TP_PROTO(u64 gva, u64 gfn),
  193. TP_ARGS(gva, gfn)
  194. );
  195. DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready,
  196. TP_PROTO(u64 token, u64 gva),
  197. TP_ARGS(token, gva),
  198. TP_STRUCT__entry(
  199. __field(__u64, token)
  200. __field(__u64, gva)
  201. ),
  202. TP_fast_assign(
  203. __entry->token = token;
  204. __entry->gva = gva;
  205. ),
  206. TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva)
  207. );
  208. DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present,
  209. TP_PROTO(u64 token, u64 gva),
  210. TP_ARGS(token, gva)
  211. );
  212. DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready,
  213. TP_PROTO(u64 token, u64 gva),
  214. TP_ARGS(token, gva)
  215. );
  216. TRACE_EVENT(
  217. kvm_async_pf_completed,
  218. TP_PROTO(unsigned long address, struct page *page, u64 gva),
  219. TP_ARGS(address, page, gva),
  220. TP_STRUCT__entry(
  221. __field(unsigned long, address)
  222. __field(pfn_t, pfn)
  223. __field(u64, gva)
  224. ),
  225. TP_fast_assign(
  226. __entry->address = address;
  227. __entry->pfn = page ? page_to_pfn(page) : 0;
  228. __entry->gva = gva;
  229. ),
  230. TP_printk("gva %#llx address %#lx pfn %#llx", __entry->gva,
  231. __entry->address, __entry->pfn)
  232. );
  233. #endif
  234. #endif /* _TRACE_KVM_MAIN_H */
  235. /* This part must be outside protection */
  236. #include <trace/define_trace.h>