1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM xen
5 #if !defined(_TRACE_XEN_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/tracepoint.h>
9 #include <asm/paravirt_types.h>
10 #include <asm/xen/trace_types.h>
12 struct multicall_entry
;
15 DECLARE_EVENT_CLASS(xen_mc__batch
,
16 TP_PROTO(enum paravirt_lazy_mode mode
),
19 __field(enum paravirt_lazy_mode
, mode
)
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")
26 #define DEFINE_XEN_MC_BATCH(name) \
27 DEFINE_EVENT(xen_mc__batch, name, \
28 TP_PROTO(enum paravirt_lazy_mode mode), \
31 DEFINE_XEN_MC_BATCH(xen_mc_batch
);
32 DEFINE_XEN_MC_BATCH(xen_mc_issue
);
34 TRACE_DEFINE_SIZEOF(ulong
);
36 TRACE_EVENT(xen_mc_entry
,
37 TP_PROTO(struct multicall_entry
*mc
, unsigned nargs
),
40 __field(unsigned int, op
)
41 __field(unsigned int, nargs
)
42 __array(unsigned long, args
, 6)
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
));
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])
55 TRACE_EVENT(xen_mc_entry_alloc
,
56 TP_PROTO(size_t args
),
61 TP_fast_assign(__entry
->args
= args
),
62 TP_printk("alloc entry %zu arg bytes", __entry
->args
)
65 TRACE_EVENT(xen_mc_callback
,
66 TP_PROTO(xen_mc_callback_fn_t fn
, void *data
),
70 * Use field_struct to avoid is_signed_type()
71 * comparison of a function pointer.
73 __field_struct(xen_mc_callback_fn_t
, fn
)
80 TP_printk("callback %ps, data %p",
81 __entry
->fn
, __entry
->data
)
84 TRACE_EVENT(xen_mc_flush_reason
,
85 TP_PROTO(enum xen_mc_flush_reason reason
),
88 __field(enum xen_mc_flush_reason
, reason
)
90 TP_fast_assign(__entry
->reason
= reason
),
91 TP_printk("flush reason %s",
92 (__entry
->reason
== XEN_MC_FL_NONE
) ? "NONE" :
93 (__entry
->reason
== XEN_MC_FL_BATCH
) ? "BATCH" :
94 (__entry
->reason
== XEN_MC_FL_ARGS
) ? "ARGS" :
95 (__entry
->reason
== XEN_MC_FL_CALLBACK
) ? "CALLBACK" : "??")
98 TRACE_EVENT(xen_mc_flush
,
99 TP_PROTO(unsigned mcidx
, unsigned argidx
, unsigned cbidx
),
100 TP_ARGS(mcidx
, argidx
, cbidx
),
102 __field(unsigned, mcidx
)
103 __field(unsigned, argidx
)
104 __field(unsigned, cbidx
)
106 TP_fast_assign(__entry
->mcidx
= mcidx
;
107 __entry
->argidx
= argidx
;
108 __entry
->cbidx
= cbidx
),
109 TP_printk("flushing %u hypercalls, %u arg bytes, %u callbacks",
110 __entry
->mcidx
, __entry
->argidx
, __entry
->cbidx
)
113 TRACE_EVENT(xen_mc_extend_args
,
114 TP_PROTO(unsigned long op
, size_t args
, enum xen_mc_extend_args res
),
115 TP_ARGS(op
, args
, res
),
117 __field(unsigned int, op
)
118 __field(size_t, args
)
119 __field(enum xen_mc_extend_args
, res
)
121 TP_fast_assign(__entry
->op
= op
;
122 __entry
->args
= args
;
124 TP_printk("extending op %u%s by %zu bytes res %s",
125 __entry
->op
, xen_hypercall_name(__entry
->op
),
127 __entry
->res
== XEN_MC_XE_OK
? "OK" :
128 __entry
->res
== XEN_MC_XE_BAD_OP
? "BAD_OP" :
129 __entry
->res
== XEN_MC_XE_NO_SPACE
? "NO_SPACE" : "???")
132 TRACE_DEFINE_SIZEOF(pteval_t
);
134 DECLARE_EVENT_CLASS(xen_mmu__set_pte
,
135 TP_PROTO(pte_t
*ptep
, pte_t pteval
),
136 TP_ARGS(ptep
, pteval
),
138 __field(pte_t
*, ptep
)
139 __field(pteval_t
, pteval
)
141 TP_fast_assign(__entry
->ptep
= ptep
;
142 __entry
->pteval
= pteval
.pte
),
143 TP_printk("ptep %p pteval %0*llx (raw %0*llx)",
145 (int)sizeof(pteval_t
) * 2, (unsigned long long)pte_val(native_make_pte(__entry
->pteval
)),
146 (int)sizeof(pteval_t
) * 2, (unsigned long long)__entry
->pteval
)
149 #define DEFINE_XEN_MMU_SET_PTE(name) \
150 DEFINE_EVENT(xen_mmu__set_pte, name, \
151 TP_PROTO(pte_t *ptep, pte_t pteval), \
152 TP_ARGS(ptep, pteval))
154 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte
);
156 TRACE_EVENT(xen_mmu_set_pte_at
,
157 TP_PROTO(struct mm_struct
*mm
, unsigned long addr
,
158 pte_t
*ptep
, pte_t pteval
),
159 TP_ARGS(mm
, addr
, ptep
, pteval
),
161 __field(struct mm_struct
*, mm
)
162 __field(unsigned long, addr
)
163 __field(pte_t
*, ptep
)
164 __field(pteval_t
, pteval
)
166 TP_fast_assign(__entry
->mm
= mm
;
167 __entry
->addr
= addr
;
168 __entry
->ptep
= ptep
;
169 __entry
->pteval
= pteval
.pte
),
170 TP_printk("mm %p addr %lx ptep %p pteval %0*llx (raw %0*llx)",
171 __entry
->mm
, __entry
->addr
, __entry
->ptep
,
172 (int)sizeof(pteval_t
) * 2, (unsigned long long)pte_val(native_make_pte(__entry
->pteval
)),
173 (int)sizeof(pteval_t
) * 2, (unsigned long long)__entry
->pteval
)
176 TRACE_DEFINE_SIZEOF(pmdval_t
);
178 TRACE_EVENT(xen_mmu_set_pmd
,
179 TP_PROTO(pmd_t
*pmdp
, pmd_t pmdval
),
180 TP_ARGS(pmdp
, pmdval
),
182 __field(pmd_t
*, pmdp
)
183 __field(pmdval_t
, pmdval
)
185 TP_fast_assign(__entry
->pmdp
= pmdp
;
186 __entry
->pmdval
= pmdval
.pmd
),
187 TP_printk("pmdp %p pmdval %0*llx (raw %0*llx)",
189 (int)sizeof(pmdval_t
) * 2, (unsigned long long)pmd_val(native_make_pmd(__entry
->pmdval
)),
190 (int)sizeof(pmdval_t
) * 2, (unsigned long long)__entry
->pmdval
)
193 #ifdef CONFIG_X86_PAE
194 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte_atomic
);
196 TRACE_EVENT(xen_mmu_pte_clear
,
197 TP_PROTO(struct mm_struct
*mm
, unsigned long addr
, pte_t
*ptep
),
198 TP_ARGS(mm
, addr
, ptep
),
200 __field(struct mm_struct
*, mm
)
201 __field(unsigned long, addr
)
202 __field(pte_t
*, ptep
)
204 TP_fast_assign(__entry
->mm
= mm
;
205 __entry
->addr
= addr
;
206 __entry
->ptep
= ptep
),
207 TP_printk("mm %p addr %lx ptep %p",
208 __entry
->mm
, __entry
->addr
, __entry
->ptep
)
211 TRACE_EVENT(xen_mmu_pmd_clear
,
212 TP_PROTO(pmd_t
*pmdp
),
215 __field(pmd_t
*, pmdp
)
217 TP_fast_assign(__entry
->pmdp
= pmdp
),
218 TP_printk("pmdp %p", __entry
->pmdp
)
222 #if CONFIG_PGTABLE_LEVELS >= 4
224 TRACE_DEFINE_SIZEOF(pudval_t
);
226 TRACE_EVENT(xen_mmu_set_pud
,
227 TP_PROTO(pud_t
*pudp
, pud_t pudval
),
228 TP_ARGS(pudp
, pudval
),
230 __field(pud_t
*, pudp
)
231 __field(pudval_t
, pudval
)
233 TP_fast_assign(__entry
->pudp
= pudp
;
234 __entry
->pudval
= native_pud_val(pudval
)),
235 TP_printk("pudp %p pudval %0*llx (raw %0*llx)",
237 (int)sizeof(pudval_t
) * 2, (unsigned long long)pud_val(native_make_pud(__entry
->pudval
)),
238 (int)sizeof(pudval_t
) * 2, (unsigned long long)__entry
->pudval
)
241 TRACE_DEFINE_SIZEOF(p4dval_t
);
243 TRACE_EVENT(xen_mmu_set_p4d
,
244 TP_PROTO(p4d_t
*p4dp
, p4d_t
*user_p4dp
, p4d_t p4dval
),
245 TP_ARGS(p4dp
, user_p4dp
, p4dval
),
247 __field(p4d_t
*, p4dp
)
248 __field(p4d_t
*, user_p4dp
)
249 __field(p4dval_t
, p4dval
)
251 TP_fast_assign(__entry
->p4dp
= p4dp
;
252 __entry
->user_p4dp
= user_p4dp
;
253 __entry
->p4dval
= p4d_val(p4dval
)),
254 TP_printk("p4dp %p user_p4dp %p p4dval %0*llx (raw %0*llx)",
255 __entry
->p4dp
, __entry
->user_p4dp
,
256 (int)sizeof(p4dval_t
) * 2, (unsigned long long)pgd_val(native_make_pgd(__entry
->p4dval
)),
257 (int)sizeof(p4dval_t
) * 2, (unsigned long long)__entry
->p4dval
)
261 TRACE_EVENT(xen_mmu_set_pud
,
262 TP_PROTO(pud_t
*pudp
, pud_t pudval
),
263 TP_ARGS(pudp
, pudval
),
265 __field(pud_t
*, pudp
)
266 __field(pudval_t
, pudval
)
268 TP_fast_assign(__entry
->pudp
= pudp
;
269 __entry
->pudval
= native_pud_val(pudval
)),
270 TP_printk("pudp %p pudval %0*llx (raw %0*llx)",
272 (int)sizeof(pudval_t
) * 2, (unsigned long long)pgd_val(native_make_pgd(__entry
->pudval
)),
273 (int)sizeof(pudval_t
) * 2, (unsigned long long)__entry
->pudval
)
278 DECLARE_EVENT_CLASS(xen_mmu_ptep_modify_prot
,
279 TP_PROTO(struct mm_struct
*mm
, unsigned long addr
,
280 pte_t
*ptep
, pte_t pteval
),
281 TP_ARGS(mm
, addr
, ptep
, pteval
),
283 __field(struct mm_struct
*, mm
)
284 __field(unsigned long, addr
)
285 __field(pte_t
*, ptep
)
286 __field(pteval_t
, pteval
)
288 TP_fast_assign(__entry
->mm
= mm
;
289 __entry
->addr
= addr
;
290 __entry
->ptep
= ptep
;
291 __entry
->pteval
= pteval
.pte
),
292 TP_printk("mm %p addr %lx ptep %p pteval %0*llx (raw %0*llx)",
293 __entry
->mm
, __entry
->addr
, __entry
->ptep
,
294 (int)sizeof(pteval_t
) * 2, (unsigned long long)pte_val(native_make_pte(__entry
->pteval
)),
295 (int)sizeof(pteval_t
) * 2, (unsigned long long)__entry
->pteval
)
297 #define DEFINE_XEN_MMU_PTEP_MODIFY_PROT(name) \
298 DEFINE_EVENT(xen_mmu_ptep_modify_prot, name, \
299 TP_PROTO(struct mm_struct *mm, unsigned long addr, \
300 pte_t *ptep, pte_t pteval), \
301 TP_ARGS(mm, addr, ptep, pteval))
303 DEFINE_XEN_MMU_PTEP_MODIFY_PROT(xen_mmu_ptep_modify_prot_start
);
304 DEFINE_XEN_MMU_PTEP_MODIFY_PROT(xen_mmu_ptep_modify_prot_commit
);
306 TRACE_EVENT(xen_mmu_alloc_ptpage
,
307 TP_PROTO(struct mm_struct
*mm
, unsigned long pfn
, unsigned level
, bool pinned
),
308 TP_ARGS(mm
, pfn
, level
, pinned
),
310 __field(struct mm_struct
*, mm
)
311 __field(unsigned long, pfn
)
312 __field(unsigned, level
)
313 __field(bool, pinned
)
315 TP_fast_assign(__entry
->mm
= mm
;
317 __entry
->level
= level
;
318 __entry
->pinned
= pinned
),
319 TP_printk("mm %p pfn %lx level %d %spinned",
320 __entry
->mm
, __entry
->pfn
, __entry
->level
,
321 __entry
->pinned
? "" : "un")
324 TRACE_EVENT(xen_mmu_release_ptpage
,
325 TP_PROTO(unsigned long pfn
, unsigned level
, bool pinned
),
326 TP_ARGS(pfn
, level
, pinned
),
328 __field(unsigned long, pfn
)
329 __field(unsigned, level
)
330 __field(bool, pinned
)
332 TP_fast_assign(__entry
->pfn
= pfn
;
333 __entry
->level
= level
;
334 __entry
->pinned
= pinned
),
335 TP_printk("pfn %lx level %d %spinned",
336 __entry
->pfn
, __entry
->level
,
337 __entry
->pinned
? "" : "un")
340 DECLARE_EVENT_CLASS(xen_mmu_pgd
,
341 TP_PROTO(struct mm_struct
*mm
, pgd_t
*pgd
),
344 __field(struct mm_struct
*, mm
)
345 __field(pgd_t
*, pgd
)
347 TP_fast_assign(__entry
->mm
= mm
;
349 TP_printk("mm %p pgd %p", __entry
->mm
, __entry
->pgd
)
351 #define DEFINE_XEN_MMU_PGD_EVENT(name) \
352 DEFINE_EVENT(xen_mmu_pgd, name, \
353 TP_PROTO(struct mm_struct *mm, pgd_t *pgd), \
356 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin
);
357 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin
);
359 TRACE_EVENT(xen_mmu_flush_tlb_one_user
,
360 TP_PROTO(unsigned long addr
),
363 __field(unsigned long, addr
)
365 TP_fast_assign(__entry
->addr
= addr
),
366 TP_printk("addr %lx", __entry
->addr
)
369 TRACE_EVENT(xen_mmu_flush_tlb_others
,
370 TP_PROTO(const struct cpumask
*cpus
, struct mm_struct
*mm
,
371 unsigned long addr
, unsigned long end
),
372 TP_ARGS(cpus
, mm
, addr
, end
),
374 __field(unsigned, ncpus
)
375 __field(struct mm_struct
*, mm
)
376 __field(unsigned long, addr
)
377 __field(unsigned long, end
)
379 TP_fast_assign(__entry
->ncpus
= cpumask_weight(cpus
);
381 __entry
->addr
= addr
,
383 TP_printk("ncpus %d mm %p addr %lx, end %lx",
384 __entry
->ncpus
, __entry
->mm
, __entry
->addr
, __entry
->end
)
387 TRACE_EVENT(xen_mmu_write_cr3
,
388 TP_PROTO(bool kernel
, unsigned long cr3
),
389 TP_ARGS(kernel
, cr3
),
391 __field(bool, kernel
)
392 __field(unsigned long, cr3
)
394 TP_fast_assign(__entry
->kernel
= kernel
;
396 TP_printk("%s cr3 %lx",
397 __entry
->kernel
? "kernel" : "user", __entry
->cr3
)
402 TRACE_EVENT(xen_cpu_write_ldt_entry
,
403 TP_PROTO(struct desc_struct
*dt
, int entrynum
, u64 desc
),
404 TP_ARGS(dt
, entrynum
, desc
),
406 __field(struct desc_struct
*, dt
)
407 __field(int, entrynum
)
410 TP_fast_assign(__entry
->dt
= dt
;
411 __entry
->entrynum
= entrynum
;
412 __entry
->desc
= desc
;
414 TP_printk("dt %p entrynum %d entry %016llx",
415 __entry
->dt
, __entry
->entrynum
,
416 (unsigned long long)__entry
->desc
)
419 TRACE_EVENT(xen_cpu_write_idt_entry
,
420 TP_PROTO(gate_desc
*dt
, int entrynum
, const gate_desc
*ent
),
421 TP_ARGS(dt
, entrynum
, ent
),
423 __field(gate_desc
*, dt
)
424 __field(int, entrynum
)
426 TP_fast_assign(__entry
->dt
= dt
;
427 __entry
->entrynum
= entrynum
;
429 TP_printk("dt %p entrynum %d",
430 __entry
->dt
, __entry
->entrynum
)
433 TRACE_EVENT(xen_cpu_load_idt
,
434 TP_PROTO(const struct desc_ptr
*desc
),
437 __field(unsigned long, addr
)
439 TP_fast_assign(__entry
->addr
= desc
->address
),
440 TP_printk("addr %lx", __entry
->addr
)
443 TRACE_EVENT(xen_cpu_write_gdt_entry
,
444 TP_PROTO(struct desc_struct
*dt
, int entrynum
, const void *desc
, int type
),
445 TP_ARGS(dt
, entrynum
, desc
, type
),
448 __field(struct desc_struct
*, dt
)
449 __field(int, entrynum
)
452 TP_fast_assign(__entry
->dt
= dt
;
453 __entry
->entrynum
= entrynum
;
454 __entry
->desc
= *(u64
*)desc
;
455 __entry
->type
= type
;
457 TP_printk("dt %p entrynum %d type %d desc %016llx",
458 __entry
->dt
, __entry
->entrynum
, __entry
->type
,
459 (unsigned long long)__entry
->desc
)
462 TRACE_EVENT(xen_cpu_set_ldt
,
463 TP_PROTO(const void *addr
, unsigned entries
),
464 TP_ARGS(addr
, entries
),
466 __field(const void *, addr
)
467 __field(unsigned, entries
)
469 TP_fast_assign(__entry
->addr
= addr
;
470 __entry
->entries
= entries
),
471 TP_printk("addr %p entries %u",
472 __entry
->addr
, __entry
->entries
)
476 #endif /* _TRACE_XEN_H */
478 /* This part must be outside protection */
479 #include <trace/define_trace.h>