2 * Arch specific functions for perf kvm stat.
4 * Copyright 2014 IBM Corp.
5 * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
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.
12 #include "../../util/kvm-stat.h"
15 define_exit_reasons_table(sie_exit_reasons
, sie_intercept_code
);
16 define_exit_reasons_table(sie_icpt_insn_codes
, icpt_insn_codes
);
17 define_exit_reasons_table(sie_sigp_order_codes
, sigp_order_codes
);
18 define_exit_reasons_table(sie_diagnose_codes
, diagnose_codes
);
19 define_exit_reasons_table(sie_icpt_prog_codes
, icpt_prog_codes
);
21 const char *vcpu_id_str
= "id";
22 const int decode_str_len
= 40;
23 const char *kvm_exit_reason
= "icptcode";
24 const char *kvm_entry_trace
= "kvm:kvm_s390_sie_enter";
25 const char *kvm_exit_trace
= "kvm:kvm_s390_sie_exit";
27 static void event_icpt_insn_get_key(struct perf_evsel
*evsel
,
28 struct perf_sample
*sample
,
29 struct event_key
*key
)
33 insn
= perf_evsel__intval(evsel
, sample
, "instruction");
34 key
->key
= icpt_insn_decoder(insn
);
35 key
->exit_reasons
= sie_icpt_insn_codes
;
38 static void event_sigp_get_key(struct perf_evsel
*evsel
,
39 struct perf_sample
*sample
,
40 struct event_key
*key
)
42 key
->key
= perf_evsel__intval(evsel
, sample
, "order_code");
43 key
->exit_reasons
= sie_sigp_order_codes
;
46 static void event_diag_get_key(struct perf_evsel
*evsel
,
47 struct perf_sample
*sample
,
48 struct event_key
*key
)
50 key
->key
= perf_evsel__intval(evsel
, sample
, "code");
51 key
->exit_reasons
= sie_diagnose_codes
;
54 static void event_icpt_prog_get_key(struct perf_evsel
*evsel
,
55 struct perf_sample
*sample
,
56 struct event_key
*key
)
58 key
->key
= perf_evsel__intval(evsel
, sample
, "code");
59 key
->exit_reasons
= sie_icpt_prog_codes
;
62 static struct child_event_ops child_events
[] = {
63 { .name
= "kvm:kvm_s390_intercept_instruction",
64 .get_key
= event_icpt_insn_get_key
},
65 { .name
= "kvm:kvm_s390_handle_sigp",
66 .get_key
= event_sigp_get_key
},
67 { .name
= "kvm:kvm_s390_handle_diag",
68 .get_key
= event_diag_get_key
},
69 { .name
= "kvm:kvm_s390_intercept_prog",
70 .get_key
= event_icpt_prog_get_key
},
74 static struct kvm_events_ops exit_events
= {
75 .is_begin_event
= exit_event_begin
,
76 .is_end_event
= exit_event_end
,
77 .child_ops
= child_events
,
78 .decode_key
= exit_event_decode_key
,
82 const char *kvm_events_tp
[] = {
83 "kvm:kvm_s390_sie_enter",
84 "kvm:kvm_s390_sie_exit",
85 "kvm:kvm_s390_intercept_instruction",
86 "kvm:kvm_s390_handle_sigp",
87 "kvm:kvm_s390_handle_diag",
88 "kvm:kvm_s390_intercept_prog",
92 struct kvm_reg_events_ops kvm_reg_events_ops
[] = {
93 { .name
= "vmexit", .ops
= &exit_events
},
97 const char * const kvm_skip_events
[] = {
102 int cpu_isa_init(struct perf_kvm_stat
*kvm
, const char *cpuid
)
104 if (strstr(cpuid
, "IBM/S390")) {
105 kvm
->exit_reasons
= sie_exit_reasons
;
106 kvm
->exit_reasons_isa
= "SIE";