1 /* 2 * Arch specific functions for perf kvm stat. 3 * 4 * Copyright 2014 IBM Corp. 5 * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License (version 2 only) 9 * as published by the Free Software Foundation. 10 */ 11 12 #include <errno.h> 13 #include "../../util/kvm-stat.h" 14 #include <asm/sie.h> 15 16 define_exit_reasons_table(sie_exit_reasons, sie_intercept_code); 17 define_exit_reasons_table(sie_icpt_insn_codes, icpt_insn_codes); 18 define_exit_reasons_table(sie_sigp_order_codes, sigp_order_codes); 19 define_exit_reasons_table(sie_diagnose_codes, diagnose_codes); 20 define_exit_reasons_table(sie_icpt_prog_codes, icpt_prog_codes); 21 22 const char *vcpu_id_str = "id"; 23 const int decode_str_len = 40; 24 const char *kvm_exit_reason = "icptcode"; 25 const char *kvm_entry_trace = "kvm:kvm_s390_sie_enter"; 26 const char *kvm_exit_trace = "kvm:kvm_s390_sie_exit"; 27 28 static void event_icpt_insn_get_key(struct perf_evsel *evsel, 29 struct perf_sample *sample, 30 struct event_key *key) 31 { 32 unsigned long insn; 33 34 insn = perf_evsel__intval(evsel, sample, "instruction"); 35 key->key = icpt_insn_decoder(insn); 36 key->exit_reasons = sie_icpt_insn_codes; 37 } 38 39 static void event_sigp_get_key(struct perf_evsel *evsel, 40 struct perf_sample *sample, 41 struct event_key *key) 42 { 43 key->key = perf_evsel__intval(evsel, sample, "order_code"); 44 key->exit_reasons = sie_sigp_order_codes; 45 } 46 47 static void event_diag_get_key(struct perf_evsel *evsel, 48 struct perf_sample *sample, 49 struct event_key *key) 50 { 51 key->key = perf_evsel__intval(evsel, sample, "code"); 52 key->exit_reasons = sie_diagnose_codes; 53 } 54 55 static void event_icpt_prog_get_key(struct perf_evsel *evsel, 56 struct perf_sample *sample, 57 struct event_key *key) 58 { 59 key->key = perf_evsel__intval(evsel, sample, "code"); 60 key->exit_reasons = sie_icpt_prog_codes; 61 } 62 63 static struct child_event_ops child_events[] = { 64 { .name = "kvm:kvm_s390_intercept_instruction", 65 .get_key = event_icpt_insn_get_key }, 66 { .name = "kvm:kvm_s390_handle_sigp", 67 .get_key = event_sigp_get_key }, 68 { .name = "kvm:kvm_s390_handle_diag", 69 .get_key = event_diag_get_key }, 70 { .name = "kvm:kvm_s390_intercept_prog", 71 .get_key = event_icpt_prog_get_key }, 72 { NULL, NULL }, 73 }; 74 75 static struct kvm_events_ops exit_events = { 76 .is_begin_event = exit_event_begin, 77 .is_end_event = exit_event_end, 78 .child_ops = child_events, 79 .decode_key = exit_event_decode_key, 80 .name = "VM-EXIT" 81 }; 82 83 const char *kvm_events_tp[] = { 84 "kvm:kvm_s390_sie_enter", 85 "kvm:kvm_s390_sie_exit", 86 "kvm:kvm_s390_intercept_instruction", 87 "kvm:kvm_s390_handle_sigp", 88 "kvm:kvm_s390_handle_diag", 89 "kvm:kvm_s390_intercept_prog", 90 NULL, 91 }; 92 93 struct kvm_reg_events_ops kvm_reg_events_ops[] = { 94 { .name = "vmexit", .ops = &exit_events }, 95 { NULL, NULL }, 96 }; 97 98 const char * const kvm_skip_events[] = { 99 "Wait state", 100 NULL, 101 }; 102 103 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid) 104 { 105 if (strstr(cpuid, "IBM/S390")) { 106 kvm->exit_reasons = sie_exit_reasons; 107 kvm->exit_reasons_isa = "SIE"; 108 } else 109 return -ENOTSUP; 110 111 return 0; 112 } 113