e3f7abd5de787e73897cb90867338fd908f3a9ec
[lttng-modules.git] / instrumentation / events / lttng-module / arch / x86 / kvm / mmutrace.h
1 #if !defined(LTTNG_TRACE_KVM_MMU_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define LTTNG_TRACE_KVM_MMU_H
3
4 #include <probes/lttng-tracepoint-event.h>
5 #include <linux/version.h>
6
7 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0))
8 #include <linux/trace_events.h>
9 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
10 #include <linux/ftrace_event.h>
11 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) */
12
13 #undef TRACE_SYSTEM
14 #define TRACE_SYSTEM kvm_mmu
15
16 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
17
18 #define LTTNG_KVM_MMU_PAGE_FIELDS \
19 ctf_integer(unsigned long, mmu_valid_gen, (sp)->mmu_valid_gen) \
20 ctf_integer(__u64, gfn, (sp)->gfn) \
21 ctf_integer(__u32, role, (sp)->role.word) \
22 ctf_integer(__u32, root_count, (sp)->root_count) \
23 ctf_integer(bool, unsync, (sp)->unsync)
24
25 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
26
27 #define LTTNG_KVM_MMU_PAGE_FIELDS \
28 ctf_integer(__u64, gfn, (sp)->gfn) \
29 ctf_integer(__u32, role, (sp)->role.word) \
30 ctf_integer(__u32, root_count, (sp)->root_count) \
31 ctf_integer(bool, unsync, (sp)->unsync)
32
33 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
34
35 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
36 /*
37 * A pagetable walk has started
38 */
39 LTTNG_TRACEPOINT_EVENT(
40 kvm_mmu_pagetable_walk,
41 TP_PROTO(u64 addr, u32 pferr),
42 TP_ARGS(addr, pferr),
43
44 TP_FIELDS(
45 ctf_integer(__u64, addr, addr)
46 ctf_integer(__u32, pferr, pferr)
47 )
48 )
49 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) */
50 /*
51 * A pagetable walk has started
52 */
53 LTTNG_TRACEPOINT_EVENT(
54 kvm_mmu_pagetable_walk,
55 TP_PROTO(u64 addr, int write_fault, int user_fault, int fetch_fault),
56 TP_ARGS(addr, write_fault, user_fault, fetch_fault),
57
58 TP_FIELDS(
59 ctf_integer(__u64, addr, addr)
60 ctf_integer(__u32, pferr,
61 (!!write_fault << 1) | (!!user_fault << 2)
62 | (!!fetch_fault << 4))
63 )
64 )
65 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) */
66
67 /* We just walked a paging element */
68 LTTNG_TRACEPOINT_EVENT(
69 kvm_mmu_paging_element,
70 TP_PROTO(u64 pte, int level),
71 TP_ARGS(pte, level),
72
73 TP_FIELDS(
74 ctf_integer(__u64, pte, pte)
75 ctf_integer(__u32, level, level)
76 )
77 )
78
79 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_mmu_set_bit_class,
80
81 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
82
83 TP_ARGS(table_gfn, index, size),
84
85 TP_FIELDS(
86 ctf_integer(__u64, gpa,
87 ((u64)table_gfn << PAGE_SHIFT) + index * size)
88 )
89 )
90
91 /* We set a pte accessed bit */
92 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_set_bit_class, kvm_mmu_set_accessed_bit,
93
94 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
95
96 TP_ARGS(table_gfn, index, size)
97 )
98
99 /* We set a pte dirty bit */
100 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_set_bit_class, kvm_mmu_set_dirty_bit,
101
102 TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
103
104 TP_ARGS(table_gfn, index, size)
105 )
106
107 LTTNG_TRACEPOINT_EVENT(
108 kvm_mmu_walker_error,
109 TP_PROTO(u32 pferr),
110 TP_ARGS(pferr),
111
112 TP_FIELDS(
113 ctf_integer(__u32, pferr, pferr)
114 )
115 )
116
117 LTTNG_TRACEPOINT_EVENT(
118 kvm_mmu_get_page,
119 TP_PROTO(struct kvm_mmu_page *sp, bool created),
120 TP_ARGS(sp, created),
121
122 TP_FIELDS(
123 LTTNG_KVM_MMU_PAGE_FIELDS
124 ctf_integer(bool, created, created)
125 )
126 )
127
128 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_mmu_page_class,
129
130 TP_PROTO(struct kvm_mmu_page *sp),
131 TP_ARGS(sp),
132
133 TP_FIELDS(
134 LTTNG_KVM_MMU_PAGE_FIELDS
135 )
136 )
137
138 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class, kvm_mmu_sync_page,
139 TP_PROTO(struct kvm_mmu_page *sp),
140
141 TP_ARGS(sp)
142 )
143
144 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class, kvm_mmu_unsync_page,
145 TP_PROTO(struct kvm_mmu_page *sp),
146
147 TP_ARGS(sp)
148 )
149
150 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class, kvm_mmu_prepare_zap_page,
151 TP_PROTO(struct kvm_mmu_page *sp),
152
153 TP_ARGS(sp)
154 )
155
156 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
157
158 LTTNG_TRACEPOINT_EVENT_MAP(
159 mark_mmio_spte,
160
161 kvm_mmu_mark_mmio_spte,
162
163 TP_PROTO(u64 *sptep, gfn_t gfn, unsigned access, unsigned int gen),
164 TP_ARGS(sptep, gfn, access, gen),
165
166 TP_FIELDS(
167 ctf_integer_hex(void *, sptep, sptep)
168 ctf_integer(gfn_t, gfn, gfn)
169 ctf_integer(unsigned, access, access)
170 ctf_integer(unsigned int, gen, gen)
171 )
172 )
173
174 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
175
176 LTTNG_TRACEPOINT_EVENT_MAP(
177 mark_mmio_spte,
178
179 kvm_mmu_mark_mmio_spte,
180
181 TP_PROTO(u64 *sptep, gfn_t gfn, unsigned access),
182 TP_ARGS(sptep, gfn, access),
183
184 TP_FIELDS(
185 ctf_integer_hex(void *, sptep, sptep)
186 ctf_integer(gfn_t, gfn, gfn)
187 ctf_integer(unsigned, access, access)
188 )
189 )
190
191 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
192
193 LTTNG_TRACEPOINT_EVENT_MAP(
194 handle_mmio_page_fault,
195
196 kvm_mmu_handle_mmio_page_fault,
197
198 TP_PROTO(u64 addr, gfn_t gfn, unsigned access),
199 TP_ARGS(addr, gfn, access),
200
201 TP_FIELDS(
202 ctf_integer(u64, addr, addr)
203 ctf_integer(gfn_t, gfn, gfn)
204 ctf_integer(unsigned, access, access)
205 )
206 )
207
208 LTTNG_TRACEPOINT_EVENT_MAP(
209 fast_page_fault,
210
211 kvm_mmu_fast_page_fault,
212
213 TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
214 u64 *sptep, u64 old_spte, bool retry),
215 TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry),
216
217 TP_FIELDS(
218 ctf_integer(int, vcpu_id, vcpu->vcpu_id)
219 ctf_integer(gva_t, gva, gva)
220 ctf_integer(u32, error_code, error_code)
221 ctf_integer_hex(u64 *, sptep, sptep)
222 ctf_integer(u64, old_spte, old_spte)
223 ctf_integer(u64, new_spte, *sptep)
224 ctf_integer(bool, retry, retry)
225 )
226 )
227 #endif /* LTTNG_TRACE_KVM_MMU_H */
228
229 #undef TRACE_INCLUDE_PATH
230 #define TRACE_INCLUDE_PATH instrumentation/events/lttng-module/arch/x86/kvm
231 #undef TRACE_INCLUDE_FILE
232 #define TRACE_INCLUDE_FILE mmutrace
233
234 /* This part must be outside protection */
235 #include <probes/define_trace.h>
This page took 0.048424 seconds and 3 git commands to generate.