Commit | Line | Data |
---|---|---|
229456fc MT |
1 | #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) |
2 | #define _TRACE_KVM_H | |
3 | ||
4 | #include <linux/tracepoint.h> | |
5 | ||
6 | #undef TRACE_SYSTEM | |
7 | #define TRACE_SYSTEM kvm | |
8 | #define TRACE_INCLUDE_PATH arch/x86/kvm | |
9 | #define TRACE_INCLUDE_FILE trace | |
10 | ||
11 | /* | |
12 | * Tracepoint for guest mode entry. | |
13 | */ | |
14 | TRACE_EVENT(kvm_entry, | |
15 | TP_PROTO(unsigned int vcpu_id), | |
16 | TP_ARGS(vcpu_id), | |
17 | ||
18 | TP_STRUCT__entry( | |
19 | __field( unsigned int, vcpu_id ) | |
20 | ), | |
21 | ||
22 | TP_fast_assign( | |
23 | __entry->vcpu_id = vcpu_id; | |
24 | ), | |
25 | ||
26 | TP_printk("vcpu %u", __entry->vcpu_id) | |
27 | ); | |
28 | ||
29 | /* | |
30 | * Tracepoint for hypercall. | |
31 | */ | |
32 | TRACE_EVENT(kvm_hypercall, | |
33 | TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1, | |
34 | unsigned long a2, unsigned long a3), | |
35 | TP_ARGS(nr, a0, a1, a2, a3), | |
36 | ||
37 | TP_STRUCT__entry( | |
38 | __field( unsigned long, nr ) | |
39 | __field( unsigned long, a0 ) | |
40 | __field( unsigned long, a1 ) | |
41 | __field( unsigned long, a2 ) | |
42 | __field( unsigned long, a3 ) | |
43 | ), | |
44 | ||
45 | TP_fast_assign( | |
46 | __entry->nr = nr; | |
47 | __entry->a0 = a0; | |
48 | __entry->a1 = a1; | |
49 | __entry->a2 = a2; | |
50 | __entry->a3 = a3; | |
51 | ), | |
52 | ||
53 | TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx", | |
54 | __entry->nr, __entry->a0, __entry->a1, __entry->a2, | |
55 | __entry->a3) | |
56 | ); | |
57 | ||
58 | /* | |
59 | * Tracepoint for PIO. | |
60 | */ | |
61 | TRACE_EVENT(kvm_pio, | |
62 | TP_PROTO(unsigned int rw, unsigned int port, unsigned int size, | |
63 | unsigned int count), | |
64 | TP_ARGS(rw, port, size, count), | |
65 | ||
66 | TP_STRUCT__entry( | |
67 | __field( unsigned int, rw ) | |
68 | __field( unsigned int, port ) | |
69 | __field( unsigned int, size ) | |
70 | __field( unsigned int, count ) | |
71 | ), | |
72 | ||
73 | TP_fast_assign( | |
74 | __entry->rw = rw; | |
75 | __entry->port = port; | |
76 | __entry->size = size; | |
77 | __entry->count = count; | |
78 | ), | |
79 | ||
80 | TP_printk("pio_%s at 0x%x size %d count %d", | |
81 | __entry->rw ? "write" : "read", | |
82 | __entry->port, __entry->size, __entry->count) | |
83 | ); | |
84 | ||
85 | /* | |
86 | * Tracepoint for cpuid. | |
87 | */ | |
88 | TRACE_EVENT(kvm_cpuid, | |
89 | TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx, | |
90 | unsigned long rcx, unsigned long rdx), | |
91 | TP_ARGS(function, rax, rbx, rcx, rdx), | |
92 | ||
93 | TP_STRUCT__entry( | |
94 | __field( unsigned int, function ) | |
95 | __field( unsigned long, rax ) | |
96 | __field( unsigned long, rbx ) | |
97 | __field( unsigned long, rcx ) | |
98 | __field( unsigned long, rdx ) | |
99 | ), | |
100 | ||
101 | TP_fast_assign( | |
102 | __entry->function = function; | |
103 | __entry->rax = rax; | |
104 | __entry->rbx = rbx; | |
105 | __entry->rcx = rcx; | |
106 | __entry->rdx = rdx; | |
107 | ), | |
108 | ||
109 | TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx", | |
110 | __entry->function, __entry->rax, | |
111 | __entry->rbx, __entry->rcx, __entry->rdx) | |
112 | ); | |
113 | ||
114 | /* | |
115 | * Tracepoint for apic access. | |
116 | */ | |
117 | TRACE_EVENT(kvm_apic, | |
118 | TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val), | |
119 | TP_ARGS(rw, reg, val), | |
120 | ||
121 | TP_STRUCT__entry( | |
122 | __field( unsigned int, rw ) | |
123 | __field( unsigned int, reg ) | |
124 | __field( unsigned int, val ) | |
125 | ), | |
126 | ||
127 | TP_fast_assign( | |
128 | __entry->rw = rw; | |
129 | __entry->reg = reg; | |
130 | __entry->val = val; | |
131 | ), | |
132 | ||
133 | TP_printk("apic_%s 0x%x = 0x%x", | |
134 | __entry->rw ? "write" : "read", | |
135 | __entry->reg, __entry->val) | |
136 | ); | |
137 | ||
138 | #define trace_kvm_apic_read(reg, val) trace_kvm_apic(0, reg, val) | |
139 | #define trace_kvm_apic_write(reg, val) trace_kvm_apic(1, reg, val) | |
140 | ||
141 | /* | |
142 | * Tracepoint for kvm guest exit: | |
143 | */ | |
144 | TRACE_EVENT(kvm_exit, | |
145 | TP_PROTO(unsigned int exit_reason, unsigned long guest_rip), | |
146 | TP_ARGS(exit_reason, guest_rip), | |
147 | ||
148 | TP_STRUCT__entry( | |
149 | __field( unsigned int, exit_reason ) | |
150 | __field( unsigned long, guest_rip ) | |
151 | ), | |
152 | ||
153 | TP_fast_assign( | |
154 | __entry->exit_reason = exit_reason; | |
155 | __entry->guest_rip = guest_rip; | |
156 | ), | |
157 | ||
158 | TP_printk("reason %s rip 0x%lx", | |
159 | ftrace_print_symbols_seq(p, __entry->exit_reason, | |
160 | kvm_x86_ops->exit_reasons_str), | |
161 | __entry->guest_rip) | |
162 | ); | |
163 | ||
164 | /* | |
165 | * Tracepoint for kvm interrupt injection: | |
166 | */ | |
167 | TRACE_EVENT(kvm_inj_virq, | |
168 | TP_PROTO(unsigned int irq), | |
169 | TP_ARGS(irq), | |
170 | ||
171 | TP_STRUCT__entry( | |
172 | __field( unsigned int, irq ) | |
173 | ), | |
174 | ||
175 | TP_fast_assign( | |
176 | __entry->irq = irq; | |
177 | ), | |
178 | ||
179 | TP_printk("irq %u", __entry->irq) | |
180 | ); | |
181 | ||
182 | /* | |
183 | * Tracepoint for page fault. | |
184 | */ | |
185 | TRACE_EVENT(kvm_page_fault, | |
186 | TP_PROTO(unsigned long fault_address, unsigned int error_code), | |
187 | TP_ARGS(fault_address, error_code), | |
188 | ||
189 | TP_STRUCT__entry( | |
190 | __field( unsigned long, fault_address ) | |
191 | __field( unsigned int, error_code ) | |
192 | ), | |
193 | ||
194 | TP_fast_assign( | |
195 | __entry->fault_address = fault_address; | |
196 | __entry->error_code = error_code; | |
197 | ), | |
198 | ||
199 | TP_printk("address %lx error_code %x", | |
200 | __entry->fault_address, __entry->error_code) | |
201 | ); | |
202 | ||
203 | /* | |
204 | * Tracepoint for guest MSR access. | |
205 | */ | |
206 | TRACE_EVENT(kvm_msr, | |
207 | TP_PROTO(unsigned int rw, unsigned int ecx, unsigned long data), | |
208 | TP_ARGS(rw, ecx, data), | |
209 | ||
210 | TP_STRUCT__entry( | |
211 | __field( unsigned int, rw ) | |
212 | __field( unsigned int, ecx ) | |
213 | __field( unsigned long, data ) | |
214 | ), | |
215 | ||
216 | TP_fast_assign( | |
217 | __entry->rw = rw; | |
218 | __entry->ecx = ecx; | |
219 | __entry->data = data; | |
220 | ), | |
221 | ||
222 | TP_printk("msr_%s %x = 0x%lx", | |
223 | __entry->rw ? "write" : "read", | |
224 | __entry->ecx, __entry->data) | |
225 | ); | |
226 | ||
227 | #define trace_kvm_msr_read(ecx, data) trace_kvm_msr(0, ecx, data) | |
228 | #define trace_kvm_msr_write(ecx, data) trace_kvm_msr(1, ecx, data) | |
229 | ||
230 | /* | |
231 | * Tracepoint for guest CR access. | |
232 | */ | |
233 | TRACE_EVENT(kvm_cr, | |
234 | TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val), | |
235 | TP_ARGS(rw, cr, val), | |
236 | ||
237 | TP_STRUCT__entry( | |
238 | __field( unsigned int, rw ) | |
239 | __field( unsigned int, cr ) | |
240 | __field( unsigned long, val ) | |
241 | ), | |
242 | ||
243 | TP_fast_assign( | |
244 | __entry->rw = rw; | |
245 | __entry->cr = cr; | |
246 | __entry->val = val; | |
247 | ), | |
248 | ||
249 | TP_printk("cr_%s %x = 0x%lx", | |
250 | __entry->rw ? "write" : "read", | |
251 | __entry->cr, __entry->val) | |
252 | ); | |
253 | ||
254 | #define trace_kvm_cr_read(cr, val) trace_kvm_cr(0, cr, val) | |
255 | #define trace_kvm_cr_write(cr, val) trace_kvm_cr(1, cr, val) | |
256 | ||
257 | #endif /* _TRACE_KVM_H */ | |
258 | ||
259 | /* This part must be outside protection */ | |
260 | #include <trace/define_trace.h> |