arm64: KVM: Add trapped system register access tracepoint
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 4 Dec 2018 10:44:22 +0000 (10:44 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Wed, 19 Dec 2018 17:47:08 +0000 (17:47 +0000)
We're pretty blind when it comes to system register tracing,
and rely on the ESR value displayed by kvm_handle_sys, which
isn't much.

Instead, let's add an actual name to the sysreg entries, so that
we can finally print it as we're about to perform the access
itself.

The new tracepoint is conveniently called kvm_sys_access.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/kvm/sys_regs.c
arch/arm64/kvm/sys_regs.h
arch/arm64/kvm/trace.h

index 965c6f1706d64488bbb91eba444fbe9ce06780fc..a1f57fcb1bdb2927e0c35aa190e66cfcccb0ef4e 100644 (file)
@@ -1850,6 +1850,8 @@ static void perform_access(struct kvm_vcpu *vcpu,
                           struct sys_reg_params *params,
                           const struct sys_reg_desc *r)
 {
+       trace_kvm_sys_access(*vcpu_pc(vcpu), params, r);
+
        /*
         * Not having an accessor means that we have configured a trap
         * that we don't know how to handle. This certainly qualifies
index cd710f8b63e0f9a33c8a39819428ae07fcf22eeb..3b1bc7f01d0bd284314308898f7aa1448f5e0436 100644 (file)
@@ -35,6 +35,9 @@ struct sys_reg_params {
 };
 
 struct sys_reg_desc {
+       /* Sysreg string for debug */
+       const char *name;
+
        /* MRS/MSR instruction which accesses it. */
        u8      Op0;
        u8      Op1;
@@ -130,6 +133,7 @@ const struct sys_reg_desc *find_reg_by_id(u64 id,
 #define Op2(_x)        .Op2 = _x
 
 #define SYS_DESC(reg)                                  \
+       .name = #reg,                                   \
        Op0(sys_reg_Op0(reg)), Op1(sys_reg_Op1(reg)),   \
        CRn(sys_reg_CRn(reg)), CRm(sys_reg_CRm(reg)),   \
        Op2(sys_reg_Op2(reg))
index 3b82fb1ddd097783ef66d6ac0f0ab334b3ab6bb2..eab91ad0effbe3784f23a4ae307773dca2ae65df 100644 (file)
@@ -3,6 +3,7 @@
 #define _TRACE_ARM64_KVM_H
 
 #include <linux/tracepoint.h>
+#include "sys_regs.h"
 
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM kvm
@@ -152,6 +153,40 @@ TRACE_EVENT(kvm_handle_sys_reg,
        TP_printk("HSR 0x%08lx", __entry->hsr)
 );
 
+TRACE_EVENT(kvm_sys_access,
+       TP_PROTO(unsigned long vcpu_pc, struct sys_reg_params *params, const struct sys_reg_desc *reg),
+       TP_ARGS(vcpu_pc, params, reg),
+
+       TP_STRUCT__entry(
+               __field(unsigned long,                  vcpu_pc)
+               __field(bool,                           is_write)
+               __field(const char *,                   name)
+               __field(u8,                             Op0)
+               __field(u8,                             Op1)
+               __field(u8,                             CRn)
+               __field(u8,                             CRm)
+               __field(u8,                             Op2)
+       ),
+
+       TP_fast_assign(
+               __entry->vcpu_pc = vcpu_pc;
+               __entry->is_write = params->is_write;
+               __entry->name = reg->name;
+               __entry->Op0 = reg->Op0;
+               __entry->Op0 = reg->Op0;
+               __entry->Op1 = reg->Op1;
+               __entry->CRn = reg->CRn;
+               __entry->CRm = reg->CRm;
+               __entry->Op2 = reg->Op2;
+       ),
+
+       TP_printk("PC: %lx %s (%d,%d,%d,%d,%d) %s",
+                 __entry->vcpu_pc, __entry->name ?: "UNKN",
+                 __entry->Op0, __entry->Op1, __entry->CRn,
+                 __entry->CRm, __entry->Op2,
+                 __entry->is_write ? "write" : "read")
+);
+
 TRACE_EVENT(kvm_set_guest_debug,
        TP_PROTO(struct kvm_vcpu *vcpu, __u32 guest_debug),
        TP_ARGS(vcpu, guest_debug),