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
),
69 __field(xen_mc_callback_fn_t
, fn
)
76 TP_printk("callback %pf, data %p",
77 __entry
->fn
, __entry
->data
)
80 TRACE_EVENT(xen_mc_flush_reason
,
81 TP_PROTO(enum xen_mc_flush_reason reason
),
84 __field(enum xen_mc_flush_reason
, reason
)
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" : "??")
94 TRACE_EVENT(xen_mc_flush
,
95 TP_PROTO(unsigned mcidx
, unsigned argidx
, unsigned cbidx
),
96 TP_ARGS(mcidx
, argidx
, cbidx
),
98 __field(unsigned, mcidx
)
99 __field(unsigned, argidx
)
100 __field(unsigned, cbidx
)
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
)
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
),
113 __field(unsigned int, op
)
114 __field(size_t, args
)
115 __field(enum xen_mc_extend_args
, res
)
117 TP_fast_assign(__entry
->op
= op
;
118 __entry
->args
= args
;
120 TP_printk("extending op %u%s by %zu bytes res %s",
121 __entry
->op
, xen_hypercall_name(__entry
->op
),
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" : "???")
128 TRACE_DEFINE_SIZEOF(pteval_t
);
130 DECLARE_EVENT_CLASS(xen_mmu__set_pte
,
131 TP_PROTO(pte_t
*ptep
, pte_t pteval
),
132 TP_ARGS(ptep
, pteval
),
134 __field(pte_t
*, ptep
)
135 __field(pteval_t
, pteval
)
137 TP_fast_assign(__entry
->ptep
= ptep
;
138 __entry
->pteval
= pteval
.pte
),
139 TP_printk("ptep %p pteval %0*llx (raw %0*llx)",
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
)
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))
150 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte
);
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
),
157 __field(struct mm_struct
*, mm
)
158 __field(unsigned long, addr
)
159 __field(pte_t
*, ptep
)
160 __field(pteval_t
, pteval
)
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
)
172 TRACE_DEFINE_SIZEOF(pmdval_t
);
174 TRACE_EVENT(xen_mmu_set_pmd
,
175 TP_PROTO(pmd_t
*pmdp
, pmd_t pmdval
),
176 TP_ARGS(pmdp
, pmdval
),
178 __field(pmd_t
*, pmdp
)
179 __field(pmdval_t
, pmdval
)
181 TP_fast_assign(__entry
->pmdp
= pmdp
;
182 __entry
->pmdval
= pmdval
.pmd
),
183 TP_printk("pmdp %p pmdval %0*llx (raw %0*llx)",
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
)
189 #ifdef CONFIG_X86_PAE
190 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte_atomic
);
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
),
196 __field(struct mm_struct
*, mm
)
197 __field(unsigned long, addr
)
198 __field(pte_t
*, ptep
)
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
)
207 TRACE_EVENT(xen_mmu_pmd_clear
,
208 TP_PROTO(pmd_t
*pmdp
),
211 __field(pmd_t
*, pmdp
)
213 TP_fast_assign(__entry
->pmdp
= pmdp
),
214 TP_printk("pmdp %p", __entry
->pmdp
)
218 #if CONFIG_PGTABLE_LEVELS >= 4
220 TRACE_DEFINE_SIZEOF(pudval_t
);
222 TRACE_EVENT(xen_mmu_set_pud
,
223 TP_PROTO(pud_t
*pudp
, pud_t pudval
),
224 TP_ARGS(pudp
, pudval
),
226 __field(pud_t
*, pudp
)
227 __field(pudval_t
, pudval
)
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)",
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
)
237 TRACE_DEFINE_SIZEOF(p4dval_t
);
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
),
243 __field(p4d_t
*, p4dp
)
244 __field(p4d_t
*, user_p4dp
)
245 __field(p4dval_t
, p4dval
)
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
)
257 TRACE_EVENT(xen_mmu_set_pud
,
258 TP_PROTO(pud_t
*pudp
, pud_t pudval
),
259 TP_ARGS(pudp
, pudval
),
261 __field(pud_t
*, pudp
)
262 __field(pudval_t
, pudval
)
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)",
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
)
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
),
279 __field(struct mm_struct
*, mm
)
280 __field(unsigned long, addr
)
281 __field(pte_t
*, ptep
)
282 __field(pteval_t
, pteval
)
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
)
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))
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
);
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
),
306 __field(struct mm_struct
*, mm
)
307 __field(unsigned long, pfn
)
308 __field(unsigned, level
)
309 __field(bool, pinned
)
311 TP_fast_assign(__entry
->mm
= mm
;
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")
320 TRACE_EVENT(xen_mmu_release_ptpage
,
321 TP_PROTO(unsigned long pfn
, unsigned level
, bool pinned
),
322 TP_ARGS(pfn
, level
, pinned
),
324 __field(unsigned long, pfn
)
325 __field(unsigned, level
)
326 __field(bool, pinned
)
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")
336 DECLARE_EVENT_CLASS(xen_mmu_pgd
,
337 TP_PROTO(struct mm_struct
*mm
, pgd_t
*pgd
),
340 __field(struct mm_struct
*, mm
)
341 __field(pgd_t
*, pgd
)
343 TP_fast_assign(__entry
->mm
= mm
;
345 TP_printk("mm %p pgd %p", __entry
->mm
, __entry
->pgd
)
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), \
352 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin
);
353 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin
);
355 TRACE_EVENT(xen_mmu_flush_tlb_one_user
,
356 TP_PROTO(unsigned long addr
),
359 __field(unsigned long, addr
)
361 TP_fast_assign(__entry
->addr
= addr
),
362 TP_printk("addr %lx", __entry
->addr
)
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
),
370 __field(unsigned, ncpus
)
371 __field(struct mm_struct
*, mm
)
372 __field(unsigned long, addr
)
373 __field(unsigned long, end
)
375 TP_fast_assign(__entry
->ncpus
= cpumask_weight(cpus
);
377 __entry
->addr
= addr
,
379 TP_printk("ncpus %d mm %p addr %lx, end %lx",
380 __entry
->ncpus
, __entry
->mm
, __entry
->addr
, __entry
->end
)
383 TRACE_EVENT(xen_mmu_write_cr3
,
384 TP_PROTO(bool kernel
, unsigned long cr3
),
385 TP_ARGS(kernel
, cr3
),
387 __field(bool, kernel
)
388 __field(unsigned long, cr3
)
390 TP_fast_assign(__entry
->kernel
= kernel
;
392 TP_printk("%s cr3 %lx",
393 __entry
->kernel
? "kernel" : "user", __entry
->cr3
)
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
),
402 __field(struct desc_struct
*, dt
)
403 __field(int, entrynum
)
406 TP_fast_assign(__entry
->dt
= dt
;
407 __entry
->entrynum
= entrynum
;
408 __entry
->desc
= desc
;
410 TP_printk("dt %p entrynum %d entry %016llx",
411 __entry
->dt
, __entry
->entrynum
,
412 (unsigned long long)__entry
->desc
)
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
),
419 __field(gate_desc
*, dt
)
420 __field(int, entrynum
)
422 TP_fast_assign(__entry
->dt
= dt
;
423 __entry
->entrynum
= entrynum
;
425 TP_printk("dt %p entrynum %d",
426 __entry
->dt
, __entry
->entrynum
)
429 TRACE_EVENT(xen_cpu_load_idt
,
430 TP_PROTO(const struct desc_ptr
*desc
),
433 __field(unsigned long, addr
)
435 TP_fast_assign(__entry
->addr
= desc
->address
),
436 TP_printk("addr %lx", __entry
->addr
)
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
),
444 __field(struct desc_struct
*, dt
)
445 __field(int, entrynum
)
448 TP_fast_assign(__entry
->dt
= dt
;
449 __entry
->entrynum
= entrynum
;
450 __entry
->desc
= *(u64
*)desc
;
451 __entry
->type
= type
;
453 TP_printk("dt %p entrynum %d type %d desc %016llx",
454 __entry
->dt
, __entry
->entrynum
, __entry
->type
,
455 (unsigned long long)__entry
->desc
)
458 TRACE_EVENT(xen_cpu_set_ldt
,
459 TP_PROTO(const void *addr
, unsigned entries
),
460 TP_ARGS(addr
, entries
),
462 __field(const void *, addr
)
463 __field(unsigned, entries
)
465 TP_fast_assign(__entry
->addr
= addr
;
466 __entry
->entries
= entries
),
467 TP_printk("addr %p entries %u",
468 __entry
->addr
, __entry
->entries
)
472 #endif /* _TRACE_XEN_H */
474 /* This part must be outside protection */
475 #include <trace/define_trace.h>