1 // SPDX-License-Identifier: GPL-2.0
4 #include "../../util/evsel.h"
5 #include "../../util/kvm-stat.h"
6 #include "arm64_exception_types.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
[] = {
25 static void event_get_key(struct evsel
*evsel
,
26 struct perf_sample
*sample
,
27 struct event_key
*key
)
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
);
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
,
69 struct kvm_reg_events_ops kvm_reg_events_ops
[] = {
77 const char * const kvm_skip_events
[] = {
81 int cpu_isa_init(struct perf_kvm_stat
*kvm
, const char *cpuid __maybe_unused
)
83 kvm
->exit_reasons_isa
= "arm64";