| 1 | #if !defined(LTTNG_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ) |
| 2 | #define LTTNG_TRACE_KVM_MAIN_H |
| 3 | |
| 4 | #include <probes/lttng-tracepoint-event.h> |
| 5 | #include <linux/version.h> |
| 6 | |
| 7 | #undef TRACE_SYSTEM |
| 8 | #define TRACE_SYSTEM kvm |
| 9 | |
| 10 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 11 | |
| 12 | LTTNG_TRACEPOINT_EVENT(kvm_userspace_exit, |
| 13 | TP_PROTO(__u32 reason, int errno), |
| 14 | TP_ARGS(reason, errno), |
| 15 | |
| 16 | TP_FIELDS( |
| 17 | ctf_integer(__u32, reason, reason) |
| 18 | ctf_integer(int, errno, errno) |
| 19 | ) |
| 20 | ) |
| 21 | #endif |
| 22 | |
| 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 |
| 27 | #endif |
| 28 | #endif |
| 29 | |
| 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), |
| 34 | |
| 35 | TP_FIELDS( |
| 36 | ctf_integer(unsigned int, gsi, gsi) |
| 37 | ctf_integer(int, level, level) |
| 38 | ctf_integer(int, irq_source_id, irq_source_id) |
| 39 | ) |
| 40 | ) |
| 41 | #endif |
| 42 | |
| 43 | #if defined(__KVM_HAVE_IOAPIC) |
| 44 | |
| 45 | LTTNG_TRACEPOINT_EVENT(kvm_ioapic_set_irq, |
| 46 | TP_PROTO(__u64 e, int pin, bool coalesced), |
| 47 | TP_ARGS(e, pin, coalesced), |
| 48 | |
| 49 | TP_FIELDS( |
| 50 | ctf_integer(__u64, e, e) |
| 51 | ctf_integer(int, pin, pin) |
| 52 | ctf_integer(bool, coalesced, coalesced) |
| 53 | ) |
| 54 | ) |
| 55 | |
| 56 | LTTNG_TRACEPOINT_EVENT(kvm_msi_set_irq, |
| 57 | TP_PROTO(__u64 address, __u64 data), |
| 58 | TP_ARGS(address, data), |
| 59 | |
| 60 | TP_FIELDS( |
| 61 | ctf_integer(__u64, address, address) |
| 62 | ctf_integer(__u64, data, data) |
| 63 | ) |
| 64 | ) |
| 65 | |
| 66 | LTTNG_TRACEPOINT_EVENT(kvm_ack_irq, |
| 67 | TP_PROTO(unsigned int irqchip, unsigned int pin), |
| 68 | TP_ARGS(irqchip, pin), |
| 69 | |
| 70 | TP_FIELDS( |
| 71 | ctf_integer(unsigned int, irqchip, irqchip) |
| 72 | ctf_integer(unsigned int, pin, pin) |
| 73 | ) |
| 74 | ) |
| 75 | |
| 76 | #endif /* defined(__KVM_HAVE_IOAPIC) */ |
| 77 | |
| 78 | #define KVM_TRACE_MMIO_READ_UNSATISFIED 0 |
| 79 | #define KVM_TRACE_MMIO_READ 1 |
| 80 | #define KVM_TRACE_MMIO_WRITE 2 |
| 81 | |
| 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" } |
| 86 | |
| 87 | LTTNG_TRACEPOINT_EVENT(kvm_mmio, |
| 88 | TP_PROTO(int type, int len, u64 gpa, u64 val), |
| 89 | TP_ARGS(type, len, gpa, val), |
| 90 | |
| 91 | TP_FIELDS( |
| 92 | ctf_integer(u32, type, type) |
| 93 | ctf_integer(u32, len, len) |
| 94 | ctf_integer(u64, gpa, gpa) |
| 95 | ctf_integer(u64, val, val) |
| 96 | ) |
| 97 | ) |
| 98 | |
| 99 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) |
| 100 | |
| 101 | #define kvm_fpu_load_symbol \ |
| 102 | {0, "unload"}, \ |
| 103 | {1, "load"} |
| 104 | |
| 105 | LTTNG_TRACEPOINT_EVENT(kvm_fpu, |
| 106 | TP_PROTO(int load), |
| 107 | TP_ARGS(load), |
| 108 | |
| 109 | TP_FIELDS( |
| 110 | ctf_integer(u32, load, load) |
| 111 | ) |
| 112 | ) |
| 113 | |
| 114 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) \ |
| 115 | || LTTNG_RHEL_KERNEL_RANGE(3,10,0,327,0,0, 3,11,0,0,0,0)) |
| 116 | |
| 117 | LTTNG_TRACEPOINT_EVENT(kvm_age_page, |
| 118 | TP_PROTO(ulong gfn, int level, struct kvm_memory_slot *slot, int ref), |
| 119 | TP_ARGS(gfn, level, slot, ref), |
| 120 | |
| 121 | TP_FIELDS( |
| 122 | ctf_integer(u64, hva, |
| 123 | ((gfn - slot->base_gfn) << PAGE_SHIFT) + slot->userspace_addr) |
| 124 | ctf_integer(u64, gfn, gfn) |
| 125 | ctf_integer(u8, level, level) |
| 126 | ctf_integer(u8, referenced, ref) |
| 127 | ) |
| 128 | ) |
| 129 | |
| 130 | #else |
| 131 | |
| 132 | LTTNG_TRACEPOINT_EVENT(kvm_age_page, |
| 133 | TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref), |
| 134 | TP_ARGS(hva, slot, ref), |
| 135 | |
| 136 | TP_FIELDS( |
| 137 | ctf_integer(u64, hva, hva) |
| 138 | ctf_integer(u64, gfn, |
| 139 | slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT)) |
| 140 | ctf_integer(u8, referenced, ref) |
| 141 | ) |
| 142 | ) |
| 143 | #endif |
| 144 | #endif |
| 145 | |
| 146 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 147 | |
| 148 | #ifdef CONFIG_KVM_ASYNC_PF |
| 149 | LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_get_page_class, |
| 150 | |
| 151 | TP_PROTO(u64 gva, u64 gfn), |
| 152 | |
| 153 | TP_ARGS(gva, gfn), |
| 154 | |
| 155 | TP_FIELDS( |
| 156 | ctf_integer(__u64, gva, gva) |
| 157 | ctf_integer(u64, gfn, gfn) |
| 158 | ) |
| 159 | ) |
| 160 | |
| 161 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class, kvm_try_async_get_page, |
| 162 | |
| 163 | TP_PROTO(u64 gva, u64 gfn), |
| 164 | |
| 165 | TP_ARGS(gva, gfn) |
| 166 | ) |
| 167 | |
| 168 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class, kvm_async_pf_doublefault, |
| 169 | |
| 170 | TP_PROTO(u64 gva, u64 gfn), |
| 171 | |
| 172 | TP_ARGS(gva, gfn) |
| 173 | ) |
| 174 | |
| 175 | LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_pf_nopresent_ready, |
| 176 | |
| 177 | TP_PROTO(u64 token, u64 gva), |
| 178 | |
| 179 | TP_ARGS(token, gva), |
| 180 | |
| 181 | TP_FIELDS( |
| 182 | ctf_integer(__u64, token, token) |
| 183 | ctf_integer(__u64, gva, gva) |
| 184 | ) |
| 185 | ) |
| 186 | |
| 187 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present, |
| 188 | |
| 189 | TP_PROTO(u64 token, u64 gva), |
| 190 | |
| 191 | TP_ARGS(token, gva) |
| 192 | ) |
| 193 | |
| 194 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready, kvm_async_pf_ready, |
| 195 | |
| 196 | TP_PROTO(u64 token, u64 gva), |
| 197 | |
| 198 | TP_ARGS(token, gva) |
| 199 | ) |
| 200 | |
| 201 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0) \ |
| 202 | || LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0)) |
| 203 | |
| 204 | LTTNG_TRACEPOINT_EVENT( |
| 205 | kvm_async_pf_completed, |
| 206 | TP_PROTO(unsigned long address, u64 gva), |
| 207 | TP_ARGS(address, gva), |
| 208 | |
| 209 | TP_FIELDS( |
| 210 | ctf_integer(unsigned long, address, address) |
| 211 | ctf_integer(u64, gva, gva) |
| 212 | ) |
| 213 | ) |
| 214 | |
| 215 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) */ |
| 216 | |
| 217 | LTTNG_TRACEPOINT_EVENT( |
| 218 | kvm_async_pf_completed, |
| 219 | TP_PROTO(unsigned long address, struct page *page, u64 gva), |
| 220 | TP_ARGS(address, page, gva), |
| 221 | |
| 222 | TP_FIELDS( |
| 223 | ctf_integer(unsigned long, address, address) |
| 224 | ctf_integer(pfn_t, pfn, page ? page_to_pfn(page) : 0) |
| 225 | ctf_integer(u64, gva, gva) |
| 226 | ) |
| 227 | ) |
| 228 | |
| 229 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) */ |
| 230 | |
| 231 | #endif |
| 232 | |
| 233 | #endif |
| 234 | |
| 235 | #endif /* LTTNG_TRACE_KVM_MAIN_H */ |
| 236 | |
| 237 | /* This part must be outside protection */ |
| 238 | #include <probes/define_trace.h> |