WIP FPC-III support
[linux/fpc-iii.git] / tools / perf / arch / arm64 / util / kvm-stat.c
blob50376b9062c1bae41e528e9154da2d819dd51a37
1 // SPDX-License-Identifier: GPL-2.0
2 #include <errno.h>
3 #include <memory.h>
4 #include "../../util/evsel.h"
5 #include "../../util/kvm-stat.h"
6 #include "arm64_exception_types.h"
7 #include "debug.h"
9 define_exit_reasons_table(arm64_exit_reasons, kvm_arm_exception_type);
10 define_exit_reasons_table(arm64_trap_exit_reasons, kvm_arm_exception_class);
12 const char *kvm_trap_exit_reason = "esr_ec";
13 const char *vcpu_id_str = "id";
14 const int decode_str_len = 20;
15 const char *kvm_exit_reason = "ret";
16 const char *kvm_entry_trace = "kvm:kvm_entry";
17 const char *kvm_exit_trace = "kvm:kvm_exit";
19 const char *kvm_events_tp[] = {
20 "kvm:kvm_entry",
21 "kvm:kvm_exit",
22 NULL,
25 static void event_get_key(struct evsel *evsel,
26 struct perf_sample *sample,
27 struct event_key *key)
29 key->info = 0;
30 key->key = evsel__intval(evsel, sample, kvm_exit_reason);
31 key->exit_reasons = arm64_exit_reasons;
34 * TRAP exceptions carry exception class info in esr_ec field
35 * and, hence, we need to use a different exit_reasons table to
36 * properly decode event's est_ec.
38 if (key->key == ARM_EXCEPTION_TRAP) {
39 key->key = evsel__intval(evsel, sample, kvm_trap_exit_reason);
40 key->exit_reasons = arm64_trap_exit_reasons;
44 static bool event_begin(struct evsel *evsel,
45 struct perf_sample *sample __maybe_unused,
46 struct event_key *key __maybe_unused)
48 return !strcmp(evsel->name, kvm_entry_trace);
51 static bool event_end(struct evsel *evsel,
52 struct perf_sample *sample,
53 struct event_key *key)
55 if (!strcmp(evsel->name, kvm_exit_trace)) {
56 event_get_key(evsel, sample, key);
57 return true;
59 return false;
62 static struct kvm_events_ops exit_events = {
63 .is_begin_event = event_begin,
64 .is_end_event = event_end,
65 .decode_key = exit_event_decode_key,
66 .name = "VM-EXIT"
69 struct kvm_reg_events_ops kvm_reg_events_ops[] = {
71 .name = "vmexit",
72 .ops = &exit_events,
74 { NULL },
77 const char * const kvm_skip_events[] = {
78 NULL,
81 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)
83 kvm->exit_reasons_isa = "arm64";
84 return 0;