ANDROID: misc: pkvm_smc: Trace denied SMCs.

Add a trace for denied SMCs, that is useful for debugging.

Bug: 278009271
Bug: 357781595
Change-Id: I139e8a238cbb352a02a2113df90b578a2ea140a3
Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
Mostafa Saleh
2024-04-10 13:00:11 +00:00
committed by Treehugger Robot
parent 20d9754be1
commit 4034e5e8f0
3 changed files with 49 additions and 0 deletions
+3
View File
@@ -9,6 +9,9 @@
#include <linux/kernel.h>
#include <asm/kvm_pkvm_module.h>
#define HYP_EVENT_FILE ../../../../drivers/misc/pkvm-smc/pkvm/events.h
#include <asm/kvm_define_hypevents.h>
static unsigned long pkvm_module_token;
int kvm_nvhe_sym(pkvm_smc_filter_hyp_init)(const struct pkvm_module_ops *ops);
+19
View File
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0 */
#if !defined(__PKVM_SMC_FILTER_HYPEVENTS_H_) || defined(HYP_EVENT_MULTI_READ)
#define __PKVM_SMC_FILTER_HYPEVENTS_H_
#ifdef __KVM_NVHE_HYPERVISOR__
#include <trace.h>
#endif
HYP_EVENT(filtered_smc,
HE_PROTO(u64 smc_id),
HE_STRUCT(
he_field(u64, smc_id)
),
HE_ASSIGN(
__entry->smc_id = smc_id;
),
HE_PRINTK("smc_id = 0x%08llx", __entry->smc_id)
);
#endif
+27
View File
@@ -9,6 +9,27 @@
#include <linux/arm-smccc.h>
#include <linux/bsearch.h>
#include "events.h"
#define HYP_EVENT_FILE ../../../../drivers/misc/pkvm-smc/pkvm/events.h
#include <define_events.h>
const struct pkvm_module_ops *pkvm_ops;
#ifdef CONFIG_TRACING
extern char __hyp_event_ids_start[];
extern char __hyp_event_ids_end[];
void *tracing_reserve_entry(unsigned long length)
{
return pkvm_ops->tracing_reserve_entry(length);
}
void tracing_commit_entry(void)
{
pkvm_ops->tracing_commit_entry();
}
#endif
struct pkvm_smc_filter {
u64 smc_id;
bool (*cb)(struct user_pt_regs *regs); /* Forward unconditionally if NULL. */
@@ -16,6 +37,7 @@ struct pkvm_smc_filter {
static bool deny_smc(struct user_pt_regs *regs)
{
trace_filtered_smc(regs->regs[0]);
regs->regs[0] = SMCCC_RET_NOT_SUPPORTED;
return true;
}
@@ -107,5 +129,10 @@ bool filter_smc(struct user_pt_regs *regs)
int pkvm_smc_filter_hyp_init(const struct pkvm_module_ops *ops)
{
#ifdef CONFIG_TRACING
ops->register_hyp_event_ids((unsigned long)__hyp_event_ids_start,
(unsigned long)__hyp_event_ids_end);
#endif
pkvm_ops = ops;
return ops->register_host_smc_handler(filter_smc);
}