Skip to content

Commit 71a7e47

Browse files
christofferdall-armMarc Zyngier
authored andcommitted
KVM: arm/arm64: Fixup the kvm_exit tracepoint
The kvm_exit tracepoint strangely always reported exits as being IRQs. This seems to be because either the __print_symbolic or the tracepoint macros use a variable named idx. Take this chance to update the fields in the tracepoint to reflect the concepts in the arm64 architecture that we pass to the tracepoint and move the exception type table to the same location and header files as the exits code. We also clear out the exception code to 0 for IRQ exits (which translates to UNKNOWN in text) to make it slighyly less confusing to parse the trace output. Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent 9009782 commit 71a7e47

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

‎arch/arm64/include/asm/kvm_arm.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@
320320
#define PAR_TO_HPFAR(par) \
321321
(((par) & GENMASK_ULL(PHYS_MASK_SHIFT - 1, 12)) >> 8)
322322

323-
#define kvm_arm_exception_type \
324-
{0, "IRQ" }, \
325-
{1, "TRAP" }
326-
327323
#define ECN(x) { ESR_ELx_EC_##x, #x }
328324

329325
#define kvm_arm_exception_class \

‎arch/arm64/include/asm/kvm_asm.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
/* The hyp-stub will return this for any kvm_call_hyp() call */
3535
#define ARM_EXCEPTION_HYP_GONE HVC_STUB_ERR
3636

37+
#define kvm_arm_exception_type \
38+
{ARM_EXCEPTION_IRQ, "IRQ" }, \
39+
{ARM_EXCEPTION_EL1_SERROR, "SERROR" }, \
40+
{ARM_EXCEPTION_TRAP, "TRAP" }, \
41+
{ARM_EXCEPTION_HYP_GONE, "HYP_GONE" }
42+
3743
#ifndef __ASSEMBLY__
3844

3945
#include <linux/mm.h>

‎virt/kvm/arm/trace.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ TRACE_EVENT(kvm_entry,
2626
);
2727

2828
TRACE_EVENT(kvm_exit,
29-
TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc),
30-
TP_ARGS(idx, exit_reason, vcpu_pc),
29+
TP_PROTO(int ret, unsigned int esr_ec, unsigned long vcpu_pc),
30+
TP_ARGS(ret, esr_ec, vcpu_pc),
3131

3232
TP_STRUCT__entry(
33-
__field( int, idx )
34-
__field( unsigned int, exit_reason )
33+
__field( int, ret )
34+
__field( unsigned int, esr_ec )
3535
__field( unsigned long, vcpu_pc )
3636
),
3737

3838
TP_fast_assign(
39-
__entry->idx = idx;
40-
__entry->exit_reason = exit_reason;
39+
__entry->ret = ARM_EXCEPTION_CODE(ret);
40+
__entry->esr_ec = (ARM_EXCEPTION_CODE(ret) == ARM_EXCEPTION_TRAP) ? esr_ec : 0;
4141
__entry->vcpu_pc = vcpu_pc;
4242
),
4343

4444
TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx",
45-
__print_symbolic(__entry->idx, kvm_arm_exception_type),
46-
__entry->exit_reason,
47-
__print_symbolic(__entry->exit_reason, kvm_arm_exception_class),
45+
__print_symbolic(__entry->ret, kvm_arm_exception_type),
46+
__entry->esr_ec,
47+
__print_symbolic(__entry->esr_ec, kvm_arm_exception_class),
4848
__entry->vcpu_pc)
4949
);
5050

0 commit comments

Comments
 (0)