Cornelia Huck | 5786fff | 2012-07-23 17:20:29 +0200 | [diff] [blame] | 1 | #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) |
| 2 | #define _TRACE_KVM_H |
| 3 | |
| 4 | #include <linux/tracepoint.h> |
| 5 | #include <asm/sigp.h> |
| 6 | #include <asm/debug.h> |
| 7 | |
| 8 | #undef TRACE_SYSTEM |
| 9 | #define TRACE_SYSTEM kvm |
| 10 | #define TRACE_INCLUDE_PATH . |
| 11 | #undef TRACE_INCLUDE_FILE |
| 12 | #define TRACE_INCLUDE_FILE trace |
| 13 | |
| 14 | /* |
| 15 | * Helpers for vcpu-specific tracepoints containing the same information |
| 16 | * as s390dbf VCPU_EVENTs. |
| 17 | */ |
| 18 | #define VCPU_PROTO_COMMON struct kvm_vcpu *vcpu |
| 19 | #define VCPU_ARGS_COMMON vcpu |
| 20 | #define VCPU_FIELD_COMMON __field(int, id) \ |
| 21 | __field(unsigned long, pswmask) \ |
| 22 | __field(unsigned long, pswaddr) |
| 23 | #define VCPU_ASSIGN_COMMON do { \ |
| 24 | __entry->id = vcpu->vcpu_id; \ |
| 25 | __entry->pswmask = vcpu->arch.sie_block->gpsw.mask; \ |
| 26 | __entry->pswaddr = vcpu->arch.sie_block->gpsw.addr; \ |
| 27 | } while (0); |
| 28 | #define VCPU_TP_PRINTK(p_str, p_args...) \ |
| 29 | TP_printk("%02d[%016lx-%016lx]: " p_str, __entry->id, \ |
| 30 | __entry->pswmask, __entry->pswaddr, p_args) |
| 31 | |
| 32 | /* |
| 33 | * Tracepoints for SIE entry and exit. |
| 34 | */ |
| 35 | TRACE_EVENT(kvm_s390_sie_enter, |
| 36 | TP_PROTO(VCPU_PROTO_COMMON, int cpuflags), |
| 37 | TP_ARGS(VCPU_ARGS_COMMON, cpuflags), |
| 38 | |
| 39 | TP_STRUCT__entry( |
| 40 | VCPU_FIELD_COMMON |
| 41 | __field(int, cpuflags) |
| 42 | ), |
| 43 | |
| 44 | TP_fast_assign( |
| 45 | VCPU_ASSIGN_COMMON |
| 46 | __entry->cpuflags = cpuflags; |
| 47 | ), |
| 48 | |
| 49 | VCPU_TP_PRINTK("entering sie flags %x", __entry->cpuflags) |
| 50 | ); |
| 51 | |
| 52 | TRACE_EVENT(kvm_s390_sie_fault, |
| 53 | TP_PROTO(VCPU_PROTO_COMMON), |
| 54 | TP_ARGS(VCPU_ARGS_COMMON), |
| 55 | |
| 56 | TP_STRUCT__entry( |
| 57 | VCPU_FIELD_COMMON |
| 58 | ), |
| 59 | |
| 60 | TP_fast_assign( |
| 61 | VCPU_ASSIGN_COMMON |
| 62 | ), |
| 63 | |
| 64 | VCPU_TP_PRINTK("%s", "fault in sie instruction") |
| 65 | ); |
| 66 | |
| 67 | #define sie_intercept_code \ |
| 68 | {0x04, "Instruction"}, \ |
| 69 | {0x08, "Program interruption"}, \ |
| 70 | {0x0C, "Instruction and program interuption"}, \ |
| 71 | {0x10, "External request"}, \ |
| 72 | {0x14, "External interruption"}, \ |
| 73 | {0x18, "I/O request"}, \ |
| 74 | {0x1C, "Wait state"}, \ |
| 75 | {0x20, "Validity"}, \ |
| 76 | {0x28, "Stop request"} |
| 77 | |
| 78 | TRACE_EVENT(kvm_s390_sie_exit, |
| 79 | TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode), |
| 80 | TP_ARGS(VCPU_ARGS_COMMON, icptcode), |
| 81 | |
| 82 | TP_STRUCT__entry( |
| 83 | VCPU_FIELD_COMMON |
| 84 | __field(u8, icptcode) |
| 85 | ), |
| 86 | |
| 87 | TP_fast_assign( |
| 88 | VCPU_ASSIGN_COMMON |
| 89 | __entry->icptcode = icptcode; |
| 90 | ), |
| 91 | |
| 92 | VCPU_TP_PRINTK("exit sie icptcode %d (%s)", __entry->icptcode, |
| 93 | __print_symbolic(__entry->icptcode, |
| 94 | sie_intercept_code)) |
| 95 | ); |
| 96 | |
| 97 | /* |
| 98 | * Trace point for intercepted instructions. |
| 99 | */ |
| 100 | TRACE_EVENT(kvm_s390_intercept_instruction, |
| 101 | TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb), |
| 102 | TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb), |
| 103 | |
| 104 | TP_STRUCT__entry( |
| 105 | VCPU_FIELD_COMMON |
| 106 | __field(__u64, instruction) |
| 107 | __field(char, insn[8]) |
| 108 | ), |
| 109 | |
| 110 | TP_fast_assign( |
| 111 | VCPU_ASSIGN_COMMON |
| 112 | __entry->instruction = ((__u64)ipa << 48) | |
| 113 | ((__u64)ipb << 16); |
| 114 | ), |
| 115 | |
| 116 | VCPU_TP_PRINTK("intercepted instruction %016llx (%s)", |
| 117 | __entry->instruction, |
| 118 | insn_to_mnemonic((unsigned char *) |
| 119 | &__entry->instruction, |
| 120 | __entry->insn) ? |
| 121 | "unknown" : __entry->insn) |
| 122 | ); |
| 123 | |
| 124 | /* |
| 125 | * Trace point for intercepted program interruptions. |
| 126 | */ |
| 127 | TRACE_EVENT(kvm_s390_intercept_prog, |
| 128 | TP_PROTO(VCPU_PROTO_COMMON, __u16 code), |
| 129 | TP_ARGS(VCPU_ARGS_COMMON, code), |
| 130 | |
| 131 | TP_STRUCT__entry( |
| 132 | VCPU_FIELD_COMMON |
| 133 | __field(__u16, code) |
| 134 | ), |
| 135 | |
| 136 | TP_fast_assign( |
| 137 | VCPU_ASSIGN_COMMON |
| 138 | __entry->code = code; |
| 139 | ), |
| 140 | |
| 141 | VCPU_TP_PRINTK("intercepted program interruption %04x", |
| 142 | __entry->code) |
| 143 | ); |
| 144 | |
| 145 | /* |
| 146 | * Trace point for validity intercepts. |
| 147 | */ |
| 148 | TRACE_EVENT(kvm_s390_intercept_validity, |
| 149 | TP_PROTO(VCPU_PROTO_COMMON, __u16 viwhy), |
| 150 | TP_ARGS(VCPU_ARGS_COMMON, viwhy), |
| 151 | |
| 152 | TP_STRUCT__entry( |
| 153 | VCPU_FIELD_COMMON |
| 154 | __field(__u16, viwhy) |
| 155 | ), |
| 156 | |
| 157 | TP_fast_assign( |
| 158 | VCPU_ASSIGN_COMMON |
| 159 | __entry->viwhy = viwhy; |
| 160 | ), |
| 161 | |
| 162 | VCPU_TP_PRINTK("got validity intercept %04x", __entry->viwhy) |
| 163 | ); |
| 164 | |
| 165 | /* |
| 166 | * Trace points for instructions that are of special interest. |
| 167 | */ |
| 168 | |
| 169 | #define sigp_order_codes \ |
| 170 | {SIGP_SENSE, "sense"}, \ |
| 171 | {SIGP_EXTERNAL_CALL, "external call"}, \ |
| 172 | {SIGP_EMERGENCY_SIGNAL, "emergency signal"}, \ |
| 173 | {SIGP_STOP, "stop"}, \ |
| 174 | {SIGP_STOP_AND_STORE_STATUS, "stop and store status"}, \ |
| 175 | {SIGP_SET_ARCHITECTURE, "set architecture"}, \ |
| 176 | {SIGP_SET_PREFIX, "set prefix"}, \ |
| 177 | {SIGP_SENSE_RUNNING, "sense running"}, \ |
| 178 | {SIGP_RESTART, "restart"} |
| 179 | |
| 180 | TRACE_EVENT(kvm_s390_handle_sigp, |
| 181 | TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr, \ |
| 182 | __u32 parameter), |
| 183 | TP_ARGS(VCPU_ARGS_COMMON, order_code, cpu_addr, parameter), |
| 184 | |
| 185 | TP_STRUCT__entry( |
| 186 | VCPU_FIELD_COMMON |
| 187 | __field(__u8, order_code) |
| 188 | __field(__u16, cpu_addr) |
| 189 | __field(__u32, parameter) |
| 190 | ), |
| 191 | |
| 192 | TP_fast_assign( |
| 193 | VCPU_ASSIGN_COMMON |
| 194 | __entry->order_code = order_code; |
| 195 | __entry->cpu_addr = cpu_addr; |
| 196 | __entry->parameter = parameter; |
| 197 | ), |
| 198 | |
| 199 | VCPU_TP_PRINTK("handle sigp order %02x (%s), cpu address %04x, " \ |
| 200 | "parameter %08x", __entry->order_code, |
| 201 | __print_symbolic(__entry->order_code, |
| 202 | sigp_order_codes), |
| 203 | __entry->cpu_addr, __entry->parameter) |
| 204 | ); |
| 205 | |
| 206 | #define diagnose_codes \ |
| 207 | {0x10, "release pages"}, \ |
| 208 | {0x44, "time slice end"}, \ |
| 209 | {0x308, "ipl functions"}, \ |
| 210 | {0x500, "kvm hypercall"}, \ |
| 211 | {0x501, "kvm breakpoint"} |
| 212 | |
| 213 | TRACE_EVENT(kvm_s390_handle_diag, |
| 214 | TP_PROTO(VCPU_PROTO_COMMON, __u16 code), |
| 215 | TP_ARGS(VCPU_ARGS_COMMON, code), |
| 216 | |
| 217 | TP_STRUCT__entry( |
| 218 | VCPU_FIELD_COMMON |
| 219 | __field(__u16, code) |
| 220 | ), |
| 221 | |
| 222 | TP_fast_assign( |
| 223 | VCPU_ASSIGN_COMMON |
| 224 | __entry->code = code; |
| 225 | ), |
| 226 | |
| 227 | VCPU_TP_PRINTK("handle diagnose call %04x (%s)", __entry->code, |
| 228 | __print_symbolic(__entry->code, diagnose_codes)) |
| 229 | ); |
| 230 | |
| 231 | TRACE_EVENT(kvm_s390_handle_lctl, |
| 232 | TP_PROTO(VCPU_PROTO_COMMON, int g, int reg1, int reg3, u64 addr), |
| 233 | TP_ARGS(VCPU_ARGS_COMMON, g, reg1, reg3, addr), |
| 234 | |
| 235 | TP_STRUCT__entry( |
| 236 | VCPU_FIELD_COMMON |
| 237 | __field(int, g) |
| 238 | __field(int, reg1) |
| 239 | __field(int, reg3) |
| 240 | __field(u64, addr) |
| 241 | ), |
| 242 | |
| 243 | TP_fast_assign( |
| 244 | VCPU_ASSIGN_COMMON |
| 245 | __entry->g = g; |
| 246 | __entry->reg1 = reg1; |
| 247 | __entry->reg3 = reg3; |
| 248 | __entry->addr = addr; |
| 249 | ), |
| 250 | |
| 251 | VCPU_TP_PRINTK("%s: loading cr %x-%x from %016llx", |
| 252 | __entry->g ? "lctlg" : "lctl", |
| 253 | __entry->reg1, __entry->reg3, __entry->addr) |
| 254 | ); |
| 255 | |
| 256 | TRACE_EVENT(kvm_s390_handle_prefix, |
| 257 | TP_PROTO(VCPU_PROTO_COMMON, int set, u32 address), |
| 258 | TP_ARGS(VCPU_ARGS_COMMON, set, address), |
| 259 | |
| 260 | TP_STRUCT__entry( |
| 261 | VCPU_FIELD_COMMON |
| 262 | __field(int, set) |
| 263 | __field(u32, address) |
| 264 | ), |
| 265 | |
| 266 | TP_fast_assign( |
| 267 | VCPU_ASSIGN_COMMON |
| 268 | __entry->set = set; |
| 269 | __entry->address = address; |
| 270 | ), |
| 271 | |
| 272 | VCPU_TP_PRINTK("%s prefix to %08x", |
| 273 | __entry->set ? "setting" : "storing", |
| 274 | __entry->address) |
| 275 | ); |
| 276 | |
| 277 | TRACE_EVENT(kvm_s390_handle_stap, |
| 278 | TP_PROTO(VCPU_PROTO_COMMON, u64 address), |
| 279 | TP_ARGS(VCPU_ARGS_COMMON, address), |
| 280 | |
| 281 | TP_STRUCT__entry( |
| 282 | VCPU_FIELD_COMMON |
| 283 | __field(u64, address) |
| 284 | ), |
| 285 | |
| 286 | TP_fast_assign( |
| 287 | VCPU_ASSIGN_COMMON |
| 288 | __entry->address = address; |
| 289 | ), |
| 290 | |
| 291 | VCPU_TP_PRINTK("storing cpu address to %016llx", |
| 292 | __entry->address) |
| 293 | ); |
| 294 | |
| 295 | TRACE_EVENT(kvm_s390_handle_stfl, |
| 296 | TP_PROTO(VCPU_PROTO_COMMON, unsigned int facility_list), |
| 297 | TP_ARGS(VCPU_ARGS_COMMON, facility_list), |
| 298 | |
| 299 | TP_STRUCT__entry( |
| 300 | VCPU_FIELD_COMMON |
| 301 | __field(unsigned int, facility_list) |
| 302 | ), |
| 303 | |
| 304 | TP_fast_assign( |
| 305 | VCPU_ASSIGN_COMMON |
| 306 | __entry->facility_list = facility_list; |
| 307 | ), |
| 308 | |
| 309 | VCPU_TP_PRINTK("store facility list value %08x", |
| 310 | __entry->facility_list) |
| 311 | ); |
| 312 | |
| 313 | TRACE_EVENT(kvm_s390_handle_stsi, |
| 314 | TP_PROTO(VCPU_PROTO_COMMON, int fc, int sel1, int sel2, u64 addr), |
| 315 | TP_ARGS(VCPU_ARGS_COMMON, fc, sel1, sel2, addr), |
| 316 | |
| 317 | TP_STRUCT__entry( |
| 318 | VCPU_FIELD_COMMON |
| 319 | __field(int, fc) |
| 320 | __field(int, sel1) |
| 321 | __field(int, sel2) |
| 322 | __field(u64, addr) |
| 323 | ), |
| 324 | |
| 325 | TP_fast_assign( |
| 326 | VCPU_ASSIGN_COMMON |
| 327 | __entry->fc = fc; |
| 328 | __entry->sel1 = sel1; |
| 329 | __entry->sel2 = sel2; |
| 330 | __entry->addr = addr; |
| 331 | ), |
| 332 | |
| 333 | VCPU_TP_PRINTK("STSI %d.%d.%d information stored to %016llx", |
| 334 | __entry->fc, __entry->sel1, __entry->sel2, |
| 335 | __entry->addr) |
| 336 | ); |
| 337 | |
| 338 | #endif /* _TRACE_KVM_H */ |
| 339 | |
| 340 | /* This part must be outside protection */ |
| 341 | #include <trace/define_trace.h> |