1 #if !defined(LTTNG_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define LTTNG_TRACE_KVM_MAIN_H
4 #include <probes/lttng-tracepoint-event.h>
5 #include <linux/version.h>
8 #define TRACE_SYSTEM kvm
10 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
12 LTTNG_TRACEPOINT_EVENT(kvm_userspace_exit
,
13 TP_PROTO(__u32 reason
, int errno
),
14 TP_ARGS(reason
, errno
),
17 ctf_integer(__u32
, reason
, reason
)
18 ctf_integer(int, errno
, errno
)
23 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
24 #if defined(__KVM_HAVE_IOAPIC)
25 #undef __KVM_HAVE_IRQ_LINE
26 #define __KVM_HAVE_IRQ_LINE
30 #if defined(__KVM_HAVE_IRQ_LINE)
31 LTTNG_TRACEPOINT_EVENT(kvm_set_irq
,
32 TP_PROTO(unsigned int gsi
, int level
, int irq_source_id
),
33 TP_ARGS(gsi
, level
, irq_source_id
),
36 ctf_integer(unsigned int, gsi
, gsi
)
37 ctf_integer(int, level
, level
)
38 ctf_integer(int, irq_source_id
, irq_source_id
)
43 #if defined(__KVM_HAVE_IOAPIC)
45 LTTNG_TRACEPOINT_EVENT(kvm_ioapic_set_irq
,
46 TP_PROTO(__u64 e
, int pin
, bool coalesced
),
47 TP_ARGS(e
, pin
, coalesced
),
50 ctf_integer(__u64
, e
, e
)
51 ctf_integer(int, pin
, pin
)
52 ctf_integer(bool, coalesced
, coalesced
)
56 LTTNG_TRACEPOINT_EVENT(kvm_msi_set_irq
,
57 TP_PROTO(__u64 address
, __u64 data
),
58 TP_ARGS(address
, data
),
61 ctf_integer(__u64
, address
, address
)
62 ctf_integer(__u64
, data
, data
)
66 LTTNG_TRACEPOINT_EVENT(kvm_ack_irq
,
67 TP_PROTO(unsigned int irqchip
, unsigned int pin
),
68 TP_ARGS(irqchip
, pin
),
71 ctf_integer(unsigned int, irqchip
, irqchip
)
72 ctf_integer(unsigned int, pin
, pin
)
76 #endif /* defined(__KVM_HAVE_IOAPIC) */
78 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
79 #define KVM_TRACE_MMIO_READ 1
80 #define KVM_TRACE_MMIO_WRITE 2
82 #define kvm_trace_symbol_mmio \
83 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
84 { KVM_TRACE_MMIO_READ, "read" }, \
85 { KVM_TRACE_MMIO_WRITE, "write" }
87 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) \
88 || LTTNG_KERNEL_RANGE(3,16,52, 3,17,0) \
89 || LTTNG_KERNEL_RANGE(3,2,97, 3,3,0) \
90 || LTTNG_DEBIAN_KERNEL_RANGE(4,9,65,0,3,0, 4,10,0,0,0,0))
92 LTTNG_TRACEPOINT_EVENT(kvm_mmio
,
93 TP_PROTO(int type
, int len
, u64 gpa
, void *val
),
94 TP_ARGS(type
, len
, gpa
, val
),
97 ctf_integer(u32
, type
, type
)
98 ctf_integer(u32
, len
, len
)
99 ctf_integer(u64
, gpa
, gpa
)
100 ctf_sequence_hex(unsigned char, val
, val
, u32
, len
)
106 LTTNG_TRACEPOINT_EVENT(kvm_mmio
,
107 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
108 TP_ARGS(type
, len
, gpa
, val
),
111 ctf_integer(u32
, type
, type
)
112 ctf_integer(u32
, len
, len
)
113 ctf_integer(u64
, gpa
, gpa
)
114 ctf_integer(u64
, val
, val
)
120 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
122 #define kvm_fpu_load_symbol \
126 LTTNG_TRACEPOINT_EVENT(kvm_fpu
,
131 ctf_integer(u32
, load
, load
)
135 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) \
136 || LTTNG_RHEL_KERNEL_RANGE(3,10,0,327,0,0, 3,11,0,0,0,0))
138 LTTNG_TRACEPOINT_EVENT(kvm_age_page
,
139 TP_PROTO(ulong gfn
, int level
, struct kvm_memory_slot
*slot
, int ref
),
140 TP_ARGS(gfn
, level
, slot
, ref
),
143 ctf_integer(u64
, hva
,
144 ((gfn
- slot
->base_gfn
) << PAGE_SHIFT
) + slot
->userspace_addr
)
145 ctf_integer(u64
, gfn
, gfn
)
146 ctf_integer(u8
, level
, level
)
147 ctf_integer(u8
, referenced
, ref
)
153 LTTNG_TRACEPOINT_EVENT(kvm_age_page
,
154 TP_PROTO(ulong hva
, struct kvm_memory_slot
*slot
, int ref
),
155 TP_ARGS(hva
, slot
, ref
),
158 ctf_integer(u64
, hva
, hva
)
159 ctf_integer(u64
, gfn
,
160 slot
->base_gfn
+ ((hva
- slot
->userspace_addr
) >> PAGE_SHIFT
))
161 ctf_integer(u8
, referenced
, ref
)
167 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
169 #ifdef CONFIG_KVM_ASYNC_PF
170 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_get_page_class
,
172 TP_PROTO(u64 gva
, u64 gfn
),
177 ctf_integer(__u64
, gva
, gva
)
178 ctf_integer(u64
, gfn
, gfn
)
182 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class
, kvm_try_async_get_page
,
184 TP_PROTO(u64 gva
, u64 gfn
),
189 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class
, kvm_async_pf_doublefault
,
191 TP_PROTO(u64 gva
, u64 gfn
),
196 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_pf_nopresent_ready
,
198 TP_PROTO(u64 token
, u64 gva
),
203 ctf_integer(__u64
, token
, token
)
204 ctf_integer(__u64
, gva
, gva
)
208 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready
, kvm_async_pf_not_present
,
210 TP_PROTO(u64 token
, u64 gva
),
215 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready
, kvm_async_pf_ready
,
217 TP_PROTO(u64 token
, u64 gva
),
222 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0) \
223 || LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0))
225 LTTNG_TRACEPOINT_EVENT(
226 kvm_async_pf_completed
,
227 TP_PROTO(unsigned long address
, u64 gva
),
228 TP_ARGS(address
, gva
),
231 ctf_integer(unsigned long, address
, address
)
232 ctf_integer(u64
, gva
, gva
)
236 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) */
238 LTTNG_TRACEPOINT_EVENT(
239 kvm_async_pf_completed
,
240 TP_PROTO(unsigned long address
, struct page
*page
, u64 gva
),
241 TP_ARGS(address
, page
, gva
),
244 ctf_integer(unsigned long, address
, address
)
245 ctf_integer(pfn_t
, pfn
, page
? page_to_pfn(page
) : 0)
246 ctf_integer(u64
, gva
, gva
)
250 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) */
256 #endif /* LTTNG_TRACE_KVM_MAIN_H */
258 /* This part must be outside protection */
259 #include <probes/define_trace.h>