trace.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
  2. #define _TRACE_KVM_H
  3. #include <linux/tracepoint.h>
  4. #include <asm/sie.h>
  5. #include <asm/debug.h>
  6. #include <asm/dis.h>
  7. #undef TRACE_SYSTEM
  8. #define TRACE_SYSTEM kvm
  9. #define TRACE_INCLUDE_PATH .
  10. #undef TRACE_INCLUDE_FILE
  11. #define TRACE_INCLUDE_FILE trace
  12. /*
  13. * Helpers for vcpu-specific tracepoints containing the same information
  14. * as s390dbf VCPU_EVENTs.
  15. */
  16. #define VCPU_PROTO_COMMON struct kvm_vcpu *vcpu
  17. #define VCPU_ARGS_COMMON vcpu
  18. #define VCPU_FIELD_COMMON __field(int, id) \
  19. __field(unsigned long, pswmask) \
  20. __field(unsigned long, pswaddr)
  21. #define VCPU_ASSIGN_COMMON do { \
  22. __entry->id = vcpu->vcpu_id; \
  23. __entry->pswmask = vcpu->arch.sie_block->gpsw.mask; \
  24. __entry->pswaddr = vcpu->arch.sie_block->gpsw.addr; \
  25. } while (0);
  26. #define VCPU_TP_PRINTK(p_str, p_args...) \
  27. TP_printk("%02d[%016lx-%016lx]: " p_str, __entry->id, \
  28. __entry->pswmask, __entry->pswaddr, p_args)
  29. TRACE_EVENT(kvm_s390_skey_related_inst,
  30. TP_PROTO(VCPU_PROTO_COMMON),
  31. TP_ARGS(VCPU_ARGS_COMMON),
  32. TP_STRUCT__entry(
  33. VCPU_FIELD_COMMON
  34. ),
  35. TP_fast_assign(
  36. VCPU_ASSIGN_COMMON
  37. ),
  38. VCPU_TP_PRINTK("%s", "first instruction related to skeys on vcpu")
  39. );
  40. TRACE_EVENT(kvm_s390_major_guest_pfault,
  41. TP_PROTO(VCPU_PROTO_COMMON),
  42. TP_ARGS(VCPU_ARGS_COMMON),
  43. TP_STRUCT__entry(
  44. VCPU_FIELD_COMMON
  45. ),
  46. TP_fast_assign(
  47. VCPU_ASSIGN_COMMON
  48. ),
  49. VCPU_TP_PRINTK("%s", "major fault, maybe applicable for pfault")
  50. );
  51. TRACE_EVENT(kvm_s390_pfault_init,
  52. TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
  53. TP_ARGS(VCPU_ARGS_COMMON, pfault_token),
  54. TP_STRUCT__entry(
  55. VCPU_FIELD_COMMON
  56. __field(long, pfault_token)
  57. ),
  58. TP_fast_assign(
  59. VCPU_ASSIGN_COMMON
  60. __entry->pfault_token = pfault_token;
  61. ),
  62. VCPU_TP_PRINTK("init pfault token %ld", __entry->pfault_token)
  63. );
  64. TRACE_EVENT(kvm_s390_pfault_done,
  65. TP_PROTO(VCPU_PROTO_COMMON, long pfault_token),
  66. TP_ARGS(VCPU_ARGS_COMMON, pfault_token),
  67. TP_STRUCT__entry(
  68. VCPU_FIELD_COMMON
  69. __field(long, pfault_token)
  70. ),
  71. TP_fast_assign(
  72. VCPU_ASSIGN_COMMON
  73. __entry->pfault_token = pfault_token;
  74. ),
  75. VCPU_TP_PRINTK("done pfault token %ld", __entry->pfault_token)
  76. );
  77. /*
  78. * Tracepoints for SIE entry and exit.
  79. */
  80. TRACE_EVENT(kvm_s390_sie_enter,
  81. TP_PROTO(VCPU_PROTO_COMMON, int cpuflags),
  82. TP_ARGS(VCPU_ARGS_COMMON, cpuflags),
  83. TP_STRUCT__entry(
  84. VCPU_FIELD_COMMON
  85. __field(int, cpuflags)
  86. ),
  87. TP_fast_assign(
  88. VCPU_ASSIGN_COMMON
  89. __entry->cpuflags = cpuflags;
  90. ),
  91. VCPU_TP_PRINTK("entering sie flags %x", __entry->cpuflags)
  92. );
  93. TRACE_EVENT(kvm_s390_sie_fault,
  94. TP_PROTO(VCPU_PROTO_COMMON),
  95. TP_ARGS(VCPU_ARGS_COMMON),
  96. TP_STRUCT__entry(
  97. VCPU_FIELD_COMMON
  98. ),
  99. TP_fast_assign(
  100. VCPU_ASSIGN_COMMON
  101. ),
  102. VCPU_TP_PRINTK("%s", "fault in sie instruction")
  103. );
  104. TRACE_EVENT(kvm_s390_sie_exit,
  105. TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode),
  106. TP_ARGS(VCPU_ARGS_COMMON, icptcode),
  107. TP_STRUCT__entry(
  108. VCPU_FIELD_COMMON
  109. __field(u8, icptcode)
  110. ),
  111. TP_fast_assign(
  112. VCPU_ASSIGN_COMMON
  113. __entry->icptcode = icptcode;
  114. ),
  115. VCPU_TP_PRINTK("exit sie icptcode %d (%s)", __entry->icptcode,
  116. __print_symbolic(__entry->icptcode,
  117. sie_intercept_code))
  118. );
  119. /*
  120. * Trace point for intercepted instructions.
  121. */
  122. TRACE_EVENT(kvm_s390_intercept_instruction,
  123. TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb),
  124. TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb),
  125. TP_STRUCT__entry(
  126. VCPU_FIELD_COMMON
  127. __field(__u64, instruction)
  128. ),
  129. TP_fast_assign(
  130. VCPU_ASSIGN_COMMON
  131. __entry->instruction = ((__u64)ipa << 48) |
  132. ((__u64)ipb << 16);
  133. ),
  134. VCPU_TP_PRINTK("intercepted instruction %016llx (%s)",
  135. __entry->instruction,
  136. __print_symbolic(icpt_insn_decoder(__entry->instruction),
  137. icpt_insn_codes))
  138. );
  139. /*
  140. * Trace point for intercepted program interruptions.
  141. */
  142. TRACE_EVENT(kvm_s390_intercept_prog,
  143. TP_PROTO(VCPU_PROTO_COMMON, __u16 code),
  144. TP_ARGS(VCPU_ARGS_COMMON, code),
  145. TP_STRUCT__entry(
  146. VCPU_FIELD_COMMON
  147. __field(__u16, code)
  148. ),
  149. TP_fast_assign(
  150. VCPU_ASSIGN_COMMON
  151. __entry->code = code;
  152. ),
  153. VCPU_TP_PRINTK("intercepted program interruption %04x",
  154. __entry->code)
  155. );
  156. /*
  157. * Trace point for validity intercepts.
  158. */
  159. TRACE_EVENT(kvm_s390_intercept_validity,
  160. TP_PROTO(VCPU_PROTO_COMMON, __u16 viwhy),
  161. TP_ARGS(VCPU_ARGS_COMMON, viwhy),
  162. TP_STRUCT__entry(
  163. VCPU_FIELD_COMMON
  164. __field(__u16, viwhy)
  165. ),
  166. TP_fast_assign(
  167. VCPU_ASSIGN_COMMON
  168. __entry->viwhy = viwhy;
  169. ),
  170. VCPU_TP_PRINTK("got validity intercept %04x", __entry->viwhy)
  171. );
  172. /*
  173. * Trace points for instructions that are of special interest.
  174. */
  175. TRACE_EVENT(kvm_s390_handle_sigp,
  176. TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr, \
  177. __u32 parameter),
  178. TP_ARGS(VCPU_ARGS_COMMON, order_code, cpu_addr, parameter),
  179. TP_STRUCT__entry(
  180. VCPU_FIELD_COMMON
  181. __field(__u8, order_code)
  182. __field(__u16, cpu_addr)
  183. __field(__u32, parameter)
  184. ),
  185. TP_fast_assign(
  186. VCPU_ASSIGN_COMMON
  187. __entry->order_code = order_code;
  188. __entry->cpu_addr = cpu_addr;
  189. __entry->parameter = parameter;
  190. ),
  191. VCPU_TP_PRINTK("handle sigp order %02x (%s), cpu address %04x, " \
  192. "parameter %08x", __entry->order_code,
  193. __print_symbolic(__entry->order_code,
  194. sigp_order_codes),
  195. __entry->cpu_addr, __entry->parameter)
  196. );
  197. TRACE_EVENT(kvm_s390_handle_sigp_pei,
  198. TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr),
  199. TP_ARGS(VCPU_ARGS_COMMON, order_code, cpu_addr),
  200. TP_STRUCT__entry(
  201. VCPU_FIELD_COMMON
  202. __field(__u8, order_code)
  203. __field(__u16, cpu_addr)
  204. ),
  205. TP_fast_assign(
  206. VCPU_ASSIGN_COMMON
  207. __entry->order_code = order_code;
  208. __entry->cpu_addr = cpu_addr;
  209. ),
  210. VCPU_TP_PRINTK("handle sigp pei order %02x (%s), cpu address %04x",
  211. __entry->order_code,
  212. __print_symbolic(__entry->order_code,
  213. sigp_order_codes),
  214. __entry->cpu_addr)
  215. );
  216. TRACE_EVENT(kvm_s390_handle_diag,
  217. TP_PROTO(VCPU_PROTO_COMMON, __u16 code),
  218. TP_ARGS(VCPU_ARGS_COMMON, code),
  219. TP_STRUCT__entry(
  220. VCPU_FIELD_COMMON
  221. __field(__u16, code)
  222. ),
  223. TP_fast_assign(
  224. VCPU_ASSIGN_COMMON
  225. __entry->code = code;
  226. ),
  227. VCPU_TP_PRINTK("handle diagnose call %04x (%s)", __entry->code,
  228. __print_symbolic(__entry->code, diagnose_codes))
  229. );
  230. TRACE_EVENT(kvm_s390_handle_lctl,
  231. TP_PROTO(VCPU_PROTO_COMMON, int g, int reg1, int reg3, u64 addr),
  232. TP_ARGS(VCPU_ARGS_COMMON, g, reg1, reg3, addr),
  233. TP_STRUCT__entry(
  234. VCPU_FIELD_COMMON
  235. __field(int, g)
  236. __field(int, reg1)
  237. __field(int, reg3)
  238. __field(u64, addr)
  239. ),
  240. TP_fast_assign(
  241. VCPU_ASSIGN_COMMON
  242. __entry->g = g;
  243. __entry->reg1 = reg1;
  244. __entry->reg3 = reg3;
  245. __entry->addr = addr;
  246. ),
  247. VCPU_TP_PRINTK("%s: loading cr %x-%x from %016llx",
  248. __entry->g ? "lctlg" : "lctl",
  249. __entry->reg1, __entry->reg3, __entry->addr)
  250. );
  251. TRACE_EVENT(kvm_s390_handle_stctl,
  252. TP_PROTO(VCPU_PROTO_COMMON, int g, int reg1, int reg3, u64 addr),
  253. TP_ARGS(VCPU_ARGS_COMMON, g, reg1, reg3, addr),
  254. TP_STRUCT__entry(
  255. VCPU_FIELD_COMMON
  256. __field(int, g)
  257. __field(int, reg1)
  258. __field(int, reg3)
  259. __field(u64, addr)
  260. ),
  261. TP_fast_assign(
  262. VCPU_ASSIGN_COMMON
  263. __entry->g = g;
  264. __entry->reg1 = reg1;
  265. __entry->reg3 = reg3;
  266. __entry->addr = addr;
  267. ),
  268. VCPU_TP_PRINTK("%s: storing cr %x-%x to %016llx",
  269. __entry->g ? "stctg" : "stctl",
  270. __entry->reg1, __entry->reg3, __entry->addr)
  271. );
  272. TRACE_EVENT(kvm_s390_handle_prefix,
  273. TP_PROTO(VCPU_PROTO_COMMON, int set, u32 address),
  274. TP_ARGS(VCPU_ARGS_COMMON, set, address),
  275. TP_STRUCT__entry(
  276. VCPU_FIELD_COMMON
  277. __field(int, set)
  278. __field(u32, address)
  279. ),
  280. TP_fast_assign(
  281. VCPU_ASSIGN_COMMON
  282. __entry->set = set;
  283. __entry->address = address;
  284. ),
  285. VCPU_TP_PRINTK("%s prefix to %08x",
  286. __entry->set ? "setting" : "storing",
  287. __entry->address)
  288. );
  289. TRACE_EVENT(kvm_s390_handle_stap,
  290. TP_PROTO(VCPU_PROTO_COMMON, u64 address),
  291. TP_ARGS(VCPU_ARGS_COMMON, address),
  292. TP_STRUCT__entry(
  293. VCPU_FIELD_COMMON
  294. __field(u64, address)
  295. ),
  296. TP_fast_assign(
  297. VCPU_ASSIGN_COMMON
  298. __entry->address = address;
  299. ),
  300. VCPU_TP_PRINTK("storing cpu address to %016llx",
  301. __entry->address)
  302. );
  303. TRACE_EVENT(kvm_s390_handle_stfl,
  304. TP_PROTO(VCPU_PROTO_COMMON, unsigned int facility_list),
  305. TP_ARGS(VCPU_ARGS_COMMON, facility_list),
  306. TP_STRUCT__entry(
  307. VCPU_FIELD_COMMON
  308. __field(unsigned int, facility_list)
  309. ),
  310. TP_fast_assign(
  311. VCPU_ASSIGN_COMMON
  312. __entry->facility_list = facility_list;
  313. ),
  314. VCPU_TP_PRINTK("store facility list value %08x",
  315. __entry->facility_list)
  316. );
  317. TRACE_EVENT(kvm_s390_handle_stsi,
  318. TP_PROTO(VCPU_PROTO_COMMON, int fc, int sel1, int sel2, u64 addr),
  319. TP_ARGS(VCPU_ARGS_COMMON, fc, sel1, sel2, addr),
  320. TP_STRUCT__entry(
  321. VCPU_FIELD_COMMON
  322. __field(int, fc)
  323. __field(int, sel1)
  324. __field(int, sel2)
  325. __field(u64, addr)
  326. ),
  327. TP_fast_assign(
  328. VCPU_ASSIGN_COMMON
  329. __entry->fc = fc;
  330. __entry->sel1 = sel1;
  331. __entry->sel2 = sel2;
  332. __entry->addr = addr;
  333. ),
  334. VCPU_TP_PRINTK("STSI %d.%d.%d information stored to %016llx",
  335. __entry->fc, __entry->sel1, __entry->sel2,
  336. __entry->addr)
  337. );
  338. #endif /* _TRACE_KVM_H */
  339. /* This part must be outside protection */
  340. #include <trace/define_trace.h>