Commit 0a90fbc8 authored by Vincent Donnefort's avatar Vincent Donnefort Committed by Marc Zyngier
Browse files

KVM: arm64: Add event support to the nVHE/pKVM hyp and trace remote



Allow the creation of hypervisor and trace remote events with a single
macro HYP_EVENT(). That macro expands in the kernel side to add all
the required declarations (based on REMOTE_EVENT()) as well as in the
hypervisor side to create the trace_<event>() function.

Signed-off-by: default avatarVincent Donnefort <vdonnefort@google.com>
Link: https://patch.msgid.link/20260309162516.2623589-28-vdonnefort@google.com


Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 2194d317
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ enum __kvm_host_smccc_func {
	__KVM_HOST_SMCCC_FUNC___tracing_swap_reader,
	__KVM_HOST_SMCCC_FUNC___tracing_update_clock,
	__KVM_HOST_SMCCC_FUNC___tracing_reset,
	__KVM_HOST_SMCCC_FUNC___tracing_enable_event,
};

#define DECLARE_KVM_VHE_SYM(sym)	extern char sym[]
+16 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#define REMOTE_EVENT_INCLUDE_FILE arch/arm64/include/asm/kvm_hypevents.h

#define REMOTE_EVENT_SECTION "_hyp_events"

#define HE_STRUCT(__args)		__args
#define HE_PRINTK(__args...)		__args
#define he_field			re_field

#define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \
	REMOTE_EVENT(__name, 0, RE_STRUCT(__struct), RE_PRINTK(__printk))

#define HYP_EVENT_MULTI_READ
#include <trace/define_remote_events.h>
#undef HYP_EVENT_MULTI_READ
+10 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#if !defined(__ARM64_KVM_HYPEVENTS_H_) || defined(HYP_EVENT_MULTI_READ)
#define __ARM64_KVM_HYPEVENTS_H_

#ifdef __KVM_NVHE_HYPERVISOR__
#include <nvhe/trace.h>
#endif

#endif
+13 −0
Original line number Diff line number Diff line
@@ -10,4 +10,17 @@ struct hyp_trace_desc {
	struct trace_buffer_desc	trace_buffer_desc;

};

struct hyp_event_id {
	unsigned short	id;
	atomic_t	enabled;
};

extern struct remote_event __hyp_events_start[];
extern struct remote_event __hyp_events_end[];

/* hyp_event section used by the hypervisor */
extern struct hyp_event_id __hyp_event_ids_start[];
extern struct hyp_event_id __hyp_event_ids_end[];

#endif
+4 −0
Original line number Diff line number Diff line
@@ -138,6 +138,10 @@ KVM_NVHE_ALIAS(__hyp_data_start);
KVM_NVHE_ALIAS(__hyp_data_end);
KVM_NVHE_ALIAS(__hyp_rodata_start);
KVM_NVHE_ALIAS(__hyp_rodata_end);
#ifdef CONFIG_NVHE_EL2_TRACING
KVM_NVHE_ALIAS(__hyp_event_ids_start);
KVM_NVHE_ALIAS(__hyp_event_ids_end);
#endif

/* pKVM static key */
KVM_NVHE_ALIAS(kvm_protected_mode_initialized);
Loading