trace.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
  2. #define _TRACE_KVM_H
  3. #include <linux/tracepoint.h>
  4. #undef TRACE_SYSTEM
  5. #define TRACE_SYSTEM kvm
  6. /*
  7. * Tracepoints for entry/exit to guest
  8. */
  9. TRACE_EVENT(kvm_entry,
  10. TP_PROTO(unsigned long vcpu_pc),
  11. TP_ARGS(vcpu_pc),
  12. TP_STRUCT__entry(
  13. __field( unsigned long, vcpu_pc )
  14. ),
  15. TP_fast_assign(
  16. __entry->vcpu_pc = vcpu_pc;
  17. ),
  18. TP_printk("PC: 0x%08lx", __entry->vcpu_pc)
  19. );
  20. TRACE_EVENT(kvm_exit,
  21. TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc),
  22. TP_ARGS(idx, exit_reason, vcpu_pc),
  23. TP_STRUCT__entry(
  24. __field( int, idx )
  25. __field( unsigned int, exit_reason )
  26. __field( unsigned long, vcpu_pc )
  27. ),
  28. TP_fast_assign(
  29. __entry->idx = idx;
  30. __entry->exit_reason = exit_reason;
  31. __entry->vcpu_pc = vcpu_pc;
  32. ),
  33. TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx",
  34. __print_symbolic(__entry->idx, kvm_arm_exception_type),
  35. __entry->exit_reason,
  36. __print_symbolic(__entry->exit_reason, kvm_arm_exception_class),
  37. __entry->vcpu_pc)
  38. );
  39. TRACE_EVENT(kvm_guest_fault,
  40. TP_PROTO(unsigned long vcpu_pc, unsigned long hsr,
  41. unsigned long hxfar,
  42. unsigned long long ipa),
  43. TP_ARGS(vcpu_pc, hsr, hxfar, ipa),
  44. TP_STRUCT__entry(
  45. __field( unsigned long, vcpu_pc )
  46. __field( unsigned long, hsr )
  47. __field( unsigned long, hxfar )
  48. __field( unsigned long long, ipa )
  49. ),
  50. TP_fast_assign(
  51. __entry->vcpu_pc = vcpu_pc;
  52. __entry->hsr = hsr;
  53. __entry->hxfar = hxfar;
  54. __entry->ipa = ipa;
  55. ),
  56. TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#08lx",
  57. __entry->ipa, __entry->hsr,
  58. __entry->hxfar, __entry->vcpu_pc)
  59. );
  60. TRACE_EVENT(kvm_access_fault,
  61. TP_PROTO(unsigned long ipa),
  62. TP_ARGS(ipa),
  63. TP_STRUCT__entry(
  64. __field( unsigned long, ipa )
  65. ),
  66. TP_fast_assign(
  67. __entry->ipa = ipa;
  68. ),
  69. TP_printk("IPA: %lx", __entry->ipa)
  70. );
  71. TRACE_EVENT(kvm_irq_line,
  72. TP_PROTO(unsigned int type, int vcpu_idx, int irq_num, int level),
  73. TP_ARGS(type, vcpu_idx, irq_num, level),
  74. TP_STRUCT__entry(
  75. __field( unsigned int, type )
  76. __field( int, vcpu_idx )
  77. __field( int, irq_num )
  78. __field( int, level )
  79. ),
  80. TP_fast_assign(
  81. __entry->type = type;
  82. __entry->vcpu_idx = vcpu_idx;
  83. __entry->irq_num = irq_num;
  84. __entry->level = level;
  85. ),
  86. TP_printk("Inject %s interrupt (%d), vcpu->idx: %d, num: %d, level: %d",
  87. (__entry->type == KVM_ARM_IRQ_TYPE_CPU) ? "CPU" :
  88. (__entry->type == KVM_ARM_IRQ_TYPE_PPI) ? "VGIC PPI" :
  89. (__entry->type == KVM_ARM_IRQ_TYPE_SPI) ? "VGIC SPI" : "UNKNOWN",
  90. __entry->type, __entry->vcpu_idx, __entry->irq_num, __entry->level)
  91. );
  92. TRACE_EVENT(kvm_mmio_emulate,
  93. TP_PROTO(unsigned long vcpu_pc, unsigned long instr,
  94. unsigned long cpsr),
  95. TP_ARGS(vcpu_pc, instr, cpsr),
  96. TP_STRUCT__entry(
  97. __field( unsigned long, vcpu_pc )
  98. __field( unsigned long, instr )
  99. __field( unsigned long, cpsr )
  100. ),
  101. TP_fast_assign(
  102. __entry->vcpu_pc = vcpu_pc;
  103. __entry->instr = instr;
  104. __entry->cpsr = cpsr;
  105. ),
  106. TP_printk("Emulate MMIO at: 0x%08lx (instr: %08lx, cpsr: %08lx)",
  107. __entry->vcpu_pc, __entry->instr, __entry->cpsr)
  108. );
  109. /* Architecturally implementation defined CP15 register access */
  110. TRACE_EVENT(kvm_emulate_cp15_imp,
  111. TP_PROTO(unsigned long Op1, unsigned long Rt1, unsigned long CRn,
  112. unsigned long CRm, unsigned long Op2, bool is_write),
  113. TP_ARGS(Op1, Rt1, CRn, CRm, Op2, is_write),
  114. TP_STRUCT__entry(
  115. __field( unsigned int, Op1 )
  116. __field( unsigned int, Rt1 )
  117. __field( unsigned int, CRn )
  118. __field( unsigned int, CRm )
  119. __field( unsigned int, Op2 )
  120. __field( bool, is_write )
  121. ),
  122. TP_fast_assign(
  123. __entry->is_write = is_write;
  124. __entry->Op1 = Op1;
  125. __entry->Rt1 = Rt1;
  126. __entry->CRn = CRn;
  127. __entry->CRm = CRm;
  128. __entry->Op2 = Op2;
  129. ),
  130. TP_printk("Implementation defined CP15: %s\tp15, %u, r%u, c%u, c%u, %u",
  131. (__entry->is_write) ? "mcr" : "mrc",
  132. __entry->Op1, __entry->Rt1, __entry->CRn,
  133. __entry->CRm, __entry->Op2)
  134. );
  135. TRACE_EVENT(kvm_wfx,
  136. TP_PROTO(unsigned long vcpu_pc, bool is_wfe),
  137. TP_ARGS(vcpu_pc, is_wfe),
  138. TP_STRUCT__entry(
  139. __field( unsigned long, vcpu_pc )
  140. __field( bool, is_wfe )
  141. ),
  142. TP_fast_assign(
  143. __entry->vcpu_pc = vcpu_pc;
  144. __entry->is_wfe = is_wfe;
  145. ),
  146. TP_printk("guest executed wf%c at: 0x%08lx",
  147. __entry->is_wfe ? 'e' : 'i', __entry->vcpu_pc)
  148. );
  149. TRACE_EVENT(kvm_unmap_hva,
  150. TP_PROTO(unsigned long hva),
  151. TP_ARGS(hva),
  152. TP_STRUCT__entry(
  153. __field( unsigned long, hva )
  154. ),
  155. TP_fast_assign(
  156. __entry->hva = hva;
  157. ),
  158. TP_printk("mmu notifier unmap hva: %#08lx", __entry->hva)
  159. );
  160. TRACE_EVENT(kvm_unmap_hva_range,
  161. TP_PROTO(unsigned long start, unsigned long end),
  162. TP_ARGS(start, end),
  163. TP_STRUCT__entry(
  164. __field( unsigned long, start )
  165. __field( unsigned long, end )
  166. ),
  167. TP_fast_assign(
  168. __entry->start = start;
  169. __entry->end = end;
  170. ),
  171. TP_printk("mmu notifier unmap range: %#08lx -- %#08lx",
  172. __entry->start, __entry->end)
  173. );
  174. TRACE_EVENT(kvm_set_spte_hva,
  175. TP_PROTO(unsigned long hva),
  176. TP_ARGS(hva),
  177. TP_STRUCT__entry(
  178. __field( unsigned long, hva )
  179. ),
  180. TP_fast_assign(
  181. __entry->hva = hva;
  182. ),
  183. TP_printk("mmu notifier set pte hva: %#08lx", __entry->hva)
  184. );
  185. TRACE_EVENT(kvm_age_hva,
  186. TP_PROTO(unsigned long start, unsigned long end),
  187. TP_ARGS(start, end),
  188. TP_STRUCT__entry(
  189. __field( unsigned long, start )
  190. __field( unsigned long, end )
  191. ),
  192. TP_fast_assign(
  193. __entry->start = start;
  194. __entry->end = end;
  195. ),
  196. TP_printk("mmu notifier age hva: %#08lx -- %#08lx",
  197. __entry->start, __entry->end)
  198. );
  199. TRACE_EVENT(kvm_test_age_hva,
  200. TP_PROTO(unsigned long hva),
  201. TP_ARGS(hva),
  202. TP_STRUCT__entry(
  203. __field( unsigned long, hva )
  204. ),
  205. TP_fast_assign(
  206. __entry->hva = hva;
  207. ),
  208. TP_printk("mmu notifier test age hva: %#08lx", __entry->hva)
  209. );
  210. TRACE_EVENT(kvm_hvc,
  211. TP_PROTO(unsigned long vcpu_pc, unsigned long r0, unsigned long imm),
  212. TP_ARGS(vcpu_pc, r0, imm),
  213. TP_STRUCT__entry(
  214. __field( unsigned long, vcpu_pc )
  215. __field( unsigned long, r0 )
  216. __field( unsigned long, imm )
  217. ),
  218. TP_fast_assign(
  219. __entry->vcpu_pc = vcpu_pc;
  220. __entry->r0 = r0;
  221. __entry->imm = imm;
  222. ),
  223. TP_printk("HVC at 0x%08lx (r0: 0x%08lx, imm: 0x%lx",
  224. __entry->vcpu_pc, __entry->r0, __entry->imm)
  225. );
  226. TRACE_EVENT(kvm_set_way_flush,
  227. TP_PROTO(unsigned long vcpu_pc, bool cache),
  228. TP_ARGS(vcpu_pc, cache),
  229. TP_STRUCT__entry(
  230. __field( unsigned long, vcpu_pc )
  231. __field( bool, cache )
  232. ),
  233. TP_fast_assign(
  234. __entry->vcpu_pc = vcpu_pc;
  235. __entry->cache = cache;
  236. ),
  237. TP_printk("S/W flush at 0x%016lx (cache %s)",
  238. __entry->vcpu_pc, __entry->cache ? "on" : "off")
  239. );
  240. TRACE_EVENT(kvm_toggle_cache,
  241. TP_PROTO(unsigned long vcpu_pc, bool was, bool now),
  242. TP_ARGS(vcpu_pc, was, now),
  243. TP_STRUCT__entry(
  244. __field( unsigned long, vcpu_pc )
  245. __field( bool, was )
  246. __field( bool, now )
  247. ),
  248. TP_fast_assign(
  249. __entry->vcpu_pc = vcpu_pc;
  250. __entry->was = was;
  251. __entry->now = now;
  252. ),
  253. TP_printk("VM op at 0x%016lx (cache was %s, now %s)",
  254. __entry->vcpu_pc, __entry->was ? "on" : "off",
  255. __entry->now ? "on" : "off")
  256. );
  257. #endif /* _TRACE_KVM_H */
  258. #undef TRACE_INCLUDE_PATH
  259. #define TRACE_INCLUDE_PATH arch/arm/kvm
  260. #undef TRACE_INCLUDE_FILE
  261. #define TRACE_INCLUDE_FILE trace
  262. /* This part must be outside protection */
  263. #include <trace/define_trace.h>