Linux 4.1.18
[linux/fpc-iii.git] / arch / x86 / kvm / mmutrace.h
blobce463a9cc8fb253d426bfabb9bb786a69a26fc55
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>
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM kvmmmu
10 #define KVM_MMU_PAGE_FIELDS \
11 __field(unsigned long, mmu_valid_gen) \
12 __field(__u64, gfn) \
13 __field(__u32, role) \
14 __field(__u32, root_count) \
15 __field(bool, unsync)
17 #define KVM_MMU_PAGE_ASSIGN(sp) \
18 __entry->mmu_valid_gen = sp->mmu_valid_gen; \
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 *saved_ptr = trace_seq_buffer_ptr(p); \
26 static const char *access_str[] = { \
27 "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" \
28 }; \
29 union kvm_mmu_page_role role; \
31 role.word = __entry->role; \
33 trace_seq_printf(p, "sp gen %lx gfn %llx %u%s q%u%s %s%s" \
34 " %snxe root %u %s%c", __entry->mmu_valid_gen, \
35 __entry->gfn, role.level, \
36 role.cr4_pae ? " pae" : "", \
37 role.quadrant, \
38 role.direct ? " direct" : "", \
39 access_str[role.access], \
40 role.invalid ? " invalid" : "", \
41 role.nxe ? "" : "!", \
42 __entry->root_count, \
43 __entry->unsync ? "unsync" : "sync", 0); \
44 saved_ptr; \
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
57 TRACE_EVENT(
58 kvm_mmu_pagetable_walk,
59 TP_PROTO(u64 addr, u32 pferr),
60 TP_ARGS(addr, pferr),
62 TP_STRUCT__entry(
63 __field(__u64, addr)
64 __field(__u32, pferr)
67 TP_fast_assign(
68 __entry->addr = addr;
69 __entry->pferr = pferr;
72 TP_printk("addr %llx pferr %x %s", __entry->addr, __entry->pferr,
73 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
77 /* We just walked a paging element */
78 TRACE_EVENT(
79 kvm_mmu_paging_element,
80 TP_PROTO(u64 pte, int level),
81 TP_ARGS(pte, level),
83 TP_STRUCT__entry(
84 __field(__u64, pte)
85 __field(__u32, level)
88 TP_fast_assign(
89 __entry->pte = pte;
90 __entry->level = level;
93 TP_printk("pte %llx level %u", __entry->pte, __entry->level)
96 DECLARE_EVENT_CLASS(kvm_mmu_set_bit_class,
98 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
100 TP_ARGS(table_gfn, index, size),
102 TP_STRUCT__entry(
103 __field(__u64, gpa)
106 TP_fast_assign(
107 __entry->gpa = ((u64)table_gfn << PAGE_SHIFT)
108 + index * size;
111 TP_printk("gpa %llx", __entry->gpa)
114 /* We set a pte accessed bit */
115 DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_accessed_bit,
117 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
119 TP_ARGS(table_gfn, index, size)
122 /* We set a pte dirty bit */
123 DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_dirty_bit,
125 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
127 TP_ARGS(table_gfn, index, size)
130 TRACE_EVENT(
131 kvm_mmu_walker_error,
132 TP_PROTO(u32 pferr),
133 TP_ARGS(pferr),
135 TP_STRUCT__entry(
136 __field(__u32, pferr)
139 TP_fast_assign(
140 __entry->pferr = pferr;
143 TP_printk("pferr %x %s", __entry->pferr,
144 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
147 TRACE_EVENT(
148 kvm_mmu_get_page,
149 TP_PROTO(struct kvm_mmu_page *sp, bool created),
150 TP_ARGS(sp, created),
152 TP_STRUCT__entry(
153 KVM_MMU_PAGE_FIELDS
154 __field(bool, created)
157 TP_fast_assign(
158 KVM_MMU_PAGE_ASSIGN(sp)
159 __entry->created = created;
162 TP_printk("%s %s", KVM_MMU_PAGE_PRINTK(),
163 __entry->created ? "new" : "existing")
166 DECLARE_EVENT_CLASS(kvm_mmu_page_class,
168 TP_PROTO(struct kvm_mmu_page *sp),
169 TP_ARGS(sp),
171 TP_STRUCT__entry(
172 KVM_MMU_PAGE_FIELDS
175 TP_fast_assign(
176 KVM_MMU_PAGE_ASSIGN(sp)
179 TP_printk("%s", KVM_MMU_PAGE_PRINTK())
182 DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_sync_page,
183 TP_PROTO(struct kvm_mmu_page *sp),
185 TP_ARGS(sp)
188 DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_unsync_page,
189 TP_PROTO(struct kvm_mmu_page *sp),
191 TP_ARGS(sp)
194 DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_prepare_zap_page,
195 TP_PROTO(struct kvm_mmu_page *sp),
197 TP_ARGS(sp)
200 TRACE_EVENT(
201 mark_mmio_spte,
202 TP_PROTO(u64 *sptep, gfn_t gfn, unsigned access, unsigned int gen),
203 TP_ARGS(sptep, gfn, access, gen),
205 TP_STRUCT__entry(
206 __field(void *, sptep)
207 __field(gfn_t, gfn)
208 __field(unsigned, access)
209 __field(unsigned int, gen)
212 TP_fast_assign(
213 __entry->sptep = sptep;
214 __entry->gfn = gfn;
215 __entry->access = access;
216 __entry->gen = gen;
219 TP_printk("sptep:%p gfn %llx access %x gen %x", __entry->sptep,
220 __entry->gfn, __entry->access, __entry->gen)
223 TRACE_EVENT(
224 handle_mmio_page_fault,
225 TP_PROTO(u64 addr, gfn_t gfn, unsigned access),
226 TP_ARGS(addr, gfn, access),
228 TP_STRUCT__entry(
229 __field(u64, addr)
230 __field(gfn_t, gfn)
231 __field(unsigned, access)
234 TP_fast_assign(
235 __entry->addr = addr;
236 __entry->gfn = gfn;
237 __entry->access = access;
240 TP_printk("addr:%llx gfn %llx access %x", __entry->addr, __entry->gfn,
241 __entry->access)
244 #define __spte_satisfied(__spte) \
245 (__entry->retry && is_writable_pte(__entry->__spte))
247 TRACE_EVENT(
248 fast_page_fault,
249 TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
250 u64 *sptep, u64 old_spte, bool retry),
251 TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry),
253 TP_STRUCT__entry(
254 __field(int, vcpu_id)
255 __field(gva_t, gva)
256 __field(u32, error_code)
257 __field(u64 *, sptep)
258 __field(u64, old_spte)
259 __field(u64, new_spte)
260 __field(bool, retry)
263 TP_fast_assign(
264 __entry->vcpu_id = vcpu->vcpu_id;
265 __entry->gva = gva;
266 __entry->error_code = error_code;
267 __entry->sptep = sptep;
268 __entry->old_spte = old_spte;
269 __entry->new_spte = *sptep;
270 __entry->retry = retry;
273 TP_printk("vcpu %d gva %lx error_code %s sptep %p old %#llx"
274 " new %llx spurious %d fixed %d", __entry->vcpu_id,
275 __entry->gva, __print_flags(__entry->error_code, "|",
276 kvm_mmu_trace_pferr_flags), __entry->sptep,
277 __entry->old_spte, __entry->new_spte,
278 __spte_satisfied(old_spte), __spte_satisfied(new_spte)
282 TRACE_EVENT(
283 kvm_mmu_invalidate_zap_all_pages,
284 TP_PROTO(struct kvm *kvm),
285 TP_ARGS(kvm),
287 TP_STRUCT__entry(
288 __field(unsigned long, mmu_valid_gen)
289 __field(unsigned int, mmu_used_pages)
292 TP_fast_assign(
293 __entry->mmu_valid_gen = kvm->arch.mmu_valid_gen;
294 __entry->mmu_used_pages = kvm->arch.n_used_mmu_pages;
297 TP_printk("kvm-mmu-valid-gen %lx used_pages %x",
298 __entry->mmu_valid_gen, __entry->mmu_used_pages
303 TRACE_EVENT(
304 check_mmio_spte,
305 TP_PROTO(u64 spte, unsigned int kvm_gen, unsigned int spte_gen),
306 TP_ARGS(spte, kvm_gen, spte_gen),
308 TP_STRUCT__entry(
309 __field(unsigned int, kvm_gen)
310 __field(unsigned int, spte_gen)
311 __field(u64, spte)
314 TP_fast_assign(
315 __entry->kvm_gen = kvm_gen;
316 __entry->spte_gen = spte_gen;
317 __entry->spte = spte;
320 TP_printk("spte %llx kvm_gen %x spte-gen %x valid %d", __entry->spte,
321 __entry->kvm_gen, __entry->spte_gen,
322 __entry->kvm_gen == __entry->spte_gen
325 #endif /* _TRACE_KVMMMU_H */
327 #undef TRACE_INCLUDE_PATH
328 #define TRACE_INCLUDE_PATH .
329 #undef TRACE_INCLUDE_FILE
330 #define TRACE_INCLUDE_FILE mmutrace
332 /* This part must be outside protection */
333 #include <trace/define_trace.h>