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