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 /* 70 * Use field_struct to avoid is_signed_type() 71 * comparison of a function pointer. 72 */ 73 __field_struct(xen_mc_callback_fn_t, fn) 74 __field(void *, data) 75 ), 76 TP_fast_assign( 77 __entry->fn = fn; 78 __entry->data = data; 79 ), 80 TP_printk("callback %ps, data %p", 81 __entry->fn, __entry->data) 82 ); 83 84 TRACE_EVENT(xen_mc_flush_reason, 85 TP_PROTO(enum xen_mc_flush_reason reason), 86 TP_ARGS(reason), 87 TP_STRUCT__entry( 88 __field(enum xen_mc_flush_reason, reason) 89 ), 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" : "??") 96 ); 97 98 TRACE_EVENT(xen_mc_flush, 99 TP_PROTO(unsigned mcidx, unsigned argidx, unsigned cbidx), 100 TP_ARGS(mcidx, argidx, cbidx), 101 TP_STRUCT__entry( 102 __field(unsigned, mcidx) 103 __field(unsigned, argidx) 104 __field(unsigned, cbidx) 105 ), 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) 111 ); 112 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), 116 TP_STRUCT__entry( 117 __field(unsigned int, op) 118 __field(size_t, args) 119 __field(enum xen_mc_extend_args, res) 120 ), 121 TP_fast_assign(__entry->op = op; 122 __entry->args = args; 123 __entry->res = res), 124 TP_printk("extending op %u%s by %zu bytes res %s", 125 __entry->op, xen_hypercall_name(__entry->op), 126 __entry->args, 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" : "???") 130 ); 131 132 TRACE_DEFINE_SIZEOF(pteval_t); 133 /* mmu */ 134 DECLARE_EVENT_CLASS(xen_mmu__set_pte, 135 TP_PROTO(pte_t *ptep, pte_t pteval), 136 TP_ARGS(ptep, pteval), 137 TP_STRUCT__entry( 138 __field(pte_t *, ptep) 139 __field(pteval_t, pteval) 140 ), 141 TP_fast_assign(__entry->ptep = ptep; 142 __entry->pteval = pteval.pte), 143 TP_printk("ptep %p pteval %0*llx (raw %0*llx)", 144 __entry->ptep, 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) 147 ); 148 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)) 153 154 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte); 155 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), 160 TP_STRUCT__entry( 161 __field(struct mm_struct *, mm) 162 __field(unsigned long, addr) 163 __field(pte_t *, ptep) 164 __field(pteval_t, pteval) 165 ), 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) 174 ); 175 176 TRACE_DEFINE_SIZEOF(pmdval_t); 177 178 TRACE_EVENT(xen_mmu_set_pmd, 179 TP_PROTO(pmd_t *pmdp, pmd_t pmdval), 180 TP_ARGS(pmdp, pmdval), 181 TP_STRUCT__entry( 182 __field(pmd_t *, pmdp) 183 __field(pmdval_t, pmdval) 184 ), 185 TP_fast_assign(__entry->pmdp = pmdp; 186 __entry->pmdval = pmdval.pmd), 187 TP_printk("pmdp %p pmdval %0*llx (raw %0*llx)", 188 __entry->pmdp, 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) 191 ); 192 193 #ifdef CONFIG_X86_PAE 194 DEFINE_XEN_MMU_SET_PTE(xen_mmu_set_pte_atomic); 195 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), 199 TP_STRUCT__entry( 200 __field(struct mm_struct *, mm) 201 __field(unsigned long, addr) 202 __field(pte_t *, ptep) 203 ), 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) 209 ); 210 211 TRACE_EVENT(xen_mmu_pmd_clear, 212 TP_PROTO(pmd_t *pmdp), 213 TP_ARGS(pmdp), 214 TP_STRUCT__entry( 215 __field(pmd_t *, pmdp) 216 ), 217 TP_fast_assign(__entry->pmdp = pmdp), 218 TP_printk("pmdp %p", __entry->pmdp) 219 ); 220 #endif 221 222 #if CONFIG_PGTABLE_LEVELS >= 4 223 224 TRACE_DEFINE_SIZEOF(pudval_t); 225 226 TRACE_EVENT(xen_mmu_set_pud, 227 TP_PROTO(pud_t *pudp, pud_t pudval), 228 TP_ARGS(pudp, pudval), 229 TP_STRUCT__entry( 230 __field(pud_t *, pudp) 231 __field(pudval_t, pudval) 232 ), 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)", 236 __entry->pudp, 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) 239 ); 240 241 TRACE_DEFINE_SIZEOF(p4dval_t); 242 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), 246 TP_STRUCT__entry( 247 __field(p4d_t *, p4dp) 248 __field(p4d_t *, user_p4dp) 249 __field(p4dval_t, p4dval) 250 ), 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) 258 ); 259 #else 260 261 TRACE_EVENT(xen_mmu_set_pud, 262 TP_PROTO(pud_t *pudp, pud_t pudval), 263 TP_ARGS(pudp, pudval), 264 TP_STRUCT__entry( 265 __field(pud_t *, pudp) 266 __field(pudval_t, pudval) 267 ), 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)", 271 __entry->pudp, 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) 274 ); 275 276 #endif 277 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), 282 TP_STRUCT__entry( 283 __field(struct mm_struct *, mm) 284 __field(unsigned long, addr) 285 __field(pte_t *, ptep) 286 __field(pteval_t, pteval) 287 ), 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) 296 ); 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)) 302 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); 305 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), 309 TP_STRUCT__entry( 310 __field(struct mm_struct *, mm) 311 __field(unsigned long, pfn) 312 __field(unsigned, level) 313 __field(bool, pinned) 314 ), 315 TP_fast_assign(__entry->mm = mm; 316 __entry->pfn = pfn; 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") 322 ); 323 324 TRACE_EVENT(xen_mmu_release_ptpage, 325 TP_PROTO(unsigned long pfn, unsigned level, bool pinned), 326 TP_ARGS(pfn, level, pinned), 327 TP_STRUCT__entry( 328 __field(unsigned long, pfn) 329 __field(unsigned, level) 330 __field(bool, pinned) 331 ), 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") 338 ); 339 340 DECLARE_EVENT_CLASS(xen_mmu_pgd, 341 TP_PROTO(struct mm_struct *mm, pgd_t *pgd), 342 TP_ARGS(mm, pgd), 343 TP_STRUCT__entry( 344 __field(struct mm_struct *, mm) 345 __field(pgd_t *, pgd) 346 ), 347 TP_fast_assign(__entry->mm = mm; 348 __entry->pgd = pgd), 349 TP_printk("mm %p pgd %p", __entry->mm, __entry->pgd) 350 ); 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), \ 354 TP_ARGS(mm, pgd)) 355 356 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin); 357 DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin); 358 359 TRACE_EVENT(xen_mmu_flush_tlb_one_user, 360 TP_PROTO(unsigned long addr), 361 TP_ARGS(addr), 362 TP_STRUCT__entry( 363 __field(unsigned long, addr) 364 ), 365 TP_fast_assign(__entry->addr = addr), 366 TP_printk("addr %lx", __entry->addr) 367 ); 368 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), 373 TP_STRUCT__entry( 374 __field(unsigned, ncpus) 375 __field(struct mm_struct *, mm) 376 __field(unsigned long, addr) 377 __field(unsigned long, end) 378 ), 379 TP_fast_assign(__entry->ncpus = cpumask_weight(cpus); 380 __entry->mm = mm; 381 __entry->addr = addr, 382 __entry->end = end), 383 TP_printk("ncpus %d mm %p addr %lx, end %lx", 384 __entry->ncpus, __entry->mm, __entry->addr, __entry->end) 385 ); 386 387 TRACE_EVENT(xen_mmu_write_cr3, 388 TP_PROTO(bool kernel, unsigned long cr3), 389 TP_ARGS(kernel, cr3), 390 TP_STRUCT__entry( 391 __field(bool, kernel) 392 __field(unsigned long, cr3) 393 ), 394 TP_fast_assign(__entry->kernel = kernel; 395 __entry->cr3 = cr3), 396 TP_printk("%s cr3 %lx", 397 __entry->kernel ? "kernel" : "user", __entry->cr3) 398 ); 399 400 401 /* CPU */ 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), 405 TP_STRUCT__entry( 406 __field(struct desc_struct *, dt) 407 __field(int, entrynum) 408 __field(u64, desc) 409 ), 410 TP_fast_assign(__entry->dt = dt; 411 __entry->entrynum = entrynum; 412 __entry->desc = desc; 413 ), 414 TP_printk("dt %p entrynum %d entry %016llx", 415 __entry->dt, __entry->entrynum, 416 (unsigned long long)__entry->desc) 417 ); 418 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), 422 TP_STRUCT__entry( 423 __field(gate_desc *, dt) 424 __field(int, entrynum) 425 ), 426 TP_fast_assign(__entry->dt = dt; 427 __entry->entrynum = entrynum; 428 ), 429 TP_printk("dt %p entrynum %d", 430 __entry->dt, __entry->entrynum) 431 ); 432 433 TRACE_EVENT(xen_cpu_load_idt, 434 TP_PROTO(const struct desc_ptr *desc), 435 TP_ARGS(desc), 436 TP_STRUCT__entry( 437 __field(unsigned long, addr) 438 ), 439 TP_fast_assign(__entry->addr = desc->address), 440 TP_printk("addr %lx", __entry->addr) 441 ); 442 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), 446 TP_STRUCT__entry( 447 __field(u64, desc) 448 __field(struct desc_struct *, dt) 449 __field(int, entrynum) 450 __field(int, type) 451 ), 452 TP_fast_assign(__entry->dt = dt; 453 __entry->entrynum = entrynum; 454 __entry->desc = *(u64 *)desc; 455 __entry->type = type; 456 ), 457 TP_printk("dt %p entrynum %d type %d desc %016llx", 458 __entry->dt, __entry->entrynum, __entry->type, 459 (unsigned long long)__entry->desc) 460 ); 461 462 TRACE_EVENT(xen_cpu_set_ldt, 463 TP_PROTO(const void *addr, unsigned entries), 464 TP_ARGS(addr, entries), 465 TP_STRUCT__entry( 466 __field(const void *, addr) 467 __field(unsigned, entries) 468 ), 469 TP_fast_assign(__entry->addr = addr; 470 __entry->entries = entries), 471 TP_printk("addr %p entries %u", 472 __entry->addr, __entry->entries) 473 ); 474 475 476 #endif /* _TRACE_XEN_H */ 477 478 /* This part must be outside protection */ 479 #include <trace/define_trace.h> 480