Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / arch / s390 / util / kvm-stat.c
blob0aed92df51ba85190459300c1245c982835525de
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Arch specific functions for perf kvm stat.
5 * Copyright 2014 IBM Corp.
6 * Author(s): Alexander Yarygin <yarygin@linux.vnet.ibm.com>
7 */
9 #include <errno.h>
10 #include <string.h>
11 #include "../../util/kvm-stat.h"
12 #include "../../util/evsel.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 char *kvm_exit_reason = "icptcode";
23 const char *kvm_entry_trace = "kvm:kvm_s390_sie_enter";
24 const char *kvm_exit_trace = "kvm:kvm_s390_sie_exit";
26 static void event_icpt_insn_get_key(struct evsel *evsel,
27 struct perf_sample *sample,
28 struct event_key *key)
30 unsigned long insn;
32 insn = evsel__intval(evsel, sample, "instruction");
33 key->key = icpt_insn_decoder(insn);
34 key->exit_reasons = sie_icpt_insn_codes;
37 static void event_sigp_get_key(struct evsel *evsel,
38 struct perf_sample *sample,
39 struct event_key *key)
41 key->key = evsel__intval(evsel, sample, "order_code");
42 key->exit_reasons = sie_sigp_order_codes;
45 static void event_diag_get_key(struct evsel *evsel,
46 struct perf_sample *sample,
47 struct event_key *key)
49 key->key = evsel__intval(evsel, sample, "code");
50 key->exit_reasons = sie_diagnose_codes;
53 static void event_icpt_prog_get_key(struct evsel *evsel,
54 struct perf_sample *sample,
55 struct event_key *key)
57 key->key = evsel__intval(evsel, sample, "code");
58 key->exit_reasons = sie_icpt_prog_codes;
61 static struct child_event_ops child_events[] = {
62 { .name = "kvm:kvm_s390_intercept_instruction",
63 .get_key = event_icpt_insn_get_key },
64 { .name = "kvm:kvm_s390_handle_sigp",
65 .get_key = event_sigp_get_key },
66 { .name = "kvm:kvm_s390_handle_diag",
67 .get_key = event_diag_get_key },
68 { .name = "kvm:kvm_s390_intercept_prog",
69 .get_key = event_icpt_prog_get_key },
70 { NULL, NULL },
73 static struct kvm_events_ops exit_events = {
74 .is_begin_event = exit_event_begin,
75 .is_end_event = exit_event_end,
76 .child_ops = child_events,
77 .decode_key = exit_event_decode_key,
78 .name = "VM-EXIT"
81 const char *kvm_events_tp[] = {
82 "kvm:kvm_s390_sie_enter",
83 "kvm:kvm_s390_sie_exit",
84 "kvm:kvm_s390_intercept_instruction",
85 "kvm:kvm_s390_handle_sigp",
86 "kvm:kvm_s390_handle_diag",
87 "kvm:kvm_s390_intercept_prog",
88 NULL,
91 struct kvm_reg_events_ops kvm_reg_events_ops[] = {
92 { .name = "vmexit", .ops = &exit_events },
93 { NULL, NULL },
96 const char * const kvm_skip_events[] = {
97 "Wait state",
98 NULL,
101 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid)
103 if (strstr(cpuid, "IBM")) {
104 kvm->exit_reasons = sie_exit_reasons;
105 kvm->exit_reasons_isa = "SIE";
106 } else
107 return -ENOTSUP;
109 return 0;