trace.h 11 KB

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