Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / arch / arm64 / util / kvm-stat.c
blob6611aa21cba957d997d6dbc28fc39d0abbcc7389
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 char *kvm_exit_reason = "ret";
15 const char *kvm_entry_trace = "kvm:kvm_entry";
16 const char *kvm_exit_trace = "kvm:kvm_exit";
18 const char *kvm_events_tp[] = {
19 "kvm:kvm_entry",
20 "kvm:kvm_exit",
21 NULL,
24 static void event_get_key(struct evsel *evsel,
25 struct perf_sample *sample,
26 struct event_key *key)
28 key->info = 0;
29 key->key = evsel__intval(evsel, sample, kvm_exit_reason);
30 key->exit_reasons = arm64_exit_reasons;
33 * TRAP exceptions carry exception class info in esr_ec field
34 * and, hence, we need to use a different exit_reasons table to
35 * properly decode event's est_ec.
37 if (key->key == ARM_EXCEPTION_TRAP) {
38 key->key = evsel__intval(evsel, sample, kvm_trap_exit_reason);
39 key->exit_reasons = arm64_trap_exit_reasons;
43 static bool event_begin(struct evsel *evsel,
44 struct perf_sample *sample __maybe_unused,
45 struct event_key *key __maybe_unused)
47 return evsel__name_is(evsel, kvm_entry_trace);
50 static bool event_end(struct evsel *evsel,
51 struct perf_sample *sample,
52 struct event_key *key)
54 if (evsel__name_is(evsel, kvm_exit_trace)) {
55 event_get_key(evsel, sample, key);
56 return true;
58 return false;
61 static struct kvm_events_ops exit_events = {
62 .is_begin_event = event_begin,
63 .is_end_event = event_end,
64 .decode_key = exit_event_decode_key,
65 .name = "VM-EXIT"
68 struct kvm_reg_events_ops kvm_reg_events_ops[] = {
70 .name = "vmexit",
71 .ops = &exit_events,
73 { NULL, NULL },
76 const char * const kvm_skip_events[] = {
77 NULL,
80 int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)
82 kvm->exit_reasons_isa = "arm64";
83 return 0;