1 #if !defined(_TRACE_KVMMMU_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define _TRACE_KVMMMU_H
4 #include <linux/tracepoint.h>
5 #include <linux/ftrace_event.h>
8 #define TRACE_SYSTEM kvmmmu
9 #define TRACE_INCLUDE_PATH .
10 #define TRACE_INCLUDE_FILE mmutrace
12 #define KVM_MMU_PAGE_FIELDS \
14 __field(__u32, role) \
15 __field(__u32, root_count) \
16 __field(__u32, unsync)
18 #define KVM_MMU_PAGE_ASSIGN(sp) \
19 __entry->gfn = sp->gfn; \
20 __entry->role = sp->role.word; \
21 __entry->root_count = sp->root_count; \
22 __entry->unsync = sp->unsync;
24 #define KVM_MMU_PAGE_PRINTK() ({ \
25 const char *ret = p->buffer + p->len; \
26 static const char *access_str[] = { \
27 "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" \
29 union kvm_mmu_page_role role; \
31 role.word = __entry->role; \
33 trace_seq_printf(p, "sp gfn %llx %u/%u q%u%s %s%s %spge" \
34 " %snxe root %u %s%c", \
35 __entry->gfn, role.level, role.glevels, \
37 role.direct ? " direct" : "", \
38 access_str[role.access], \
39 role.invalid ? " invalid" : "", \
40 role.cr4_pge ? "" : "!", \
41 role.nxe ? "" : "!", \
42 __entry->root_count, \
43 __entry->unsync ? "unsync" : "sync", 0); \
47 #define kvm_mmu_trace_pferr_flags \
48 { PFERR_PRESENT_MASK, "P" }, \
49 { PFERR_WRITE_MASK, "W" }, \
50 { PFERR_USER_MASK, "U" }, \
51 { PFERR_RSVD_MASK, "RSVD" }, \
52 { PFERR_FETCH_MASK, "F" }
55 * A pagetable walk has started
58 kvm_mmu_pagetable_walk
,
59 TP_PROTO(u64 addr
, int write_fault
, int user_fault
, int fetch_fault
),
60 TP_ARGS(addr
, write_fault
, user_fault
, fetch_fault
),
69 __entry
->pferr
= (!!write_fault
<< 1) | (!!user_fault
<< 2)
70 | (!!fetch_fault
<< 4);
73 TP_printk("addr %llx pferr %x %s", __entry
->addr
, __entry
->pferr
,
74 __print_flags(__entry
->pferr
, "|", kvm_mmu_trace_pferr_flags
))
78 /* We just walked a paging element */
80 kvm_mmu_paging_element
,
81 TP_PROTO(u64 pte
, int level
),
91 __entry
->level
= level
;
94 TP_printk("pte %llx level %u", __entry
->pte
, __entry
->level
)
97 /* We set a pte accessed bit */
99 kvm_mmu_set_accessed_bit
,
100 TP_PROTO(unsigned long table_gfn
, unsigned index
, unsigned size
),
101 TP_ARGS(table_gfn
, index
, size
),
108 __entry
->gpa
= ((u64
)table_gfn
<< PAGE_SHIFT
)
112 TP_printk("gpa %llx", __entry
->gpa
)
115 /* We set a pte dirty bit */
117 kvm_mmu_set_dirty_bit
,
118 TP_PROTO(unsigned long table_gfn
, unsigned index
, unsigned size
),
119 TP_ARGS(table_gfn
, index
, size
),
126 __entry
->gpa
= ((u64
)table_gfn
<< PAGE_SHIFT
)
130 TP_printk("gpa %llx", __entry
->gpa
)
134 kvm_mmu_walker_error
,
139 __field(__u32
, pferr
)
143 __entry
->pferr
= pferr
;
146 TP_printk("pferr %x %s", __entry
->pferr
,
147 __print_flags(__entry
->pferr
, "|", kvm_mmu_trace_pferr_flags
))
152 TP_PROTO(struct kvm_mmu_page
*sp
, bool created
),
153 TP_ARGS(sp
, created
),
157 __field(bool, created
)
161 KVM_MMU_PAGE_ASSIGN(sp
)
162 __entry
->created
= created
;
165 TP_printk("%s %s", KVM_MMU_PAGE_PRINTK(),
166 __entry
->created
? "new" : "existing")
171 TP_PROTO(struct kvm_mmu_page
*sp
),
179 KVM_MMU_PAGE_ASSIGN(sp
)
182 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
187 TP_PROTO(struct kvm_mmu_page
*sp
),
195 KVM_MMU_PAGE_ASSIGN(sp
)
198 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
203 TP_PROTO(struct kvm_mmu_page
*sp
),
211 KVM_MMU_PAGE_ASSIGN(sp
)
214 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
217 #endif /* _TRACE_KVMMMU_H */
219 /* This part must be outside protection */
220 #include <trace/define_trace.h>