9c2cc6a96e825b6853016b090734f31a539b4f52
[linux-2.6.git] / include / trace / events / kvm.h
1 #if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
2 #define _TRACE_KVM_MAIN_H
3
4 #include <linux/tracepoint.h>
5
6 #undef TRACE_SYSTEM
7 #define TRACE_SYSTEM kvm
8
9 #if defined(__KVM_HAVE_IOAPIC)
10 TRACE_EVENT(kvm_set_irq,
11         TP_PROTO(unsigned int gsi, int level, int irq_source_id),
12         TP_ARGS(gsi, level, irq_source_id),
13
14         TP_STRUCT__entry(
15                 __field(        unsigned int,   gsi             )
16                 __field(        int,            level           )
17                 __field(        int,            irq_source_id   )
18         ),
19
20         TP_fast_assign(
21                 __entry->gsi            = gsi;
22                 __entry->level          = level;
23                 __entry->irq_source_id  = irq_source_id;
24         ),
25
26         TP_printk("gsi %u level %d source %d",
27                   __entry->gsi, __entry->level, __entry->irq_source_id)
28 );
29
30 #define kvm_deliver_mode                \
31         {0x0, "Fixed"},                 \
32         {0x1, "LowPrio"},               \
33         {0x2, "SMI"},                   \
34         {0x3, "Res3"},                  \
35         {0x4, "NMI"},                   \
36         {0x5, "INIT"},                  \
37         {0x6, "SIPI"},                  \
38         {0x7, "ExtINT"}
39
40 TRACE_EVENT(kvm_ioapic_set_irq,
41             TP_PROTO(__u64 e, int pin, bool coalesced),
42             TP_ARGS(e, pin, coalesced),
43
44         TP_STRUCT__entry(
45                 __field(        __u64,          e               )
46                 __field(        int,            pin             )
47                 __field(        bool,           coalesced       )
48         ),
49
50         TP_fast_assign(
51                 __entry->e              = e;
52                 __entry->pin            = pin;
53                 __entry->coalesced      = coalesced;
54         ),
55
56         TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
57                   __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e,
58                   __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode),
59                   (__entry->e & (1<<11)) ? "logical" : "physical",
60                   (__entry->e & (1<<15)) ? "level" : "edge",
61                   (__entry->e & (1<<16)) ? "|masked" : "",
62                   __entry->coalesced ? " (coalesced)" : "")
63 );
64
65 TRACE_EVENT(kvm_msi_set_irq,
66             TP_PROTO(__u64 address, __u64 data),
67             TP_ARGS(address, data),
68
69         TP_STRUCT__entry(
70                 __field(        __u64,          address         )
71                 __field(        __u64,          data            )
72         ),
73
74         TP_fast_assign(
75                 __entry->address        = address;
76                 __entry->data           = data;
77         ),
78
79         TP_printk("dst %u vec %x (%s|%s|%s%s)",
80                   (u8)(__entry->address >> 12), (u8)__entry->data,
81                   __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode),
82                   (__entry->address & (1<<2)) ? "logical" : "physical",
83                   (__entry->data & (1<<15)) ? "level" : "edge",
84                   (__entry->address & (1<<3)) ? "|rh" : "")
85 );
86
87 #define kvm_irqchips                                            \
88         {KVM_IRQCHIP_PIC_MASTER,        "PIC master"},          \
89         {KVM_IRQCHIP_PIC_SLAVE,         "PIC slave"},           \
90         {KVM_IRQCHIP_IOAPIC,            "IOAPIC"}
91
92 TRACE_EVENT(kvm_ack_irq,
93         TP_PROTO(unsigned int irqchip, unsigned int pin),
94         TP_ARGS(irqchip, pin),
95
96         TP_STRUCT__entry(
97                 __field(        unsigned int,   irqchip         )
98                 __field(        unsigned int,   pin             )
99         ),
100
101         TP_fast_assign(
102                 __entry->irqchip        = irqchip;
103                 __entry->pin            = pin;
104         ),
105
106         TP_printk("irqchip %s pin %u",
107                   __print_symbolic(__entry->irqchip, kvm_irqchips),
108                  __entry->pin)
109 );
110
111
112
113 #endif /* defined(__KVM_HAVE_IOAPIC) */
114
115 #define KVM_TRACE_MMIO_READ_UNSATISFIED 0
116 #define KVM_TRACE_MMIO_READ 1
117 #define KVM_TRACE_MMIO_WRITE 2
118
119 #define kvm_trace_symbol_mmio \
120         { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
121         { KVM_TRACE_MMIO_READ, "read" }, \
122         { KVM_TRACE_MMIO_WRITE, "write" }
123
124 TRACE_EVENT(kvm_mmio,
125         TP_PROTO(int type, int len, u64 gpa, u64 val),
126         TP_ARGS(type, len, gpa, val),
127
128         TP_STRUCT__entry(
129                 __field(        u32,    type            )
130                 __field(        u32,    len             )
131                 __field(        u64,    gpa             )
132                 __field(        u64,    val             )
133         ),
134
135         TP_fast_assign(
136                 __entry->type           = type;
137                 __entry->len            = len;
138                 __entry->gpa            = gpa;
139                 __entry->val            = val;
140         ),
141
142         TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
143                   __print_symbolic(__entry->type, kvm_trace_symbol_mmio),
144                   __entry->len, __entry->gpa, __entry->val)
145 );
146
147 #define kvm_fpu_load_symbol     \
148         {0, "unload"},          \
149         {1, "load"}
150
151 TRACE_EVENT(kvm_fpu,
152         TP_PROTO(int load),
153         TP_ARGS(load),
154
155         TP_STRUCT__entry(
156                 __field(        u32,            load            )
157         ),
158
159         TP_fast_assign(
160                 __entry->load           = load;
161         ),
162
163         TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
164 );
165
166 TRACE_EVENT(kvm_age_page,
167         TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
168         TP_ARGS(hva, slot, ref),
169
170         TP_STRUCT__entry(
171                 __field(        u64,    hva             )
172                 __field(        u64,    gfn             )
173                 __field(        u8,     referenced      )
174         ),
175
176         TP_fast_assign(
177                 __entry->hva            = hva;
178                 __entry->gfn            =
179                   slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
180                 __entry->referenced     = ref;
181         ),
182
183         TP_printk("hva %llx gfn %llx %s",
184                   __entry->hva, __entry->gfn,
185                   __entry->referenced ? "YOUNG" : "OLD")
186 );
187
188 #ifdef CONFIG_KVM_ASYNC_PF
189 TRACE_EVENT(
190         kvm_try_async_get_page,
191         TP_PROTO(bool async, u64 pfn),
192         TP_ARGS(async, pfn),
193
194         TP_STRUCT__entry(
195                 __field(__u64, pfn)
196                 ),
197
198         TP_fast_assign(
199                 __entry->pfn = (!async) ? pfn : (u64)-1;
200                 ),
201
202         TP_printk("pfn %#llx", __entry->pfn)
203 );
204
205 TRACE_EVENT(
206         kvm_async_pf_not_present,
207         TP_PROTO(u64 token, u64 gva),
208         TP_ARGS(token, gva),
209
210         TP_STRUCT__entry(
211                 __field(__u64, token)
212                 __field(__u64, gva)
213                 ),
214
215         TP_fast_assign(
216                 __entry->token = token;
217                 __entry->gva = gva;
218                 ),
219
220         TP_printk("token %#llx gva %#llx not present", __entry->token,
221                   __entry->gva)
222 );
223
224 TRACE_EVENT(
225         kvm_async_pf_ready,
226         TP_PROTO(u64 token, u64 gva),
227         TP_ARGS(token, gva),
228
229         TP_STRUCT__entry(
230                 __field(__u64, token)
231                 __field(__u64, gva)
232                 ),
233
234         TP_fast_assign(
235                 __entry->token = token;
236                 __entry->gva = gva;
237                 ),
238
239         TP_printk("token %#llx gva %#llx ready", __entry->token, __entry->gva)
240 );
241
242 TRACE_EVENT(
243         kvm_async_pf_completed,
244         TP_PROTO(unsigned long address, struct page *page, u64 gva),
245         TP_ARGS(address, page, gva),
246
247         TP_STRUCT__entry(
248                 __field(unsigned long, address)
249                 __field(pfn_t, pfn)
250                 __field(u64, gva)
251                 ),
252
253         TP_fast_assign(
254                 __entry->address = address;
255                 __entry->pfn = page ? page_to_pfn(page) : 0;
256                 __entry->gva = gva;
257                 ),
258
259         TP_printk("gva %#llx address %#lx pfn %#llx",  __entry->gva,
260                   __entry->address, __entry->pfn)
261 );
262
263 TRACE_EVENT(
264         kvm_async_pf_doublefault,
265         TP_PROTO(u64 gva, u64 gfn),
266         TP_ARGS(gva, gfn),
267
268         TP_STRUCT__entry(
269                 __field(u64, gva)
270                 __field(u64, gfn)
271                 ),
272
273         TP_fast_assign(
274                 __entry->gva = gva;
275                 __entry->gfn = gfn;
276                 ),
277
278         TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
279 );
280
281 #endif
282
283 #endif /* _TRACE_KVM_MAIN_H */
284
285 /* This part must be outside protection */
286 #include <trace/define_trace.h>