Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / tools / perf / arch / s390 / util / kvm-stat.c
blobed57df2e6d687d89ccf95d9aa03c263411de7fe9
1 /*
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"
13 #include <asm/sie.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)
31 unsigned long insn;
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 },
71 { NULL, NULL },
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,
79 .name = "VM-EXIT"
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",
89 NULL,
92 struct kvm_reg_events_ops kvm_reg_events_ops[] = {
93 { .name = "vmexit", .ops = &exit_events },
94 { NULL, NULL },
97 const char * const kvm_skip_events[] = {
98 "Wait state",
99 NULL,
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";
107 } else
108 return -ENOTSUP;
110 return 0;