@@ -14,7 +14,7 @@ kvm-y += arm.o mmu.o mmio.o psci.o hypercalls.o pvtime.o \
inject_fault.o va_layout.o handle_exit.o \
guest.o debug.o reset.o sys_regs.o stacktrace.o \
vgic-sys-reg-v3.o fpsimd.o pkvm.o \
- arch_timer.o trng.o vmid.o \
+ arch_timer.o trng.o vmid.o trace.o \
vgic/vgic.o vgic/vgic-init.o \
vgic/vgic-irqfd.o vgic/vgic-v2.o \
vgic/vgic-v3.o vgic/vgic-v4.o \
@@ -917,7 +917,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
/**************************************************************
* Enter the guest
*/
- trace_kvm_entry(*vcpu_pc(vcpu));
+ trace_kvm_entry_tp(vcpu);
guest_timing_enter_irqoff();
ret = kvm_arm_vcpu_enter_exit(vcpu);
@@ -974,7 +974,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
local_irq_enable();
- trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
+ trace_kvm_exit_tp(ret, vcpu);
/* Exit types that need handling before we can be preempted */
handle_exit_early(vcpu, ret);
new file mode 100644
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/init.h>
+#include <linux/tracepoint.h>
+
+#include <asm/kvm_emulate.h>
+
+#include "trace_arm.h"
+
+static void kvm_entry_tp(void *data, struct kvm_vcpu *vcpu)
+{
+ if (trace_kvm_entry_enabled())
+ trace_kvm_entry(*vcpu_pc(vcpu));
+}
+
+static void kvm_exit_tp(void *data, int ret, struct kvm_vcpu *vcpu)
+{
+ if (trace_kvm_exit_enabled())
+ trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu),
+ *vcpu_pc(vcpu));
+}
+
+static int __init kvm_tp_init(void)
+{
+ register_trace_kvm_entry_tp(kvm_entry_tp, NULL);
+ register_trace_kvm_exit_tp(kvm_exit_tp, NULL);
+ return 0;
+}
+
+core_initcall(kvm_tp_init)
@@ -11,6 +11,10 @@
/*
* Tracepoints for entry/exit to guest
*/
+DECLARE_TRACE(kvm_entry_tp,
+ TP_PROTO(struct kvm_vcpu *vcpu),
+ TP_ARGS(vcpu));
+
TRACE_EVENT(kvm_entry,
TP_PROTO(unsigned long vcpu_pc),
TP_ARGS(vcpu_pc),
@@ -26,6 +30,10 @@ TRACE_EVENT(kvm_entry,
TP_printk("PC: 0x%016lx", __entry->vcpu_pc)
);
+DECLARE_TRACE(kvm_exit_tp,
+ TP_PROTO(int ret, struct kvm_vcpu *vcpu),
+ TP_ARGS(ret, vcpu));
+
TRACE_EVENT(kvm_exit,
TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc),
TP_ARGS(ret, esr_ec, vcpu_pc),
This commit doesn't change any functionality but only refactoring. It registers callbacks for tracepoints dynamically, with this way, the existed trace events (in this case kvm_entry and kvm_exit) are kept. This is a preparation to add new trace events in later patch. Signed-off-by: Leo Yan <leo.yan@linaro.org> --- arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 4 ++-- arch/arm64/kvm/trace.c | 29 +++++++++++++++++++++++++++++ arch/arm64/kvm/trace_arm.h | 8 ++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 arch/arm64/kvm/trace.c