Files
linux-cryptodev-2.6/tools/perf/util/kvm-stat-arch/kvm-stat-riscv.c
Ian Rogers 43af548436 perf kvm: Wire up e_machine
Pass the e_machine to the kvm functions so that they aren't just wired
to EM_HOST.

In the case of a session move some setup until the session
is created.

As the session isn't fully running the default EM_HOST is returned as no
e_machine can be found in a running machine.

This is, however, some marginal progress to cross platform support.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrew Jones <ajones@ventanamicro.com>
Cc: Anubhav Shelat <ashelat@redhat.com>
Cc: Anup Patel <anup@brainfault.org>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Blake Jones <blakejones@google.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quan Zhou <zhouquan@iscas.ac.cn>
Cc: Shimin Guo <shimin.guo@skydio.com>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yunseong Kim <ysk@kzalloc.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-02-03 18:01:27 -03:00

91 lines
1.9 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Arch specific functions for perf kvm stat.
*
* Copyright 2024 Beijing ESWIN Computing Technology Co., Ltd.
*
*/
#include <errno.h>
#include <memory.h>
#include "../evsel.h"
#include "../kvm-stat.h"
#include "riscv_trap_types.h"
#include "debug.h"
define_exit_reasons_table(riscv_exit_reasons, kvm_riscv_trap_class);
static const char * const __kvm_events_tp[] = {
"kvm:kvm_entry",
"kvm:kvm_exit",
NULL,
};
static void event_get_key(struct evsel *evsel,
struct perf_sample *sample,
struct event_key *key)
{
int xlen = 64; // TODO: 32-bit support.
key->info = 0;
key->key = evsel__intval(evsel, sample, kvm_exit_reason(EM_RISCV)) & ~CAUSE_IRQ_FLAG(xlen);
key->exit_reasons = riscv_exit_reasons;
}
static bool event_begin(struct evsel *evsel,
struct perf_sample *sample __maybe_unused,
struct event_key *key __maybe_unused)
{
return evsel__name_is(evsel, kvm_entry_trace(EM_RISCV));
}
static bool event_end(struct evsel *evsel,
struct perf_sample *sample,
struct event_key *key)
{
if (evsel__name_is(evsel, kvm_exit_trace(EM_RISCV))) {
event_get_key(evsel, sample, key);
return true;
}
return false;
}
static const struct kvm_events_ops exit_events = {
.is_begin_event = event_begin,
.is_end_event = event_end,
.decode_key = exit_event_decode_key,
.name = "VM-EXIT"
};
static const struct kvm_reg_events_ops __kvm_reg_events_ops[] = {
{
.name = "vmexit",
.ops = &exit_events,
},
{ NULL, NULL },
};
static const char * const __kvm_skip_events[] = {
NULL,
};
int __cpu_isa_init_riscv(struct perf_kvm_stat *kvm)
{
kvm->exit_reasons_isa = "riscv64";
return 0;
}
const char * const *__kvm_events_tp_riscv(void)
{
return __kvm_events_tp;
}
const struct kvm_reg_events_ops *__kvm_reg_events_ops_riscv(void)
{
return __kvm_reg_events_ops;
}
const char * const *__kvm_skip_events_riscv(void)
{
return __kvm_skip_events;
}