trace.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
  3. #define _TRACE_KVM_H
  4. #include <linux/tracepoint.h>
  5. #undef TRACE_SYSTEM
  6. #define TRACE_SYSTEM kvm
  7. /*
  8. * Tracepoints for entry/exit to guest
  9. */
  10. TRACE_EVENT(kvm_entry,
  11. TP_PROTO(unsigned long vcpu_pc),
  12. TP_ARGS(vcpu_pc),
  13. TP_STRUCT__entry(
  14. __field( unsigned long, vcpu_pc )
  15. ),
  16. TP_fast_assign(
  17. __entry->vcpu_pc = vcpu_pc;
  18. ),
  19. TP_printk("PC: 0x%08lx", __entry->vcpu_pc)
  20. );
  21. TRACE_EVENT(kvm_exit,
  22. TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc),
  23. TP_ARGS(idx, exit_reason, vcpu_pc),
  24. TP_STRUCT__entry(
  25. __field( int, idx )
  26. __field( unsigned int, exit_reason )
  27. __field( unsigned long, vcpu_pc )
  28. ),
  29. TP_fast_assign(
  30. __entry->idx = idx;
  31. __entry->exit_reason = exit_reason;
  32. __entry->vcpu_pc = vcpu_pc;
  33. ),
  34. TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx",
  35. __print_symbolic(__entry->idx, kvm_arm_exception_type),
  36. __entry->exit_reason,
  37. __print_symbolic(__entry->exit_reason, kvm_arm_exception_class),
  38. __entry->vcpu_pc)
  39. );
  40. TRACE_EVENT(kvm_guest_fault,
  41. TP_PROTO(unsigned long vcpu_pc, unsigned long hsr,
  42. unsigned long hxfar,
  43. unsigned long long ipa),
  44. TP_ARGS(vcpu_pc, hsr, hxfar, ipa),
  45. TP_STRUCT__entry(
  46. __field( unsigned long, vcpu_pc )
  47. __field( unsigned long, hsr )
  48. __field( unsigned long, hxfar )
  49. __field( unsigned long long, ipa )
  50. ),
  51. TP_fast_assign(
  52. __entry->vcpu_pc = vcpu_pc;
  53. __entry->hsr = hsr;
  54. __entry->hxfar = hxfar;
  55. __entry->ipa = ipa;
  56. ),
  57. TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#08lx",
  58. __entry->ipa, __entry->hsr,
  59. __entry->hxfar, __entry->vcpu_pc)
  60. );
  61. TRACE_EVENT(kvm_access_fault,
  62. TP_PROTO(unsigned long ipa),
  63. TP_ARGS(ipa),
  64. TP_STRUCT__entry(
  65. __field( unsigned long, ipa )
  66. ),
  67. TP_fast_assign(
  68. __entry->ipa = ipa;
  69. ),
  70. TP_printk("IPA: %lx", __entry->ipa)
  71. );
  72. TRACE_EVENT(kvm_irq_line,
  73. TP_PROTO(unsigned int type, int vcpu_idx, int irq_num, int level),
  74. TP_ARGS(type, vcpu_idx, irq_num, level),
  75. TP_STRUCT__entry(
  76. __field( unsigned int, type )
  77. __field( int, vcpu_idx )
  78. __field( int, irq_num )
  79. __field( int, level )
  80. ),
  81. TP_fast_assign(
  82. __entry->type = type;
  83. __entry->vcpu_idx = vcpu_idx;
  84. __entry->irq_num = irq_num;
  85. __entry->level = level;
  86. ),
  87. TP_printk("Inject %s interrupt (%d), vcpu->idx: %d, num: %d, level: %d",
  88. (__entry->type == KVM_ARM_IRQ_TYPE_CPU) ? "CPU" :
  89. (__entry->type == KVM_ARM_IRQ_TYPE_PPI) ? "VGIC PPI" :
  90. (__entry->type == KVM_ARM_IRQ_TYPE_SPI) ? "VGIC SPI" : "UNKNOWN",
  91. __entry->type, __entry->vcpu_idx, __entry->irq_num, __entry->level)
  92. );
  93. TRACE_EVENT(kvm_mmio_emulate,
  94. TP_PROTO(unsigned long vcpu_pc, unsigned long instr,
  95. unsigned long cpsr),
  96. TP_ARGS(vcpu_pc, instr, cpsr),
  97. TP_STRUCT__entry(
  98. __field( unsigned long, vcpu_pc )
  99. __field( unsigned long, instr )
  100. __field( unsigned long, cpsr )
  101. ),
  102. TP_fast_assign(
  103. __entry->vcpu_pc = vcpu_pc;
  104. __entry->instr = instr;
  105. __entry->cpsr = cpsr;
  106. ),
  107. TP_printk("Emulate MMIO at: 0x%08lx (instr: %08lx, cpsr: %08lx)",
  108. __entry->vcpu_pc, __entry->instr, __entry->cpsr)
  109. );
  110. TRACE_EVENT(kvm_unmap_hva_range,
  111. TP_PROTO(unsigned long start, unsigned long end),
  112. TP_ARGS(start, end),
  113. TP_STRUCT__entry(
  114. __field( unsigned long, start )
  115. __field( unsigned long, end )
  116. ),
  117. TP_fast_assign(
  118. __entry->start = start;
  119. __entry->end = end;
  120. ),
  121. TP_printk("mmu notifier unmap range: %#08lx -- %#08lx",
  122. __entry->start, __entry->end)
  123. );
  124. TRACE_EVENT(kvm_set_spte_hva,
  125. TP_PROTO(unsigned long hva),
  126. TP_ARGS(hva),
  127. TP_STRUCT__entry(
  128. __field( unsigned long, hva )
  129. ),
  130. TP_fast_assign(
  131. __entry->hva = hva;
  132. ),
  133. TP_printk("mmu notifier set pte hva: %#08lx", __entry->hva)
  134. );
  135. TRACE_EVENT(kvm_age_hva,
  136. TP_PROTO(unsigned long start, unsigned long end),
  137. TP_ARGS(start, end),
  138. TP_STRUCT__entry(
  139. __field( unsigned long, start )
  140. __field( unsigned long, end )
  141. ),
  142. TP_fast_assign(
  143. __entry->start = start;
  144. __entry->end = end;
  145. ),
  146. TP_printk("mmu notifier age hva: %#08lx -- %#08lx",
  147. __entry->start, __entry->end)
  148. );
  149. TRACE_EVENT(kvm_test_age_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 test age hva: %#08lx", __entry->hva)
  159. );
  160. TRACE_EVENT(kvm_set_way_flush,
  161. TP_PROTO(unsigned long vcpu_pc, bool cache),
  162. TP_ARGS(vcpu_pc, cache),
  163. TP_STRUCT__entry(
  164. __field( unsigned long, vcpu_pc )
  165. __field( bool, cache )
  166. ),
  167. TP_fast_assign(
  168. __entry->vcpu_pc = vcpu_pc;
  169. __entry->cache = cache;
  170. ),
  171. TP_printk("S/W flush at 0x%016lx (cache %s)",
  172. __entry->vcpu_pc, __entry->cache ? "on" : "off")
  173. );
  174. TRACE_EVENT(kvm_toggle_cache,
  175. TP_PROTO(unsigned long vcpu_pc, bool was, bool now),
  176. TP_ARGS(vcpu_pc, was, now),
  177. TP_STRUCT__entry(
  178. __field( unsigned long, vcpu_pc )
  179. __field( bool, was )
  180. __field( bool, now )
  181. ),
  182. TP_fast_assign(
  183. __entry->vcpu_pc = vcpu_pc;
  184. __entry->was = was;
  185. __entry->now = now;
  186. ),
  187. TP_printk("VM op at 0x%016lx (cache was %s, now %s)",
  188. __entry->vcpu_pc, __entry->was ? "on" : "off",
  189. __entry->now ? "on" : "off")
  190. );
  191. /*
  192. * Tracepoints for arch_timer
  193. */
  194. TRACE_EVENT(kvm_timer_update_irq,
  195. TP_PROTO(unsigned long vcpu_id, __u32 irq, int level),
  196. TP_ARGS(vcpu_id, irq, level),
  197. TP_STRUCT__entry(
  198. __field( unsigned long, vcpu_id )
  199. __field( __u32, irq )
  200. __field( int, level )
  201. ),
  202. TP_fast_assign(
  203. __entry->vcpu_id = vcpu_id;
  204. __entry->irq = irq;
  205. __entry->level = level;
  206. ),
  207. TP_printk("VCPU: %ld, IRQ %d, level %d",
  208. __entry->vcpu_id, __entry->irq, __entry->level)
  209. );
  210. #endif /* _TRACE_KVM_H */
  211. #undef TRACE_INCLUDE_PATH
  212. #define TRACE_INCLUDE_PATH ../../../virt/kvm/arm
  213. #undef TRACE_INCLUDE_FILE
  214. #define TRACE_INCLUDE_FILE trace
  215. /* This part must be outside protection */
  216. #include <trace/define_trace.h>