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