1 #if !defined(LTTNG_TRACE_KVM_MMU_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define LTTNG_TRACE_KVM_MMU_H
4 #include <probes/lttng-tracepoint-event.h>
5 #include <linux/version.h>
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)) */
14 #define TRACE_SYSTEM kvm_mmu
16 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
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)
25 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
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)
33 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
35 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
37 * A pagetable walk has started
39 LTTNG_TRACEPOINT_EVENT(
40 kvm_mmu_pagetable_walk
,
41 TP_PROTO(u64 addr
, u32 pferr
),
45 ctf_integer(__u64
, addr
, addr
)
46 ctf_integer(__u32
, pferr
, pferr
)
49 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) */
51 * A pagetable walk has started
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
),
59 ctf_integer(__u64
, addr
, addr
)
60 ctf_integer(__u32
, pferr
,
61 (!!write_fault
<< 1) | (!!user_fault
<< 2)
62 | (!!fetch_fault
<< 4))
65 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) */
67 /* We just walked a paging element */
68 LTTNG_TRACEPOINT_EVENT(
69 kvm_mmu_paging_element
,
70 TP_PROTO(u64 pte
, int level
),
74 ctf_integer(__u64
, pte
, pte
)
75 ctf_integer(__u32
, level
, level
)
79 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_mmu_set_bit_class
,
81 TP_PROTO(unsigned long table_gfn
, unsigned index
, unsigned size
),
83 TP_ARGS(table_gfn
, index
, size
),
86 ctf_integer(__u64
, gpa
,
87 ((u64
)table_gfn
<< PAGE_SHIFT
) + index
* size
)
91 /* We set a pte accessed bit */
92 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_set_bit_class
, kvm_mmu_set_accessed_bit
,
94 TP_PROTO(unsigned long table_gfn
, unsigned index
, unsigned size
),
96 TP_ARGS(table_gfn
, index
, size
)
99 /* We set a pte dirty bit */
100 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_set_bit_class
, kvm_mmu_set_dirty_bit
,
102 TP_PROTO(unsigned long table_gfn
, unsigned index
, unsigned size
),
104 TP_ARGS(table_gfn
, index
, size
)
107 LTTNG_TRACEPOINT_EVENT(
108 kvm_mmu_walker_error
,
113 ctf_integer(__u32
, pferr
, pferr
)
117 LTTNG_TRACEPOINT_EVENT(
119 TP_PROTO(struct kvm_mmu_page
*sp
, bool created
),
120 TP_ARGS(sp
, created
),
123 LTTNG_KVM_MMU_PAGE_FIELDS
124 ctf_integer(bool, created
, created
)
128 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_mmu_page_class
,
130 TP_PROTO(struct kvm_mmu_page
*sp
),
134 LTTNG_KVM_MMU_PAGE_FIELDS
138 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class
, kvm_mmu_sync_page
,
139 TP_PROTO(struct kvm_mmu_page
*sp
),
144 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class
, kvm_mmu_unsync_page
,
145 TP_PROTO(struct kvm_mmu_page
*sp
),
150 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class
, kvm_mmu_prepare_zap_page
,
151 TP_PROTO(struct kvm_mmu_page
*sp
),
156 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
158 LTTNG_TRACEPOINT_EVENT_MAP(
161 kvm_mmu_mark_mmio_spte
,
163 TP_PROTO(u64
*sptep
, gfn_t gfn
, unsigned access
, unsigned int gen
),
164 TP_ARGS(sptep
, gfn
, access
, gen
),
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
)
174 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
176 LTTNG_TRACEPOINT_EVENT_MAP(
179 kvm_mmu_mark_mmio_spte
,
181 TP_PROTO(u64
*sptep
, gfn_t gfn
, unsigned access
),
182 TP_ARGS(sptep
, gfn
, access
),
185 ctf_integer_hex(void *, sptep
, sptep
)
186 ctf_integer(gfn_t
, gfn
, gfn
)
187 ctf_integer(unsigned, access
, access
)
191 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
193 LTTNG_TRACEPOINT_EVENT_MAP(
194 handle_mmio_page_fault
,
196 kvm_mmu_handle_mmio_page_fault
,
198 TP_PROTO(u64 addr
, gfn_t gfn
, unsigned access
),
199 TP_ARGS(addr
, gfn
, access
),
202 ctf_integer(u64
, addr
, addr
)
203 ctf_integer(gfn_t
, gfn
, gfn
)
204 ctf_integer(unsigned, access
, access
)
208 LTTNG_TRACEPOINT_EVENT_MAP(
211 kvm_mmu_fast_page_fault
,
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
),
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
)
227 #endif /* LTTNG_TRACE_KVM_MMU_H */
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
234 /* This part must be outside protection */
235 #include <probes/define_trace.h>