brintos

brintos / linux-shallow public Read only

0
0
Text · 1.7 KiB · 491aef4 Raw
79 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * Arch specific functions for perf kvm stat.4 *5 * Copyright 2024 Beijing ESWIN Computing Technology Co., Ltd.6 *7 */8#include <errno.h>9#include <memory.h>10#include "../../../util/evsel.h"11#include "../../../util/kvm-stat.h"12#include "riscv_exception_types.h"13#include "debug.h"14 15define_exit_reasons_table(riscv_exit_reasons, kvm_riscv_exception_class);16 17const char *vcpu_id_str = "id";18const char *kvm_exit_reason = "scause";19const char *kvm_entry_trace = "kvm:kvm_entry";20const char *kvm_exit_trace = "kvm:kvm_exit";21 22const char *kvm_events_tp[] = {23	"kvm:kvm_entry",24	"kvm:kvm_exit",25	NULL,26};27 28static void event_get_key(struct evsel *evsel,29			  struct perf_sample *sample,30			  struct event_key *key)31{32	key->info = 0;33	key->key = evsel__intval(evsel, sample, kvm_exit_reason);34	key->exit_reasons = riscv_exit_reasons;35}36 37static bool event_begin(struct evsel *evsel,38			struct perf_sample *sample __maybe_unused,39			struct event_key *key __maybe_unused)40{41	return evsel__name_is(evsel, kvm_entry_trace);42}43 44static bool event_end(struct evsel *evsel,45		      struct perf_sample *sample,46		      struct event_key *key)47{48	if (evsel__name_is(evsel, kvm_exit_trace)) {49		event_get_key(evsel, sample, key);50		return true;51	}52	return false;53}54 55static struct kvm_events_ops exit_events = {56	.is_begin_event = event_begin,57	.is_end_event	= event_end,58	.decode_key	= exit_event_decode_key,59	.name		= "VM-EXIT"60};61 62struct kvm_reg_events_ops kvm_reg_events_ops[] = {63	{64		.name	= "vmexit",65		.ops	= &exit_events,66	},67	{ NULL, NULL },68};69 70const char * const kvm_skip_events[] = {71	NULL,72};73 74int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)75{76	kvm->exit_reasons_isa = "riscv64";77	return 0;78}79