| 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 | |
| 88 | #if (LTTNG_SLE_KERNEL_RANGE(4,4,121,92,92,0, 4,4,122,0,0,0) \ |
| 89 | || LTTNG_SLE_KERNEL_RANGE(4,4,131,94,0,0, 4,5,0,0,0,0)) |
| 90 | |
| 91 | LTTNG_TRACEPOINT_EVENT(kvm_mmio, |
| 92 | TP_PROTO(int type, int len, u64 gpa, u64 val), |
| 93 | TP_ARGS(type, len, gpa, val), |
| 94 | |
| 95 | TP_FIELDS( |
| 96 | ctf_integer(u32, type, type) |
| 97 | ctf_integer(u32, len, len) |
| 98 | ctf_integer(u64, gpa, gpa) |
| 99 | ctf_integer(u64, val, val) |
| 100 | ) |
| 101 | ) |
| 102 | |
| 103 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) \ |
| 104 | || LTTNG_KERNEL_RANGE(4,14,14, 4,15,0) \ |
| 105 | || LTTNG_DEBIAN_KERNEL_RANGE(4,14,13,0,1,0, 4,15,0,0,0,0) \ |
| 106 | || LTTNG_KERNEL_RANGE(4,9,77, 4,10,0) \ |
| 107 | || LTTNG_KERNEL_RANGE(4,4,112, 4,5,0) \ |
| 108 | || LTTNG_KERNEL_RANGE(4,1,50, 4,2,0) \ |
| 109 | || LTTNG_KERNEL_RANGE(3,16,52, 3,17,0) \ |
| 110 | || LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,144, 3,14,0,0) \ |
| 111 | || LTTNG_KERNEL_RANGE(3,2,97, 3,3,0) \ |
| 112 | || LTTNG_UBUNTU_KERNEL_RANGE(4,13,16,38, 4,14,0,0) \ |
| 113 | || LTTNG_DEBIAN_KERNEL_RANGE(4,9,65,0,3,0, 4,10,0,0,0,0) \ |
| 114 | || LTTNG_FEDORA_KERNEL_RANGE(4,14,13,300, 4,15,0,0)) |
| 115 | |
| 116 | LTTNG_TRACEPOINT_EVENT(kvm_mmio, |
| 117 | TP_PROTO(int type, int len, u64 gpa, void *val), |
| 118 | TP_ARGS(type, len, gpa, val), |
| 119 | |
| 120 | TP_FIELDS( |
| 121 | ctf_integer(u32, type, type) |
| 122 | ctf_integer(u32, len, len) |
| 123 | ctf_integer(u64, gpa, gpa) |
| 124 | ctf_sequence_hex(unsigned char, val, val, u32, len) |
| 125 | ) |
| 126 | ) |
| 127 | |
| 128 | #else |
| 129 | |
| 130 | LTTNG_TRACEPOINT_EVENT(kvm_mmio, |
| 131 | TP_PROTO(int type, int len, u64 gpa, u64 val), |
| 132 | TP_ARGS(type, len, gpa, val), |
| 133 | |
| 134 | TP_FIELDS( |
| 135 | ctf_integer(u32, type, type) |
| 136 | ctf_integer(u32, len, len) |
| 137 | ctf_integer(u64, gpa, gpa) |
| 138 | ctf_integer(u64, val, val) |
| 139 | ) |
| 140 | ) |
| 141 | |
| 142 | #endif |
| 143 | |
| 144 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) |
| 145 | |
| 146 | #define kvm_fpu_load_symbol \ |
| 147 | {0, "unload"}, \ |
| 148 | {1, "load"} |
| 149 | |
| 150 | LTTNG_TRACEPOINT_EVENT(kvm_fpu, |
| 151 | TP_PROTO(int load), |
| 152 | TP_ARGS(load), |
| 153 | |
| 154 | TP_FIELDS( |
| 155 | ctf_integer(u32, load, load) |
| 156 | ) |
| 157 | ) |
| 158 | |
| 159 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) \ |
| 160 | || LTTNG_RHEL_KERNEL_RANGE(3,10,0,327,0,0, 3,11,0,0,0,0)) |
| 161 | |
| 162 | LTTNG_TRACEPOINT_EVENT(kvm_age_page, |
| 163 | TP_PROTO(ulong gfn, int level, struct kvm_memory_slot *slot, int ref), |
| 164 | TP_ARGS(gfn, level, slot, ref), |
| 165 | |
| 166 | TP_FIELDS( |
| 167 | ctf_integer(u64, hva, |
| 168 | ((gfn - slot->base_gfn) << PAGE_SHIFT) + slot->userspace_addr) |
| 169 | ctf_integer(u64, gfn, gfn) |
| 170 | ctf_integer(u8, level, level) |
| 171 | ctf_integer(u8, referenced, ref) |
| 172 | ) |
| 173 | ) |
| 174 | |
| 175 | #else |
| 176 | |
| 177 | LTTNG_TRACEPOINT_EVENT(kvm_age_page, |
| 178 | TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref), |
| 179 | TP_ARGS(hva, slot, ref), |
| 180 | |
| 181 | TP_FIELDS( |
| 182 | ctf_integer(u64, hva, hva) |
| 183 | ctf_integer(u64, gfn, |
| 184 | slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT)) |
| 185 | ctf_integer(u8, referenced, ref) |
| 186 | ) |
| 187 | ) |
| 188 | #endif |
| 189 | #endif |
| 190 | |
| 191 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 192 | |
| 193 | #ifdef CONFIG_KVM_ASYNC_PF |
| 194 | LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_get_page_class, |
| 195 | |
| 196 | TP_PROTO(u64 gva, u64 gfn), |
| 197 | |
| 198 | TP_ARGS(gva, gfn), |
| 199 | |
| 200 | TP_FIELDS( |
| 201 | ctf_integer(__u64, gva, gva) |
| 202 | ctf_integer(u64, gfn, gfn) |
| 203 | ) |
| 204 | ) |
| 205 | |
| 206 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class, kvm_try_async_get_page, |
| 207 | |
| 208 | TP_PROTO(u64 gva, u64 gfn), |
| 209 | |
| 210 | TP_ARGS(gva, gfn) |
| 211 | ) |
| 212 | |
| 213 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_get_page_class, kvm_async_pf_doublefault, |
| 214 | |
| 215 | TP_PROTO(u64 gva, u64 gfn), |
| 216 | |
| 217 | TP_ARGS(gva, gfn) |
| 218 | ) |
| 219 | |
| 220 | LTTNG_TRACEPOINT_EVENT_CLASS(kvm_async_pf_nopresent_ready, |
| 221 | |
| 222 | TP_PROTO(u64 token, u64 gva), |
| 223 | |
| 224 | TP_ARGS(token, gva), |
| 225 | |
| 226 | TP_FIELDS( |
| 227 | ctf_integer(__u64, token, token) |
| 228 | ctf_integer(__u64, gva, gva) |
| 229 | ) |
| 230 | ) |
| 231 | |
| 232 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present, |
| 233 | |
| 234 | TP_PROTO(u64 token, u64 gva), |
| 235 | |
| 236 | TP_ARGS(token, gva) |
| 237 | ) |
| 238 | |
| 239 | LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready, kvm_async_pf_ready, |
| 240 | |
| 241 | TP_PROTO(u64 token, u64 gva), |
| 242 | |
| 243 | TP_ARGS(token, gva) |
| 244 | ) |
| 245 | |
| 246 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0) \ |
| 247 | || LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0)) |
| 248 | |
| 249 | LTTNG_TRACEPOINT_EVENT( |
| 250 | kvm_async_pf_completed, |
| 251 | TP_PROTO(unsigned long address, u64 gva), |
| 252 | TP_ARGS(address, gva), |
| 253 | |
| 254 | TP_FIELDS( |
| 255 | ctf_integer(unsigned long, address, address) |
| 256 | ctf_integer(u64, gva, gva) |
| 257 | ) |
| 258 | ) |
| 259 | |
| 260 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) */ |
| 261 | |
| 262 | LTTNG_TRACEPOINT_EVENT( |
| 263 | kvm_async_pf_completed, |
| 264 | TP_PROTO(unsigned long address, struct page *page, u64 gva), |
| 265 | TP_ARGS(address, page, gva), |
| 266 | |
| 267 | TP_FIELDS( |
| 268 | ctf_integer(unsigned long, address, address) |
| 269 | ctf_integer(pfn_t, pfn, page ? page_to_pfn(page) : 0) |
| 270 | ctf_integer(u64, gva, gva) |
| 271 | ) |
| 272 | ) |
| 273 | |
| 274 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0)) */ |
| 275 | |
| 276 | #endif |
| 277 | |
| 278 | #endif |
| 279 | |
| 280 | #endif /* LTTNG_TRACE_KVM_MAIN_H */ |
| 281 | |
| 282 | /* This part must be outside protection */ |
| 283 | #include <probes/define_trace.h> |