1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #if !defined(LTTNG_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
3 #define LTTNG_TRACE_KVM_MAIN_H
5 #include <lttng/tracepoint-event.h>
6 #include <lttng/kernel-version.h>
9 #define TRACE_SYSTEM kvm
11 LTTNG_TRACEPOINT_EVENT(kvm_userspace_exit
,
12 TP_PROTO(__u32 reason
, int errno
),
13 TP_ARGS(reason
, errno
),
16 ctf_integer(__u32
, reason
, reason
)
17 ctf_integer(int, errno
, errno
)
21 #if defined(__KVM_HAVE_IOAPIC)
22 LTTNG_TRACEPOINT_EVENT(kvm_set_irq
,
23 TP_PROTO(unsigned int gsi
, int level
, int irq_source_id
),
24 TP_ARGS(gsi
, level
, irq_source_id
),
27 ctf_integer(unsigned int, gsi
, gsi
)
28 ctf_integer(int, level
, level
)
29 ctf_integer(int, irq_source_id
, irq_source_id
)
33 LTTNG_TRACEPOINT_EVENT(kvm_ioapic_set_irq
,
34 TP_PROTO(__u64 e
, int pin
, bool coalesced
),
35 TP_ARGS(e
, pin
, coalesced
),
38 ctf_integer(__u64
, e
, e
)
39 ctf_integer(int, pin
, pin
)
40 ctf_integer(bool, coalesced
, coalesced
)
44 LTTNG_TRACEPOINT_EVENT(kvm_msi_set_irq
,
45 TP_PROTO(__u64 address
, __u64 data
),
46 TP_ARGS(address
, data
),
49 ctf_integer_hex(__u64
, address
, address
)
50 ctf_integer(__u64
, data
, data
)
54 LTTNG_TRACEPOINT_EVENT(kvm_ack_irq
,
55 TP_PROTO(unsigned int irqchip
, unsigned int pin
),
56 TP_ARGS(irqchip
, pin
),
59 ctf_integer(unsigned int, irqchip
, irqchip
)
60 ctf_integer(unsigned int, pin
, pin
)
64 #endif /* defined(__KVM_HAVE_IOAPIC) */
66 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
67 #define KVM_TRACE_MMIO_READ 1
68 #define KVM_TRACE_MMIO_WRITE 2
70 #define kvm_trace_symbol_mmio \
71 { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
72 { KVM_TRACE_MMIO_READ, "read" }, \
73 { KVM_TRACE_MMIO_WRITE, "write" }
76 #if (LTTNG_SLE_KERNEL_RANGE(4,4,121,92,92,0, 4,4,122,0,0,0) \
77 || LTTNG_SLE_KERNEL_RANGE(4,4,131,94,0,0, 4,5,0,0,0,0))
79 LTTNG_TRACEPOINT_EVENT(kvm_mmio
,
80 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
81 TP_ARGS(type
, len
, gpa
, val
),
84 ctf_integer(u32
, type
, type
)
85 ctf_integer(u32
, len
, len
)
86 ctf_integer(u64
, gpa
, gpa
)
87 ctf_integer(u64
, val
, val
)
91 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0) \
92 || LTTNG_KERNEL_RANGE(4,14,14, 4,15,0) \
93 || LTTNG_DEBIAN_KERNEL_RANGE(4,14,13,1,0, 4,15,0,0,0) \
94 || LTTNG_KERNEL_RANGE(4,9,77, 4,10,0) \
95 || LTTNG_KERNEL_RANGE(4,4,112, 4,5,0) \
96 || LTTNG_UBUNTU_KERNEL_RANGE(4,13,16,38, 4,14,0,0) \
97 || LTTNG_DEBIAN_KERNEL_RANGE(4,9,65,3,0, 4,10,0,0,0) \
98 || LTTNG_FEDORA_KERNEL_RANGE(4,14,13,300, 4,15,0,0))
100 LTTNG_TRACEPOINT_EVENT(kvm_mmio
,
101 TP_PROTO(int type
, int len
, u64 gpa
, void *val
),
102 TP_ARGS(type
, len
, gpa
, val
),
105 ctf_integer(u32
, type
, type
)
106 ctf_integer(u32
, len
, len
)
107 ctf_integer(u64
, gpa
, gpa
)
108 ctf_sequence_hex(unsigned char, val
, val
, u32
, len
)
114 LTTNG_TRACEPOINT_EVENT(kvm_mmio
,
115 TP_PROTO(int type
, int len
, u64 gpa
, u64 val
),
116 TP_ARGS(type
, len
, gpa
, val
),
119 ctf_integer(u32
, type
, type
)
120 ctf_integer(u32
, len
, len
)
121 ctf_integer(u64
, gpa
, gpa
)
122 ctf_integer(u64
, val
, val
)
128 #define kvm_fpu_load_symbol \
132 LTTNG_TRACEPOINT_EVENT(kvm_fpu
,
137 ctf_integer(u32
, load
, load
)
141 LTTNG_TRACEPOINT_EVENT(kvm_age_page
,
142 TP_PROTO(ulong gfn
, int level
, struct kvm_memory_slot
*slot
, int ref
),
143 TP_ARGS(gfn
, level
, slot
, ref
),
146 ctf_integer(u64
, hva
,
147 ((gfn
- slot
->base_gfn
) << PAGE_SHIFT
) + slot
->userspace_addr
)
148 ctf_integer(u64
, gfn
, gfn
)
149 ctf_integer(u8
, level
, level
)
150 ctf_integer(u8
, referenced
, ref
)
154 #ifdef CONFIG_KVM_ASYNC_PF
155 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_get_page_class
,
157 TP_PROTO(u64 gva
, u64 gfn
),
162 ctf_integer(__u64
, gva
, gva
)
163 ctf_integer(u64
, gfn
, gfn
)
167 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class
, kvm_try_async_get_page
,
169 TP_PROTO(u64 gva
, u64 gfn
),
174 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class
, kvm_async_pf_doublefault
,
176 TP_PROTO(u64 gva
, u64 gfn
),
181 LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_pf_nopresent_ready
,
183 TP_PROTO(u64 token
, u64 gva
),
188 ctf_integer(__u64
, token
, token
)
189 ctf_integer(__u64
, gva
, gva
)
193 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready
, kvm_async_pf_not_present
,
195 TP_PROTO(u64 token
, u64 gva
),
200 LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready
, kvm_async_pf_ready
,
202 TP_PROTO(u64 token
, u64 gva
),
207 LTTNG_TRACEPOINT_EVENT(
208 kvm_async_pf_completed
,
209 TP_PROTO(unsigned long address
, u64 gva
),
210 TP_ARGS(address
, gva
),
213 ctf_integer_hex(unsigned long, address
, address
)
214 ctf_integer(u64
, gva
, gva
)
220 #endif /* LTTNG_TRACE_KVM_MAIN_H */
222 /* This part must be outside protection */
223 #include <lttng/define_trace.h>