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 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
[] = {
24 static void event_get_key(struct evsel
*evsel
,
25 struct perf_sample
*sample
,
26 struct event_key
*key
)
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
);
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
,
68 struct kvm_reg_events_ops kvm_reg_events_ops
[] = {
76 const char * const kvm_skip_events
[] = {
80 int cpu_isa_init(struct perf_kvm_stat
*kvm
, const char *cpuid __maybe_unused
)
82 kvm
->exit_reasons_isa
= "arm64";