trace.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  1. #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
  2. #define _TRACE_KVM_H
  3. #include <linux/tracepoint.h>
  4. #include <asm/vmx.h>
  5. #include <asm/svm.h>
  6. #include <asm/clocksource.h>
  7. #include <asm/pvclock-abi.h>
  8. #undef TRACE_SYSTEM
  9. #define TRACE_SYSTEM kvm
  10. /*
  11. * Tracepoint for guest mode entry.
  12. */
  13. TRACE_EVENT(kvm_entry,
  14. TP_PROTO(unsigned int vcpu_id),
  15. TP_ARGS(vcpu_id),
  16. TP_STRUCT__entry(
  17. __field( unsigned int, vcpu_id )
  18. ),
  19. TP_fast_assign(
  20. __entry->vcpu_id = vcpu_id;
  21. ),
  22. TP_printk("vcpu %u", __entry->vcpu_id)
  23. );
  24. /*
  25. * Tracepoint for hypercall.
  26. */
  27. TRACE_EVENT(kvm_hypercall,
  28. TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
  29. unsigned long a2, unsigned long a3),
  30. TP_ARGS(nr, a0, a1, a2, a3),
  31. TP_STRUCT__entry(
  32. __field( unsigned long, nr )
  33. __field( unsigned long, a0 )
  34. __field( unsigned long, a1 )
  35. __field( unsigned long, a2 )
  36. __field( unsigned long, a3 )
  37. ),
  38. TP_fast_assign(
  39. __entry->nr = nr;
  40. __entry->a0 = a0;
  41. __entry->a1 = a1;
  42. __entry->a2 = a2;
  43. __entry->a3 = a3;
  44. ),
  45. TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
  46. __entry->nr, __entry->a0, __entry->a1, __entry->a2,
  47. __entry->a3)
  48. );
  49. /*
  50. * Tracepoint for hypercall.
  51. */
  52. TRACE_EVENT(kvm_hv_hypercall,
  53. TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
  54. __u64 ingpa, __u64 outgpa),
  55. TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
  56. TP_STRUCT__entry(
  57. __field( __u16, rep_cnt )
  58. __field( __u16, rep_idx )
  59. __field( __u64, ingpa )
  60. __field( __u64, outgpa )
  61. __field( __u16, code )
  62. __field( bool, fast )
  63. ),
  64. TP_fast_assign(
  65. __entry->rep_cnt = rep_cnt;
  66. __entry->rep_idx = rep_idx;
  67. __entry->ingpa = ingpa;
  68. __entry->outgpa = outgpa;
  69. __entry->code = code;
  70. __entry->fast = fast;
  71. ),
  72. TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
  73. __entry->code, __entry->fast ? "fast" : "slow",
  74. __entry->rep_cnt, __entry->rep_idx, __entry->ingpa,
  75. __entry->outgpa)
  76. );
  77. /*
  78. * Tracepoint for PIO.
  79. */
  80. #define KVM_PIO_IN 0
  81. #define KVM_PIO_OUT 1
  82. TRACE_EVENT(kvm_pio,
  83. TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
  84. unsigned int count, void *data),
  85. TP_ARGS(rw, port, size, count, data),
  86. TP_STRUCT__entry(
  87. __field( unsigned int, rw )
  88. __field( unsigned int, port )
  89. __field( unsigned int, size )
  90. __field( unsigned int, count )
  91. __field( unsigned int, val )
  92. ),
  93. TP_fast_assign(
  94. __entry->rw = rw;
  95. __entry->port = port;
  96. __entry->size = size;
  97. __entry->count = count;
  98. if (size == 1)
  99. __entry->val = *(unsigned char *)data;
  100. else if (size == 2)
  101. __entry->val = *(unsigned short *)data;
  102. else
  103. __entry->val = *(unsigned int *)data;
  104. ),
  105. TP_printk("pio_%s at 0x%x size %d count %d val 0x%x %s",
  106. __entry->rw ? "write" : "read",
  107. __entry->port, __entry->size, __entry->count, __entry->val,
  108. __entry->count > 1 ? "(...)" : "")
  109. );
  110. /*
  111. * Tracepoint for fast mmio.
  112. */
  113. TRACE_EVENT(kvm_fast_mmio,
  114. TP_PROTO(u64 gpa),
  115. TP_ARGS(gpa),
  116. TP_STRUCT__entry(
  117. __field(u64, gpa)
  118. ),
  119. TP_fast_assign(
  120. __entry->gpa = gpa;
  121. ),
  122. TP_printk("fast mmio at gpa 0x%llx", __entry->gpa)
  123. );
  124. /*
  125. * Tracepoint for cpuid.
  126. */
  127. TRACE_EVENT(kvm_cpuid,
  128. TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
  129. unsigned long rcx, unsigned long rdx),
  130. TP_ARGS(function, rax, rbx, rcx, rdx),
  131. TP_STRUCT__entry(
  132. __field( unsigned int, function )
  133. __field( unsigned long, rax )
  134. __field( unsigned long, rbx )
  135. __field( unsigned long, rcx )
  136. __field( unsigned long, rdx )
  137. ),
  138. TP_fast_assign(
  139. __entry->function = function;
  140. __entry->rax = rax;
  141. __entry->rbx = rbx;
  142. __entry->rcx = rcx;
  143. __entry->rdx = rdx;
  144. ),
  145. TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
  146. __entry->function, __entry->rax,
  147. __entry->rbx, __entry->rcx, __entry->rdx)
  148. );
  149. #define AREG(x) { APIC_##x, "APIC_" #x }
  150. #define kvm_trace_symbol_apic \
  151. AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI), \
  152. AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR), \
  153. AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
  154. AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR), \
  155. AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT), \
  156. AREG(ECTRL)
  157. /*
  158. * Tracepoint for apic access.
  159. */
  160. TRACE_EVENT(kvm_apic,
  161. TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
  162. TP_ARGS(rw, reg, val),
  163. TP_STRUCT__entry(
  164. __field( unsigned int, rw )
  165. __field( unsigned int, reg )
  166. __field( unsigned int, val )
  167. ),
  168. TP_fast_assign(
  169. __entry->rw = rw;
  170. __entry->reg = reg;
  171. __entry->val = val;
  172. ),
  173. TP_printk("apic_%s %s = 0x%x",
  174. __entry->rw ? "write" : "read",
  175. __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
  176. __entry->val)
  177. );
  178. #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val)
  179. #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val)
  180. #define KVM_ISA_VMX 1
  181. #define KVM_ISA_SVM 2
  182. /*
  183. * Tracepoint for kvm guest exit:
  184. */
  185. TRACE_EVENT(kvm_exit,
  186. TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
  187. TP_ARGS(exit_reason, vcpu, isa),
  188. TP_STRUCT__entry(
  189. __field( unsigned int, exit_reason )
  190. __field( unsigned long, guest_rip )
  191. __field( u32, isa )
  192. __field( u64, info1 )
  193. __field( u64, info2 )
  194. ),
  195. TP_fast_assign(
  196. __entry->exit_reason = exit_reason;
  197. __entry->guest_rip = kvm_rip_read(vcpu);
  198. __entry->isa = isa;
  199. kvm_x86_ops->get_exit_info(vcpu, &__entry->info1,
  200. &__entry->info2);
  201. ),
  202. TP_printk("reason %s rip 0x%lx info %llx %llx",
  203. (__entry->isa == KVM_ISA_VMX) ?
  204. __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
  205. __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
  206. __entry->guest_rip, __entry->info1, __entry->info2)
  207. );
  208. /*
  209. * Tracepoint for kvm interrupt injection:
  210. */
  211. TRACE_EVENT(kvm_inj_virq,
  212. TP_PROTO(unsigned int irq),
  213. TP_ARGS(irq),
  214. TP_STRUCT__entry(
  215. __field( unsigned int, irq )
  216. ),
  217. TP_fast_assign(
  218. __entry->irq = irq;
  219. ),
  220. TP_printk("irq %u", __entry->irq)
  221. );
  222. #define EXS(x) { x##_VECTOR, "#" #x }
  223. #define kvm_trace_sym_exc \
  224. EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM), \
  225. EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF), \
  226. EXS(MF), EXS(AC), EXS(MC)
  227. /*
  228. * Tracepoint for kvm interrupt injection:
  229. */
  230. TRACE_EVENT(kvm_inj_exception,
  231. TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
  232. TP_ARGS(exception, has_error, error_code),
  233. TP_STRUCT__entry(
  234. __field( u8, exception )
  235. __field( u8, has_error )
  236. __field( u32, error_code )
  237. ),
  238. TP_fast_assign(
  239. __entry->exception = exception;
  240. __entry->has_error = has_error;
  241. __entry->error_code = error_code;
  242. ),
  243. TP_printk("%s (0x%x)",
  244. __print_symbolic(__entry->exception, kvm_trace_sym_exc),
  245. /* FIXME: don't print error_code if not present */
  246. __entry->has_error ? __entry->error_code : 0)
  247. );
  248. /*
  249. * Tracepoint for page fault.
  250. */
  251. TRACE_EVENT(kvm_page_fault,
  252. TP_PROTO(unsigned long fault_address, unsigned int error_code),
  253. TP_ARGS(fault_address, error_code),
  254. TP_STRUCT__entry(
  255. __field( unsigned long, fault_address )
  256. __field( unsigned int, error_code )
  257. ),
  258. TP_fast_assign(
  259. __entry->fault_address = fault_address;
  260. __entry->error_code = error_code;
  261. ),
  262. TP_printk("address %lx error_code %x",
  263. __entry->fault_address, __entry->error_code)
  264. );
  265. /*
  266. * Tracepoint for guest MSR access.
  267. */
  268. TRACE_EVENT(kvm_msr,
  269. TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
  270. TP_ARGS(write, ecx, data, exception),
  271. TP_STRUCT__entry(
  272. __field( unsigned, write )
  273. __field( u32, ecx )
  274. __field( u64, data )
  275. __field( u8, exception )
  276. ),
  277. TP_fast_assign(
  278. __entry->write = write;
  279. __entry->ecx = ecx;
  280. __entry->data = data;
  281. __entry->exception = exception;
  282. ),
  283. TP_printk("msr_%s %x = 0x%llx%s",
  284. __entry->write ? "write" : "read",
  285. __entry->ecx, __entry->data,
  286. __entry->exception ? " (#GP)" : "")
  287. );
  288. #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data, false)
  289. #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data, false)
  290. #define trace_kvm_msr_read_ex(ecx) trace_kvm_msr(0, ecx, 0, true)
  291. #define trace_kvm_msr_write_ex(ecx, data) trace_kvm_msr(1, ecx, data, true)
  292. /*
  293. * Tracepoint for guest CR access.
  294. */
  295. TRACE_EVENT(kvm_cr,
  296. TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
  297. TP_ARGS(rw, cr, val),
  298. TP_STRUCT__entry(
  299. __field( unsigned int, rw )
  300. __field( unsigned int, cr )
  301. __field( unsigned long, val )
  302. ),
  303. TP_fast_assign(
  304. __entry->rw = rw;
  305. __entry->cr = cr;
  306. __entry->val = val;
  307. ),
  308. TP_printk("cr_%s %x = 0x%lx",
  309. __entry->rw ? "write" : "read",
  310. __entry->cr, __entry->val)
  311. );
  312. #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val)
  313. #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val)
  314. TRACE_EVENT(kvm_pic_set_irq,
  315. TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
  316. TP_ARGS(chip, pin, elcr, imr, coalesced),
  317. TP_STRUCT__entry(
  318. __field( __u8, chip )
  319. __field( __u8, pin )
  320. __field( __u8, elcr )
  321. __field( __u8, imr )
  322. __field( bool, coalesced )
  323. ),
  324. TP_fast_assign(
  325. __entry->chip = chip;
  326. __entry->pin = pin;
  327. __entry->elcr = elcr;
  328. __entry->imr = imr;
  329. __entry->coalesced = coalesced;
  330. ),
  331. TP_printk("chip %u pin %u (%s%s)%s",
  332. __entry->chip, __entry->pin,
  333. (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
  334. (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
  335. __entry->coalesced ? " (coalesced)" : "")
  336. );
  337. #define kvm_apic_dst_shorthand \
  338. {0x0, "dst"}, \
  339. {0x1, "self"}, \
  340. {0x2, "all"}, \
  341. {0x3, "all-but-self"}
  342. TRACE_EVENT(kvm_apic_ipi,
  343. TP_PROTO(__u32 icr_low, __u32 dest_id),
  344. TP_ARGS(icr_low, dest_id),
  345. TP_STRUCT__entry(
  346. __field( __u32, icr_low )
  347. __field( __u32, dest_id )
  348. ),
  349. TP_fast_assign(
  350. __entry->icr_low = icr_low;
  351. __entry->dest_id = dest_id;
  352. ),
  353. TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
  354. __entry->dest_id, (u8)__entry->icr_low,
  355. __print_symbolic((__entry->icr_low >> 8 & 0x7),
  356. kvm_deliver_mode),
  357. (__entry->icr_low & (1<<11)) ? "logical" : "physical",
  358. (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
  359. (__entry->icr_low & (1<<15)) ? "level" : "edge",
  360. __print_symbolic((__entry->icr_low >> 18 & 0x3),
  361. kvm_apic_dst_shorthand))
  362. );
  363. TRACE_EVENT(kvm_apic_accept_irq,
  364. TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec),
  365. TP_ARGS(apicid, dm, tm, vec),
  366. TP_STRUCT__entry(
  367. __field( __u32, apicid )
  368. __field( __u16, dm )
  369. __field( __u8, tm )
  370. __field( __u8, vec )
  371. ),
  372. TP_fast_assign(
  373. __entry->apicid = apicid;
  374. __entry->dm = dm;
  375. __entry->tm = tm;
  376. __entry->vec = vec;
  377. ),
  378. TP_printk("apicid %x vec %u (%s|%s)",
  379. __entry->apicid, __entry->vec,
  380. __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
  381. __entry->tm ? "level" : "edge")
  382. );
  383. TRACE_EVENT(kvm_eoi,
  384. TP_PROTO(struct kvm_lapic *apic, int vector),
  385. TP_ARGS(apic, vector),
  386. TP_STRUCT__entry(
  387. __field( __u32, apicid )
  388. __field( int, vector )
  389. ),
  390. TP_fast_assign(
  391. __entry->apicid = apic->vcpu->vcpu_id;
  392. __entry->vector = vector;
  393. ),
  394. TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
  395. );
  396. TRACE_EVENT(kvm_pv_eoi,
  397. TP_PROTO(struct kvm_lapic *apic, int vector),
  398. TP_ARGS(apic, vector),
  399. TP_STRUCT__entry(
  400. __field( __u32, apicid )
  401. __field( int, vector )
  402. ),
  403. TP_fast_assign(
  404. __entry->apicid = apic->vcpu->vcpu_id;
  405. __entry->vector = vector;
  406. ),
  407. TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
  408. );
  409. /*
  410. * Tracepoint for nested VMRUN
  411. */
  412. TRACE_EVENT(kvm_nested_vmrun,
  413. TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
  414. __u32 event_inj, bool npt),
  415. TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
  416. TP_STRUCT__entry(
  417. __field( __u64, rip )
  418. __field( __u64, vmcb )
  419. __field( __u64, nested_rip )
  420. __field( __u32, int_ctl )
  421. __field( __u32, event_inj )
  422. __field( bool, npt )
  423. ),
  424. TP_fast_assign(
  425. __entry->rip = rip;
  426. __entry->vmcb = vmcb;
  427. __entry->nested_rip = nested_rip;
  428. __entry->int_ctl = int_ctl;
  429. __entry->event_inj = event_inj;
  430. __entry->npt = npt;
  431. ),
  432. TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
  433. "event_inj: 0x%08x npt: %s",
  434. __entry->rip, __entry->vmcb, __entry->nested_rip,
  435. __entry->int_ctl, __entry->event_inj,
  436. __entry->npt ? "on" : "off")
  437. );
  438. TRACE_EVENT(kvm_nested_intercepts,
  439. TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
  440. TP_ARGS(cr_read, cr_write, exceptions, intercept),
  441. TP_STRUCT__entry(
  442. __field( __u16, cr_read )
  443. __field( __u16, cr_write )
  444. __field( __u32, exceptions )
  445. __field( __u64, intercept )
  446. ),
  447. TP_fast_assign(
  448. __entry->cr_read = cr_read;
  449. __entry->cr_write = cr_write;
  450. __entry->exceptions = exceptions;
  451. __entry->intercept = intercept;
  452. ),
  453. TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
  454. __entry->cr_read, __entry->cr_write, __entry->exceptions,
  455. __entry->intercept)
  456. );
  457. /*
  458. * Tracepoint for #VMEXIT while nested
  459. */
  460. TRACE_EVENT(kvm_nested_vmexit,
  461. TP_PROTO(__u64 rip, __u32 exit_code,
  462. __u64 exit_info1, __u64 exit_info2,
  463. __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
  464. TP_ARGS(rip, exit_code, exit_info1, exit_info2,
  465. exit_int_info, exit_int_info_err, isa),
  466. TP_STRUCT__entry(
  467. __field( __u64, rip )
  468. __field( __u32, exit_code )
  469. __field( __u64, exit_info1 )
  470. __field( __u64, exit_info2 )
  471. __field( __u32, exit_int_info )
  472. __field( __u32, exit_int_info_err )
  473. __field( __u32, isa )
  474. ),
  475. TP_fast_assign(
  476. __entry->rip = rip;
  477. __entry->exit_code = exit_code;
  478. __entry->exit_info1 = exit_info1;
  479. __entry->exit_info2 = exit_info2;
  480. __entry->exit_int_info = exit_int_info;
  481. __entry->exit_int_info_err = exit_int_info_err;
  482. __entry->isa = isa;
  483. ),
  484. TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
  485. "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
  486. __entry->rip,
  487. (__entry->isa == KVM_ISA_VMX) ?
  488. __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
  489. __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
  490. __entry->exit_info1, __entry->exit_info2,
  491. __entry->exit_int_info, __entry->exit_int_info_err)
  492. );
  493. /*
  494. * Tracepoint for #VMEXIT reinjected to the guest
  495. */
  496. TRACE_EVENT(kvm_nested_vmexit_inject,
  497. TP_PROTO(__u32 exit_code,
  498. __u64 exit_info1, __u64 exit_info2,
  499. __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
  500. TP_ARGS(exit_code, exit_info1, exit_info2,
  501. exit_int_info, exit_int_info_err, isa),
  502. TP_STRUCT__entry(
  503. __field( __u32, exit_code )
  504. __field( __u64, exit_info1 )
  505. __field( __u64, exit_info2 )
  506. __field( __u32, exit_int_info )
  507. __field( __u32, exit_int_info_err )
  508. __field( __u32, isa )
  509. ),
  510. TP_fast_assign(
  511. __entry->exit_code = exit_code;
  512. __entry->exit_info1 = exit_info1;
  513. __entry->exit_info2 = exit_info2;
  514. __entry->exit_int_info = exit_int_info;
  515. __entry->exit_int_info_err = exit_int_info_err;
  516. __entry->isa = isa;
  517. ),
  518. TP_printk("reason: %s ext_inf1: 0x%016llx "
  519. "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
  520. (__entry->isa == KVM_ISA_VMX) ?
  521. __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
  522. __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
  523. __entry->exit_info1, __entry->exit_info2,
  524. __entry->exit_int_info, __entry->exit_int_info_err)
  525. );
  526. /*
  527. * Tracepoint for nested #vmexit because of interrupt pending
  528. */
  529. TRACE_EVENT(kvm_nested_intr_vmexit,
  530. TP_PROTO(__u64 rip),
  531. TP_ARGS(rip),
  532. TP_STRUCT__entry(
  533. __field( __u64, rip )
  534. ),
  535. TP_fast_assign(
  536. __entry->rip = rip
  537. ),
  538. TP_printk("rip: 0x%016llx", __entry->rip)
  539. );
  540. /*
  541. * Tracepoint for nested #vmexit because of interrupt pending
  542. */
  543. TRACE_EVENT(kvm_invlpga,
  544. TP_PROTO(__u64 rip, int asid, u64 address),
  545. TP_ARGS(rip, asid, address),
  546. TP_STRUCT__entry(
  547. __field( __u64, rip )
  548. __field( int, asid )
  549. __field( __u64, address )
  550. ),
  551. TP_fast_assign(
  552. __entry->rip = rip;
  553. __entry->asid = asid;
  554. __entry->address = address;
  555. ),
  556. TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
  557. __entry->rip, __entry->asid, __entry->address)
  558. );
  559. /*
  560. * Tracepoint for nested #vmexit because of interrupt pending
  561. */
  562. TRACE_EVENT(kvm_skinit,
  563. TP_PROTO(__u64 rip, __u32 slb),
  564. TP_ARGS(rip, slb),
  565. TP_STRUCT__entry(
  566. __field( __u64, rip )
  567. __field( __u32, slb )
  568. ),
  569. TP_fast_assign(
  570. __entry->rip = rip;
  571. __entry->slb = slb;
  572. ),
  573. TP_printk("rip: 0x%016llx slb: 0x%08x",
  574. __entry->rip, __entry->slb)
  575. );
  576. #define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
  577. #define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
  578. #define KVM_EMUL_INSN_F_CS_D (1 << 2)
  579. #define KVM_EMUL_INSN_F_CS_L (1 << 3)
  580. #define kvm_trace_symbol_emul_flags \
  581. { 0, "real" }, \
  582. { KVM_EMUL_INSN_F_CR0_PE \
  583. | KVM_EMUL_INSN_F_EFL_VM, "vm16" }, \
  584. { KVM_EMUL_INSN_F_CR0_PE, "prot16" }, \
  585. { KVM_EMUL_INSN_F_CR0_PE \
  586. | KVM_EMUL_INSN_F_CS_D, "prot32" }, \
  587. { KVM_EMUL_INSN_F_CR0_PE \
  588. | KVM_EMUL_INSN_F_CS_L, "prot64" }
  589. #define kei_decode_mode(mode) ({ \
  590. u8 flags = 0xff; \
  591. switch (mode) { \
  592. case X86EMUL_MODE_REAL: \
  593. flags = 0; \
  594. break; \
  595. case X86EMUL_MODE_VM86: \
  596. flags = KVM_EMUL_INSN_F_EFL_VM; \
  597. break; \
  598. case X86EMUL_MODE_PROT16: \
  599. flags = KVM_EMUL_INSN_F_CR0_PE; \
  600. break; \
  601. case X86EMUL_MODE_PROT32: \
  602. flags = KVM_EMUL_INSN_F_CR0_PE \
  603. | KVM_EMUL_INSN_F_CS_D; \
  604. break; \
  605. case X86EMUL_MODE_PROT64: \
  606. flags = KVM_EMUL_INSN_F_CR0_PE \
  607. | KVM_EMUL_INSN_F_CS_L; \
  608. break; \
  609. } \
  610. flags; \
  611. })
  612. TRACE_EVENT(kvm_emulate_insn,
  613. TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
  614. TP_ARGS(vcpu, failed),
  615. TP_STRUCT__entry(
  616. __field( __u64, rip )
  617. __field( __u32, csbase )
  618. __field( __u8, len )
  619. __array( __u8, insn, 15 )
  620. __field( __u8, flags )
  621. __field( __u8, failed )
  622. ),
  623. TP_fast_assign(
  624. __entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS);
  625. __entry->len = vcpu->arch.emulate_ctxt.fetch.ptr
  626. - vcpu->arch.emulate_ctxt.fetch.data;
  627. __entry->rip = vcpu->arch.emulate_ctxt._eip - __entry->len;
  628. memcpy(__entry->insn,
  629. vcpu->arch.emulate_ctxt.fetch.data,
  630. 15);
  631. __entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode);
  632. __entry->failed = failed;
  633. ),
  634. TP_printk("%x:%llx:%s (%s)%s",
  635. __entry->csbase, __entry->rip,
  636. __print_hex(__entry->insn, __entry->len),
  637. __print_symbolic(__entry->flags,
  638. kvm_trace_symbol_emul_flags),
  639. __entry->failed ? " failed" : ""
  640. )
  641. );
  642. #define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
  643. #define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
  644. TRACE_EVENT(
  645. vcpu_match_mmio,
  646. TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
  647. TP_ARGS(gva, gpa, write, gpa_match),
  648. TP_STRUCT__entry(
  649. __field(gva_t, gva)
  650. __field(gpa_t, gpa)
  651. __field(bool, write)
  652. __field(bool, gpa_match)
  653. ),
  654. TP_fast_assign(
  655. __entry->gva = gva;
  656. __entry->gpa = gpa;
  657. __entry->write = write;
  658. __entry->gpa_match = gpa_match
  659. ),
  660. TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
  661. __entry->write ? "Write" : "Read",
  662. __entry->gpa_match ? "GPA" : "GVA")
  663. );
  664. TRACE_EVENT(kvm_write_tsc_offset,
  665. TP_PROTO(unsigned int vcpu_id, __u64 previous_tsc_offset,
  666. __u64 next_tsc_offset),
  667. TP_ARGS(vcpu_id, previous_tsc_offset, next_tsc_offset),
  668. TP_STRUCT__entry(
  669. __field( unsigned int, vcpu_id )
  670. __field( __u64, previous_tsc_offset )
  671. __field( __u64, next_tsc_offset )
  672. ),
  673. TP_fast_assign(
  674. __entry->vcpu_id = vcpu_id;
  675. __entry->previous_tsc_offset = previous_tsc_offset;
  676. __entry->next_tsc_offset = next_tsc_offset;
  677. ),
  678. TP_printk("vcpu=%u prev=%llu next=%llu", __entry->vcpu_id,
  679. __entry->previous_tsc_offset, __entry->next_tsc_offset)
  680. );
  681. #ifdef CONFIG_X86_64
  682. #define host_clocks \
  683. {VCLOCK_NONE, "none"}, \
  684. {VCLOCK_TSC, "tsc"} \
  685. TRACE_EVENT(kvm_update_master_clock,
  686. TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
  687. TP_ARGS(use_master_clock, host_clock, offset_matched),
  688. TP_STRUCT__entry(
  689. __field( bool, use_master_clock )
  690. __field( unsigned int, host_clock )
  691. __field( bool, offset_matched )
  692. ),
  693. TP_fast_assign(
  694. __entry->use_master_clock = use_master_clock;
  695. __entry->host_clock = host_clock;
  696. __entry->offset_matched = offset_matched;
  697. ),
  698. TP_printk("masterclock %d hostclock %s offsetmatched %u",
  699. __entry->use_master_clock,
  700. __print_symbolic(__entry->host_clock, host_clocks),
  701. __entry->offset_matched)
  702. );
  703. TRACE_EVENT(kvm_track_tsc,
  704. TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
  705. unsigned int online_vcpus, bool use_master_clock,
  706. unsigned int host_clock),
  707. TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
  708. host_clock),
  709. TP_STRUCT__entry(
  710. __field( unsigned int, vcpu_id )
  711. __field( unsigned int, nr_vcpus_matched_tsc )
  712. __field( unsigned int, online_vcpus )
  713. __field( bool, use_master_clock )
  714. __field( unsigned int, host_clock )
  715. ),
  716. TP_fast_assign(
  717. __entry->vcpu_id = vcpu_id;
  718. __entry->nr_vcpus_matched_tsc = nr_matched;
  719. __entry->online_vcpus = online_vcpus;
  720. __entry->use_master_clock = use_master_clock;
  721. __entry->host_clock = host_clock;
  722. ),
  723. TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
  724. " hostclock %s",
  725. __entry->vcpu_id, __entry->use_master_clock,
  726. __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
  727. __print_symbolic(__entry->host_clock, host_clocks))
  728. );
  729. #endif /* CONFIG_X86_64 */
  730. /*
  731. * Tracepoint for PML full VMEXIT.
  732. */
  733. TRACE_EVENT(kvm_pml_full,
  734. TP_PROTO(unsigned int vcpu_id),
  735. TP_ARGS(vcpu_id),
  736. TP_STRUCT__entry(
  737. __field( unsigned int, vcpu_id )
  738. ),
  739. TP_fast_assign(
  740. __entry->vcpu_id = vcpu_id;
  741. ),
  742. TP_printk("vcpu %d: PML full", __entry->vcpu_id)
  743. );
  744. TRACE_EVENT(kvm_ple_window,
  745. TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old),
  746. TP_ARGS(grow, vcpu_id, new, old),
  747. TP_STRUCT__entry(
  748. __field( bool, grow )
  749. __field( unsigned int, vcpu_id )
  750. __field( int, new )
  751. __field( int, old )
  752. ),
  753. TP_fast_assign(
  754. __entry->grow = grow;
  755. __entry->vcpu_id = vcpu_id;
  756. __entry->new = new;
  757. __entry->old = old;
  758. ),
  759. TP_printk("vcpu %u: ple_window %d (%s %d)",
  760. __entry->vcpu_id,
  761. __entry->new,
  762. __entry->grow ? "grow" : "shrink",
  763. __entry->old)
  764. );
  765. #define trace_kvm_ple_window_grow(vcpu_id, new, old) \
  766. trace_kvm_ple_window(true, vcpu_id, new, old)
  767. #define trace_kvm_ple_window_shrink(vcpu_id, new, old) \
  768. trace_kvm_ple_window(false, vcpu_id, new, old)
  769. TRACE_EVENT(kvm_pvclock_update,
  770. TP_PROTO(unsigned int vcpu_id, struct pvclock_vcpu_time_info *pvclock),
  771. TP_ARGS(vcpu_id, pvclock),
  772. TP_STRUCT__entry(
  773. __field( unsigned int, vcpu_id )
  774. __field( __u32, version )
  775. __field( __u64, tsc_timestamp )
  776. __field( __u64, system_time )
  777. __field( __u32, tsc_to_system_mul )
  778. __field( __s8, tsc_shift )
  779. __field( __u8, flags )
  780. ),
  781. TP_fast_assign(
  782. __entry->vcpu_id = vcpu_id;
  783. __entry->version = pvclock->version;
  784. __entry->tsc_timestamp = pvclock->tsc_timestamp;
  785. __entry->system_time = pvclock->system_time;
  786. __entry->tsc_to_system_mul = pvclock->tsc_to_system_mul;
  787. __entry->tsc_shift = pvclock->tsc_shift;
  788. __entry->flags = pvclock->flags;
  789. ),
  790. TP_printk("vcpu_id %u, pvclock { version %u, tsc_timestamp 0x%llx, "
  791. "system_time 0x%llx, tsc_to_system_mul 0x%x, tsc_shift %d, "
  792. "flags 0x%x }",
  793. __entry->vcpu_id,
  794. __entry->version,
  795. __entry->tsc_timestamp,
  796. __entry->system_time,
  797. __entry->tsc_to_system_mul,
  798. __entry->tsc_shift,
  799. __entry->flags)
  800. );
  801. TRACE_EVENT(kvm_wait_lapic_expire,
  802. TP_PROTO(unsigned int vcpu_id, s64 delta),
  803. TP_ARGS(vcpu_id, delta),
  804. TP_STRUCT__entry(
  805. __field( unsigned int, vcpu_id )
  806. __field( s64, delta )
  807. ),
  808. TP_fast_assign(
  809. __entry->vcpu_id = vcpu_id;
  810. __entry->delta = delta;
  811. ),
  812. TP_printk("vcpu %u: delta %lld (%s)",
  813. __entry->vcpu_id,
  814. __entry->delta,
  815. __entry->delta < 0 ? "early" : "late")
  816. );
  817. TRACE_EVENT(kvm_enter_smm,
  818. TP_PROTO(unsigned int vcpu_id, u64 smbase, bool entering),
  819. TP_ARGS(vcpu_id, smbase, entering),
  820. TP_STRUCT__entry(
  821. __field( unsigned int, vcpu_id )
  822. __field( u64, smbase )
  823. __field( bool, entering )
  824. ),
  825. TP_fast_assign(
  826. __entry->vcpu_id = vcpu_id;
  827. __entry->smbase = smbase;
  828. __entry->entering = entering;
  829. ),
  830. TP_printk("vcpu %u: %s SMM, smbase 0x%llx",
  831. __entry->vcpu_id,
  832. __entry->entering ? "entering" : "leaving",
  833. __entry->smbase)
  834. );
  835. /*
  836. * Tracepoint for VT-d posted-interrupts.
  837. */
  838. TRACE_EVENT(kvm_pi_irte_update,
  839. TP_PROTO(unsigned int host_irq, unsigned int vcpu_id,
  840. unsigned int gsi, unsigned int gvec,
  841. u64 pi_desc_addr, bool set),
  842. TP_ARGS(host_irq, vcpu_id, gsi, gvec, pi_desc_addr, set),
  843. TP_STRUCT__entry(
  844. __field( unsigned int, host_irq )
  845. __field( unsigned int, vcpu_id )
  846. __field( unsigned int, gsi )
  847. __field( unsigned int, gvec )
  848. __field( u64, pi_desc_addr )
  849. __field( bool, set )
  850. ),
  851. TP_fast_assign(
  852. __entry->host_irq = host_irq;
  853. __entry->vcpu_id = vcpu_id;
  854. __entry->gsi = gsi;
  855. __entry->gvec = gvec;
  856. __entry->pi_desc_addr = pi_desc_addr;
  857. __entry->set = set;
  858. ),
  859. TP_printk("VT-d PI is %s for irq %u, vcpu %u, gsi: 0x%x, "
  860. "gvec: 0x%x, pi_desc_addr: 0x%llx",
  861. __entry->set ? "enabled and being updated" : "disabled",
  862. __entry->host_irq,
  863. __entry->vcpu_id,
  864. __entry->gsi,
  865. __entry->gvec,
  866. __entry->pi_desc_addr)
  867. );
  868. /*
  869. * Tracepoint for kvm_hv_notify_acked_sint.
  870. */
  871. TRACE_EVENT(kvm_hv_notify_acked_sint,
  872. TP_PROTO(int vcpu_id, u32 sint),
  873. TP_ARGS(vcpu_id, sint),
  874. TP_STRUCT__entry(
  875. __field(int, vcpu_id)
  876. __field(u32, sint)
  877. ),
  878. TP_fast_assign(
  879. __entry->vcpu_id = vcpu_id;
  880. __entry->sint = sint;
  881. ),
  882. TP_printk("vcpu_id %d sint %u", __entry->vcpu_id, __entry->sint)
  883. );
  884. /*
  885. * Tracepoint for synic_set_irq.
  886. */
  887. TRACE_EVENT(kvm_hv_synic_set_irq,
  888. TP_PROTO(int vcpu_id, u32 sint, int vector, int ret),
  889. TP_ARGS(vcpu_id, sint, vector, ret),
  890. TP_STRUCT__entry(
  891. __field(int, vcpu_id)
  892. __field(u32, sint)
  893. __field(int, vector)
  894. __field(int, ret)
  895. ),
  896. TP_fast_assign(
  897. __entry->vcpu_id = vcpu_id;
  898. __entry->sint = sint;
  899. __entry->vector = vector;
  900. __entry->ret = ret;
  901. ),
  902. TP_printk("vcpu_id %d sint %u vector %d ret %d",
  903. __entry->vcpu_id, __entry->sint, __entry->vector,
  904. __entry->ret)
  905. );
  906. /*
  907. * Tracepoint for kvm_hv_synic_send_eoi.
  908. */
  909. TRACE_EVENT(kvm_hv_synic_send_eoi,
  910. TP_PROTO(int vcpu_id, int vector),
  911. TP_ARGS(vcpu_id, vector),
  912. TP_STRUCT__entry(
  913. __field(int, vcpu_id)
  914. __field(u32, sint)
  915. __field(int, vector)
  916. __field(int, ret)
  917. ),
  918. TP_fast_assign(
  919. __entry->vcpu_id = vcpu_id;
  920. __entry->vector = vector;
  921. ),
  922. TP_printk("vcpu_id %d vector %d", __entry->vcpu_id, __entry->vector)
  923. );
  924. /*
  925. * Tracepoint for synic_set_msr.
  926. */
  927. TRACE_EVENT(kvm_hv_synic_set_msr,
  928. TP_PROTO(int vcpu_id, u32 msr, u64 data, bool host),
  929. TP_ARGS(vcpu_id, msr, data, host),
  930. TP_STRUCT__entry(
  931. __field(int, vcpu_id)
  932. __field(u32, msr)
  933. __field(u64, data)
  934. __field(bool, host)
  935. ),
  936. TP_fast_assign(
  937. __entry->vcpu_id = vcpu_id;
  938. __entry->msr = msr;
  939. __entry->data = data;
  940. __entry->host = host
  941. ),
  942. TP_printk("vcpu_id %d msr 0x%x data 0x%llx host %d",
  943. __entry->vcpu_id, __entry->msr, __entry->data, __entry->host)
  944. );
  945. /*
  946. * Tracepoint for stimer_set_config.
  947. */
  948. TRACE_EVENT(kvm_hv_stimer_set_config,
  949. TP_PROTO(int vcpu_id, int timer_index, u64 config, bool host),
  950. TP_ARGS(vcpu_id, timer_index, config, host),
  951. TP_STRUCT__entry(
  952. __field(int, vcpu_id)
  953. __field(int, timer_index)
  954. __field(u64, config)
  955. __field(bool, host)
  956. ),
  957. TP_fast_assign(
  958. __entry->vcpu_id = vcpu_id;
  959. __entry->timer_index = timer_index;
  960. __entry->config = config;
  961. __entry->host = host;
  962. ),
  963. TP_printk("vcpu_id %d timer %d config 0x%llx host %d",
  964. __entry->vcpu_id, __entry->timer_index, __entry->config,
  965. __entry->host)
  966. );
  967. /*
  968. * Tracepoint for stimer_set_count.
  969. */
  970. TRACE_EVENT(kvm_hv_stimer_set_count,
  971. TP_PROTO(int vcpu_id, int timer_index, u64 count, bool host),
  972. TP_ARGS(vcpu_id, timer_index, count, host),
  973. TP_STRUCT__entry(
  974. __field(int, vcpu_id)
  975. __field(int, timer_index)
  976. __field(u64, count)
  977. __field(bool, host)
  978. ),
  979. TP_fast_assign(
  980. __entry->vcpu_id = vcpu_id;
  981. __entry->timer_index = timer_index;
  982. __entry->count = count;
  983. __entry->host = host;
  984. ),
  985. TP_printk("vcpu_id %d timer %d count %llu host %d",
  986. __entry->vcpu_id, __entry->timer_index, __entry->count,
  987. __entry->host)
  988. );
  989. /*
  990. * Tracepoint for stimer_start(periodic timer case).
  991. */
  992. TRACE_EVENT(kvm_hv_stimer_start_periodic,
  993. TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 exp_time),
  994. TP_ARGS(vcpu_id, timer_index, time_now, exp_time),
  995. TP_STRUCT__entry(
  996. __field(int, vcpu_id)
  997. __field(int, timer_index)
  998. __field(u64, time_now)
  999. __field(u64, exp_time)
  1000. ),
  1001. TP_fast_assign(
  1002. __entry->vcpu_id = vcpu_id;
  1003. __entry->timer_index = timer_index;
  1004. __entry->time_now = time_now;
  1005. __entry->exp_time = exp_time;
  1006. ),
  1007. TP_printk("vcpu_id %d timer %d time_now %llu exp_time %llu",
  1008. __entry->vcpu_id, __entry->timer_index, __entry->time_now,
  1009. __entry->exp_time)
  1010. );
  1011. /*
  1012. * Tracepoint for stimer_start(one-shot timer case).
  1013. */
  1014. TRACE_EVENT(kvm_hv_stimer_start_one_shot,
  1015. TP_PROTO(int vcpu_id, int timer_index, u64 time_now, u64 count),
  1016. TP_ARGS(vcpu_id, timer_index, time_now, count),
  1017. TP_STRUCT__entry(
  1018. __field(int, vcpu_id)
  1019. __field(int, timer_index)
  1020. __field(u64, time_now)
  1021. __field(u64, count)
  1022. ),
  1023. TP_fast_assign(
  1024. __entry->vcpu_id = vcpu_id;
  1025. __entry->timer_index = timer_index;
  1026. __entry->time_now = time_now;
  1027. __entry->count = count;
  1028. ),
  1029. TP_printk("vcpu_id %d timer %d time_now %llu count %llu",
  1030. __entry->vcpu_id, __entry->timer_index, __entry->time_now,
  1031. __entry->count)
  1032. );
  1033. /*
  1034. * Tracepoint for stimer_timer_callback.
  1035. */
  1036. TRACE_EVENT(kvm_hv_stimer_callback,
  1037. TP_PROTO(int vcpu_id, int timer_index),
  1038. TP_ARGS(vcpu_id, timer_index),
  1039. TP_STRUCT__entry(
  1040. __field(int, vcpu_id)
  1041. __field(int, timer_index)
  1042. ),
  1043. TP_fast_assign(
  1044. __entry->vcpu_id = vcpu_id;
  1045. __entry->timer_index = timer_index;
  1046. ),
  1047. TP_printk("vcpu_id %d timer %d",
  1048. __entry->vcpu_id, __entry->timer_index)
  1049. );
  1050. /*
  1051. * Tracepoint for stimer_expiration.
  1052. */
  1053. TRACE_EVENT(kvm_hv_stimer_expiration,
  1054. TP_PROTO(int vcpu_id, int timer_index, int msg_send_result),
  1055. TP_ARGS(vcpu_id, timer_index, msg_send_result),
  1056. TP_STRUCT__entry(
  1057. __field(int, vcpu_id)
  1058. __field(int, timer_index)
  1059. __field(int, msg_send_result)
  1060. ),
  1061. TP_fast_assign(
  1062. __entry->vcpu_id = vcpu_id;
  1063. __entry->timer_index = timer_index;
  1064. __entry->msg_send_result = msg_send_result;
  1065. ),
  1066. TP_printk("vcpu_id %d timer %d msg send result %d",
  1067. __entry->vcpu_id, __entry->timer_index,
  1068. __entry->msg_send_result)
  1069. );
  1070. /*
  1071. * Tracepoint for stimer_cleanup.
  1072. */
  1073. TRACE_EVENT(kvm_hv_stimer_cleanup,
  1074. TP_PROTO(int vcpu_id, int timer_index),
  1075. TP_ARGS(vcpu_id, timer_index),
  1076. TP_STRUCT__entry(
  1077. __field(int, vcpu_id)
  1078. __field(int, timer_index)
  1079. ),
  1080. TP_fast_assign(
  1081. __entry->vcpu_id = vcpu_id;
  1082. __entry->timer_index = timer_index;
  1083. ),
  1084. TP_printk("vcpu_id %d timer %d",
  1085. __entry->vcpu_id, __entry->timer_index)
  1086. );
  1087. /*
  1088. * Tracepoint for AMD AVIC
  1089. */
  1090. TRACE_EVENT(kvm_avic_incomplete_ipi,
  1091. TP_PROTO(u32 vcpu, u32 icrh, u32 icrl, u32 id, u32 index),
  1092. TP_ARGS(vcpu, icrh, icrl, id, index),
  1093. TP_STRUCT__entry(
  1094. __field(u32, vcpu)
  1095. __field(u32, icrh)
  1096. __field(u32, icrl)
  1097. __field(u32, id)
  1098. __field(u32, index)
  1099. ),
  1100. TP_fast_assign(
  1101. __entry->vcpu = vcpu;
  1102. __entry->icrh = icrh;
  1103. __entry->icrl = icrl;
  1104. __entry->id = id;
  1105. __entry->index = index;
  1106. ),
  1107. TP_printk("vcpu=%u, icrh:icrl=%#010x:%08x, id=%u, index=%u\n",
  1108. __entry->vcpu, __entry->icrh, __entry->icrl,
  1109. __entry->id, __entry->index)
  1110. );
  1111. TRACE_EVENT(kvm_avic_unaccelerated_access,
  1112. TP_PROTO(u32 vcpu, u32 offset, bool ft, bool rw, u32 vec),
  1113. TP_ARGS(vcpu, offset, ft, rw, vec),
  1114. TP_STRUCT__entry(
  1115. __field(u32, vcpu)
  1116. __field(u32, offset)
  1117. __field(bool, ft)
  1118. __field(bool, rw)
  1119. __field(u32, vec)
  1120. ),
  1121. TP_fast_assign(
  1122. __entry->vcpu = vcpu;
  1123. __entry->offset = offset;
  1124. __entry->ft = ft;
  1125. __entry->rw = rw;
  1126. __entry->vec = vec;
  1127. ),
  1128. TP_printk("vcpu=%u, offset=%#x(%s), %s, %s, vec=%#x\n",
  1129. __entry->vcpu,
  1130. __entry->offset,
  1131. __print_symbolic(__entry->offset, kvm_trace_symbol_apic),
  1132. __entry->ft ? "trap" : "fault",
  1133. __entry->rw ? "write" : "read",
  1134. __entry->vec)
  1135. );
  1136. TRACE_EVENT(kvm_hv_timer_state,
  1137. TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use),
  1138. TP_ARGS(vcpu_id, hv_timer_in_use),
  1139. TP_STRUCT__entry(
  1140. __field(unsigned int, vcpu_id)
  1141. __field(unsigned int, hv_timer_in_use)
  1142. ),
  1143. TP_fast_assign(
  1144. __entry->vcpu_id = vcpu_id;
  1145. __entry->hv_timer_in_use = hv_timer_in_use;
  1146. ),
  1147. TP_printk("vcpu_id %x hv_timer %x\n",
  1148. __entry->vcpu_id,
  1149. __entry->hv_timer_in_use)
  1150. );
  1151. #endif /* _TRACE_KVM_H */
  1152. #undef TRACE_INCLUDE_PATH
  1153. #define TRACE_INCLUDE_PATH arch/x86/kvm
  1154. #undef TRACE_INCLUDE_FILE
  1155. #define TRACE_INCLUDE_FILE trace
  1156. /* This part must be outside protection */
  1157. #include <trace/define_trace.h>