xref: /openbmc/linux/include/trace/events/xen.h (revision 884caada)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM xen
4 
5 #if !defined(_TRACE_XEN_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_XEN_H
7 
8 #include <linux/tracepoint.h>
9 #include <asm/paravirt_types.h>
10 #include <asm/xen/trace_types.h>
11 
12 struct multicall_entry;
13 
14 /* Multicalls */
15 DECLARE_EVENT_CLASS(xen_mc__batch,
16 	    TP_PROTO(enum paravirt_lazy_mode mode),
17 	    TP_ARGS(mode),
18 	    TP_STRUCT__entry(
19 		    __field(enum paravirt_lazy_mode, mode)
20 		    ),
21 	    TP_fast_assign(__entry->mode = mode),
22 	    TP_printk("start batch LAZY_%s",
23 		      (__entry->mode == PARAVIRT_LAZY_MMU) ? "MMU" :
24 		      (__entry->mode == PARAVIRT_LAZY_CPU) ? "CPU" : "NONE")
25 	);
26 #define DEFINE_XEN_MC_BATCH(name)			\
27 	DEFINE_EVENT(xen_mc__batch, name,		\
28 		TP_PROTO(enum paravirt_lazy_mode mode),	\
29 		     TP_ARGS(mode))
30 
31 DEFINE_XEN_MC_BATCH(xen_mc_batch);
32 DEFINE_XEN_MC_BATCH(xen_mc_issue);
33 
34 TRACE_DEFINE_SIZEOF(ulong);
35 
36 TRACE_EVENT(xen_mc_entry,
37 	    TP_PROTO(struct multicall_entry *mc, unsigned nargs),
38 	    TP_ARGS(mc, nargs),
39 	    TP_STRUCT__entry(
40 		    __field(unsigned int, op)
41 		    __field(unsigned int, nargs)
42 		    __array(unsigned long, args, 6)
43 		    ),
44 	    TP_fast_assign(__entry->op = mc->op;
45 			   __entry->nargs = nargs;
46 			   memcpy(__entry->args, mc->args, sizeof(ulong) * nargs);
47 			   memset(__entry->args + nargs, 0, sizeof(ulong) * (6 - nargs));
48 		    ),
49 	    TP_printk("op %u%s args [%lx, %lx, %lx, %lx, %lx, %lx]",
50 		      __entry->op, xen_hypercall_name(__entry->op),
51 		      __entry->args[0], __entry->args[1], __entry->args[2],
52 		      __entry->args[3], __entry->args[4], __entry->args[5])
53 	);
54 
55 TRACE_EVENT(xen_mc_entry_alloc,
56 	    TP_PROTO(size_t args),
57 	    TP_ARGS(args),
58 	    TP_STRUCT__entry(
59 		    __field(size_t, args)
60 		    ),
61 	    TP_fast_assign(__entry->args = args),
62 	    TP_printk("alloc entry %zu arg bytes", __entry->args)
63 	);
64 
65 TRACE_EVENT(xen_mc_callback,
66 	    TP_PROTO(xen_mc_callback_fn_t fn, void *data),
67 	    TP_ARGS(fn, data),
68 	    TP_STRUCT__entry(
69 		    __field(xen_mc_callback_fn_t, fn)
70 		    __field(void *, data)
71 		    ),
72 	    TP_fast_assign(
73 		    __entry->fn = fn;
74 		    __entry->data = data;
75 		    ),
76 	    TP_printk("callback %ps, data %p",
77 		      __entry->fn, __entry->data)
78 	);
79 
80 TRACE_EVENT(xen_mc_flush_reason,
81 	    TP_PROTO(enum xen_mc_flush_reason reason),
82 	    TP_ARGS(reason),
83 	    TP_STRUCT__entry(
84 		    __field(enum xen_mc_flush_reason, reason)
85 		    ),
86 	    TP_fast_assign(__entry->reason = reason),
87 	    TP_printk("flush reason %s",
88 		      (__entry->reason == XEN_MC_FL_NONE) ? "NONE" :
89 		      (__entry->reason == XEN_MC_FL_BATCH) ? "BATCH" :
90 		      (__entry->reason == XEN_MC_FL_ARGS) ? "ARGS" :
91 		      (__entry->reason == XEN_MC_FL_CALLBACK) ? "CALLBACK" : "??")
92 	);
93 
94 TRACE_EVENT(xen_mc_flush,
95 	    TP_PROTO(unsigned mcidx, unsigned argidx, unsigned cbidx),
96 	    TP_ARGS(mcidx, argidx, cbidx),
97 	    TP_STRUCT__entry(
98 		    __field(unsigned, mcidx)
99 		    __field(unsigned, argidx)
100 		    __field(unsigned, cbidx)
101 		    ),
102 	    TP_fast_assign(__entry->mcidx = mcidx;
103 			   __entry->argidx = argidx;
104 			   __entry->cbidx = cbidx),
105 	    TP_printk("flushing %u hypercalls, %u arg bytes, %u callbacks",
106 		      __entry->mcidx, __entry->argidx, __entry->cbidx)
107 	);
108 
109 TRACE_EVENT(xen_mc_extend_args,
110 	    TP_PROTO(unsigned long op, size_t args, enum xen_mc_extend_args res),
111 	    TP_ARGS(op, args, res),
112 	    TP_STRUCT__entry(
113 		    __field(unsigned int, op)
114 		    __field(size_t, args)
115 		    __field(enum xen_mc_extend_args, res)
116 		    ),
117 	    TP_fast_assign(__entry->op = op;
118 			   __entry->args = args;
119 			   __entry->res = res),
120 	    TP_printk("extending op %u%s by %zu bytes res %s",
121 		      __entry->op, xen_hypercall_name(__entry->op),
122 		      __entry->args,
123 		      __entry->res == XEN_MC_XE_OK ? "OK" :
124 		      __entry->res == XEN_MC_XE_BAD_OP ? "BAD_OP" :
125 		      __entry->res == XEN_MC_XE_NO_SPACE ? "NO_SPACE" : "???")
126 	);
127 
128 TRACE_DEFINE_SIZEOF(pteval_t);
129 /* mmu */
130 DECLARE_EVENT_CLASS(xen_mmu__set_pte,
131 	    TP_PROTO(pte_t *ptep, pte_t pteval),
132 	    TP_ARGS(ptep, pteval),
133 	    TP_STRUCT__entry(
134 		    __field(pte_t *, ptep)
135 		    __field(pteval_t, pteval)
136 		    ),
137 	    TP_fast_assign(__entry->ptep = ptep;
138 			   __entry->pteval = pteval.pte),
139 	    TP_printk("ptep %p pteval %0*llx (raw %0*llx)",
140 		      __entry->ptep,
141 		      (int)sizeof(pteval_t) * 2, (unsigned long long)pte_val(native_make_pte(__entry->pteval)),
142 		      (int)sizeof(pteval_t) * 2, (unsigned long long)__entry->pteval)
143 	);
144 
145 #define DEFINE_XEN_MMU_SET_PTE(name)				\
146 	DEFINE_EVENT(xen_mmu__set_pte, name,			\
147 		     TP_PROTO(pte_t *ptep, pte_t pteval),	\
148 		     TP_ARGS(ptep, pteval))
149 
150 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte);
151 
152 TRACE_EVENT(xen_mmu_set_pte_at,
153 	    TP_PROTO(struct mm_struct *mm, unsigned long addr,
154 		     pte_t *ptep, pte_t pteval),
155 	    TP_ARGS(mm, addr, ptep, pteval),
156 	    TP_STRUCT__entry(
157 		    __field(struct mm_struct *, mm)
158 		    __field(unsigned long, addr)
159 		    __field(pte_t *, ptep)
160 		    __field(pteval_t, pteval)
161 		    ),
162 	    TP_fast_assign(__entry->mm = mm;
163 			   __entry->addr = addr;
164 			   __entry->ptep = ptep;
165 			   __entry->pteval = pteval.pte),
166 	    TP_printk("mm %p addr %lx ptep %p pteval %0*llx (raw %0*llx)",
167 		      __entry->mm, __entry->addr, __entry->ptep,
168 		      (int)sizeof(pteval_t) * 2, (unsigned long long)pte_val(native_make_pte(__entry->pteval)),
169 		      (int)sizeof(pteval_t) * 2, (unsigned long long)__entry->pteval)
170 	);
171 
172 TRACE_DEFINE_SIZEOF(pmdval_t);
173 
174 TRACE_EVENT(xen_mmu_set_pmd,
175 	    TP_PROTO(pmd_t *pmdp, pmd_t pmdval),
176 	    TP_ARGS(pmdp, pmdval),
177 	    TP_STRUCT__entry(
178 		    __field(pmd_t *, pmdp)
179 		    __field(pmdval_t, pmdval)
180 		    ),
181 	    TP_fast_assign(__entry->pmdp = pmdp;
182 			   __entry->pmdval = pmdval.pmd),
183 	    TP_printk("pmdp %p pmdval %0*llx (raw %0*llx)",
184 		      __entry->pmdp,
185 		      (int)sizeof(pmdval_t) * 2, (unsigned long long)pmd_val(native_make_pmd(__entry->pmdval)),
186 		      (int)sizeof(pmdval_t) * 2, (unsigned long long)__entry->pmdval)
187 	);
188 
189 #ifdef CONFIG_X86_PAE
190 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte_atomic);
191 
192 TRACE_EVENT(xen_mmu_pte_clear,
193 	    TP_PROTO(struct mm_struct *mm, unsigned long addr, pte_t *ptep),
194 	    TP_ARGS(mm, addr, ptep),
195 	    TP_STRUCT__entry(
196 		    __field(struct mm_struct *, mm)
197 		    __field(unsigned long, addr)
198 		    __field(pte_t *, ptep)
199 		    ),
200 	    TP_fast_assign(__entry->mm = mm;
201 			   __entry->addr = addr;
202 			   __entry->ptep = ptep),
203 	    TP_printk("mm %p addr %lx ptep %p",
204 		      __entry->mm, __entry->addr, __entry->ptep)
205 	);
206 
207 TRACE_EVENT(xen_mmu_pmd_clear,
208 	    TP_PROTO(pmd_t *pmdp),
209 	    TP_ARGS(pmdp),
210 	    TP_STRUCT__entry(
211 		    __field(pmd_t *, pmdp)
212 		    ),
213 	    TP_fast_assign(__entry->pmdp = pmdp),
214 	    TP_printk("pmdp %p", __entry->pmdp)
215 	);
216 #endif
217 
218 #if CONFIG_PGTABLE_LEVELS >= 4
219 
220 TRACE_DEFINE_SIZEOF(pudval_t);
221 
222 TRACE_EVENT(xen_mmu_set_pud,
223 	    TP_PROTO(pud_t *pudp, pud_t pudval),
224 	    TP_ARGS(pudp, pudval),
225 	    TP_STRUCT__entry(
226 		    __field(pud_t *, pudp)
227 		    __field(pudval_t, pudval)
228 		    ),
229 	    TP_fast_assign(__entry->pudp = pudp;
230 			   __entry->pudval = native_pud_val(pudval)),
231 	    TP_printk("pudp %p pudval %0*llx (raw %0*llx)",
232 		      __entry->pudp,
233 		      (int)sizeof(pudval_t) * 2, (unsigned long long)pud_val(native_make_pud(__entry->pudval)),
234 		      (int)sizeof(pudval_t) * 2, (unsigned long long)__entry->pudval)
235 	);
236 
237 TRACE_DEFINE_SIZEOF(p4dval_t);
238 
239 TRACE_EVENT(xen_mmu_set_p4d,
240 	    TP_PROTO(p4d_t *p4dp, p4d_t *user_p4dp, p4d_t p4dval),
241 	    TP_ARGS(p4dp, user_p4dp, p4dval),
242 	    TP_STRUCT__entry(
243 		    __field(p4d_t *, p4dp)
244 		    __field(p4d_t *, user_p4dp)
245 		    __field(p4dval_t, p4dval)
246 		    ),
247 	    TP_fast_assign(__entry->p4dp = p4dp;
248 			   __entry->user_p4dp = user_p4dp;
249 			   __entry->p4dval = p4d_val(p4dval)),
250 	    TP_printk("p4dp %p user_p4dp %p p4dval %0*llx (raw %0*llx)",
251 		      __entry->p4dp, __entry->user_p4dp,
252 		      (int)sizeof(p4dval_t) * 2, (unsigned long long)pgd_val(native_make_pgd(__entry->p4dval)),
253 		      (int)sizeof(p4dval_t) * 2, (unsigned long long)__entry->p4dval)
254 	);
255 #else
256 
257 TRACE_EVENT(xen_mmu_set_pud,
258 	    TP_PROTO(pud_t *pudp, pud_t pudval),
259 	    TP_ARGS(pudp, pudval),
260 	    TP_STRUCT__entry(
261 		    __field(pud_t *, pudp)
262 		    __field(pudval_t, pudval)
263 		    ),
264 	    TP_fast_assign(__entry->pudp = pudp;
265 			   __entry->pudval = native_pud_val(pudval)),
266 	    TP_printk("pudp %p pudval %0*llx (raw %0*llx)",
267 		      __entry->pudp,
268 		      (int)sizeof(pudval_t) * 2, (unsigned long long)pgd_val(native_make_pgd(__entry->pudval)),
269 		      (int)sizeof(pudval_t) * 2, (unsigned long long)__entry->pudval)
270 	);
271 
272 #endif
273 
274 DECLARE_EVENT_CLASS(xen_mmu_ptep_modify_prot,
275 	    TP_PROTO(struct mm_struct *mm, unsigned long addr,
276 		     pte_t *ptep, pte_t pteval),
277 	    TP_ARGS(mm, addr, ptep, pteval),
278 	    TP_STRUCT__entry(
279 		    __field(struct mm_struct *, mm)
280 		    __field(unsigned long, addr)
281 		    __field(pte_t *, ptep)
282 		    __field(pteval_t, pteval)
283 		    ),
284 	    TP_fast_assign(__entry->mm = mm;
285 			   __entry->addr = addr;
286 			   __entry->ptep = ptep;
287 			   __entry->pteval = pteval.pte),
288 	    TP_printk("mm %p addr %lx ptep %p pteval %0*llx (raw %0*llx)",
289 		      __entry->mm, __entry->addr, __entry->ptep,
290 		      (int)sizeof(pteval_t) * 2, (unsigned long long)pte_val(native_make_pte(__entry->pteval)),
291 		      (int)sizeof(pteval_t) * 2, (unsigned long long)__entry->pteval)
292 	);
293 #define DEFINE_XEN_MMU_PTEP_MODIFY_PROT(name)				\
294 	DEFINE_EVENT(xen_mmu_ptep_modify_prot, name,			\
295 		     TP_PROTO(struct mm_struct *mm, unsigned long addr,	\
296 			      pte_t *ptep, pte_t pteval),		\
297 		     TP_ARGS(mm, addr, ptep, pteval))
298 
299 DEFINE_XEN_MMU_PTEP_MODIFY_PROT(xen_mmu_ptep_modify_prot_start);
300 DEFINE_XEN_MMU_PTEP_MODIFY_PROT(xen_mmu_ptep_modify_prot_commit);
301 
302 TRACE_EVENT(xen_mmu_alloc_ptpage,
303 	    TP_PROTO(struct mm_struct *mm, unsigned long pfn, unsigned level, bool pinned),
304 	    TP_ARGS(mm, pfn, level, pinned),
305 	    TP_STRUCT__entry(
306 		    __field(struct mm_struct *, mm)
307 		    __field(unsigned long, pfn)
308 		    __field(unsigned, level)
309 		    __field(bool, pinned)
310 		    ),
311 	    TP_fast_assign(__entry->mm = mm;
312 			   __entry->pfn = pfn;
313 			   __entry->level = level;
314 			   __entry->pinned = pinned),
315 	    TP_printk("mm %p  pfn %lx  level %d  %spinned",
316 		      __entry->mm, __entry->pfn, __entry->level,
317 		      __entry->pinned ? "" : "un")
318 	);
319 
320 TRACE_EVENT(xen_mmu_release_ptpage,
321 	    TP_PROTO(unsigned long pfn, unsigned level, bool pinned),
322 	    TP_ARGS(pfn, level, pinned),
323 	    TP_STRUCT__entry(
324 		    __field(unsigned long, pfn)
325 		    __field(unsigned, level)
326 		    __field(bool, pinned)
327 		    ),
328 	    TP_fast_assign(__entry->pfn = pfn;
329 			   __entry->level = level;
330 			   __entry->pinned = pinned),
331 	    TP_printk("pfn %lx  level %d  %spinned",
332 		      __entry->pfn, __entry->level,
333 		      __entry->pinned ? "" : "un")
334 	);
335 
336 DECLARE_EVENT_CLASS(xen_mmu_pgd,
337 	    TP_PROTO(struct mm_struct *mm, pgd_t *pgd),
338 	    TP_ARGS(mm, pgd),
339 	    TP_STRUCT__entry(
340 		    __field(struct mm_struct *, mm)
341 		    __field(pgd_t *, pgd)
342 		    ),
343 	    TP_fast_assign(__entry->mm = mm;
344 			   __entry->pgd = pgd),
345 	    TP_printk("mm %p pgd %p", __entry->mm, __entry->pgd)
346 	);
347 #define DEFINE_XEN_MMU_PGD_EVENT(name)				\
348 	DEFINE_EVENT(xen_mmu_pgd, name,				\
349 		TP_PROTO(struct mm_struct *mm, pgd_t *pgd),	\
350 		     TP_ARGS(mm, pgd))
351 
352 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin);
353 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin);
354 
355 TRACE_EVENT(xen_mmu_flush_tlb_one_user,
356 	    TP_PROTO(unsigned long addr),
357 	    TP_ARGS(addr),
358 	    TP_STRUCT__entry(
359 		    __field(unsigned long, addr)
360 		    ),
361 	    TP_fast_assign(__entry->addr = addr),
362 	    TP_printk("addr %lx", __entry->addr)
363 	);
364 
365 TRACE_EVENT(xen_mmu_flush_tlb_others,
366 	    TP_PROTO(const struct cpumask *cpus, struct mm_struct *mm,
367 		     unsigned long addr, unsigned long end),
368 	    TP_ARGS(cpus, mm, addr, end),
369 	    TP_STRUCT__entry(
370 		    __field(unsigned, ncpus)
371 		    __field(struct mm_struct *, mm)
372 		    __field(unsigned long, addr)
373 		    __field(unsigned long, end)
374 		    ),
375 	    TP_fast_assign(__entry->ncpus = cpumask_weight(cpus);
376 			   __entry->mm = mm;
377 			   __entry->addr = addr,
378 			   __entry->end = end),
379 	    TP_printk("ncpus %d mm %p addr %lx, end %lx",
380 		      __entry->ncpus, __entry->mm, __entry->addr, __entry->end)
381 	);
382 
383 TRACE_EVENT(xen_mmu_write_cr3,
384 	    TP_PROTO(bool kernel, unsigned long cr3),
385 	    TP_ARGS(kernel, cr3),
386 	    TP_STRUCT__entry(
387 		    __field(bool, kernel)
388 		    __field(unsigned long, cr3)
389 		    ),
390 	    TP_fast_assign(__entry->kernel = kernel;
391 			   __entry->cr3 = cr3),
392 	    TP_printk("%s cr3 %lx",
393 		      __entry->kernel ? "kernel" : "user", __entry->cr3)
394 	);
395 
396 
397 /* CPU */
398 TRACE_EVENT(xen_cpu_write_ldt_entry,
399 	    TP_PROTO(struct desc_struct *dt, int entrynum, u64 desc),
400 	    TP_ARGS(dt, entrynum, desc),
401 	    TP_STRUCT__entry(
402 		    __field(struct desc_struct *, dt)
403 		    __field(int, entrynum)
404 		    __field(u64, desc)
405 		    ),
406 	    TP_fast_assign(__entry->dt = dt;
407 			   __entry->entrynum = entrynum;
408 			   __entry->desc = desc;
409 		    ),
410 	    TP_printk("dt %p  entrynum %d  entry %016llx",
411 		      __entry->dt, __entry->entrynum,
412 		      (unsigned long long)__entry->desc)
413 	);
414 
415 TRACE_EVENT(xen_cpu_write_idt_entry,
416 	    TP_PROTO(gate_desc *dt, int entrynum, const gate_desc *ent),
417 	    TP_ARGS(dt, entrynum, ent),
418 	    TP_STRUCT__entry(
419 		    __field(gate_desc *, dt)
420 		    __field(int, entrynum)
421 		    ),
422 	    TP_fast_assign(__entry->dt = dt;
423 			   __entry->entrynum = entrynum;
424 		    ),
425 	    TP_printk("dt %p  entrynum %d",
426 		      __entry->dt, __entry->entrynum)
427 	);
428 
429 TRACE_EVENT(xen_cpu_load_idt,
430 	    TP_PROTO(const struct desc_ptr *desc),
431 	    TP_ARGS(desc),
432 	    TP_STRUCT__entry(
433 		    __field(unsigned long, addr)
434 		    ),
435 	    TP_fast_assign(__entry->addr = desc->address),
436 	    TP_printk("addr %lx", __entry->addr)
437 	);
438 
439 TRACE_EVENT(xen_cpu_write_gdt_entry,
440 	    TP_PROTO(struct desc_struct *dt, int entrynum, const void *desc, int type),
441 	    TP_ARGS(dt, entrynum, desc, type),
442 	    TP_STRUCT__entry(
443 		    __field(u64, desc)
444 		    __field(struct desc_struct *, dt)
445 		    __field(int, entrynum)
446 		    __field(int, type)
447 		    ),
448 	    TP_fast_assign(__entry->dt = dt;
449 			   __entry->entrynum = entrynum;
450 			   __entry->desc = *(u64 *)desc;
451 			   __entry->type = type;
452 		    ),
453 	    TP_printk("dt %p  entrynum %d  type %d  desc %016llx",
454 		      __entry->dt, __entry->entrynum, __entry->type,
455 		      (unsigned long long)__entry->desc)
456 	);
457 
458 TRACE_EVENT(xen_cpu_set_ldt,
459 	    TP_PROTO(const void *addr, unsigned entries),
460 	    TP_ARGS(addr, entries),
461 	    TP_STRUCT__entry(
462 		    __field(const void *, addr)
463 		    __field(unsigned, entries)
464 		    ),
465 	    TP_fast_assign(__entry->addr = addr;
466 			   __entry->entries = entries),
467 	    TP_printk("addr %p  entries %u",
468 		      __entry->addr, __entry->entries)
469 	);
470 
471 
472 #endif /*  _TRACE_XEN_H */
473 
474 /* This part must be outside protection */
475 #include <trace/define_trace.h>
476