Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm/arm64: KVM: Add exit reaons to kvm_exit event tracing

This patch extends trace_kvm_exit() to include KVM exit reasons
(i.e. EC of HSR). The tracing function then dumps both exit reason
and PC of vCPU, shown as the following. Tracing tools can use this
new exit_reason field to better understand the behavior of guest VMs.

886.301252: kvm_exit: HSR_EC: 0x0024, PC: 0xfffffe0000506b28

Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

authored by

Wei Huang and committed by
Paolo Bonzini
91314cb0 a050dfb2

+8 -4
+1 -1
arch/arm/kvm/arm.c
··· 540 540 541 541 vcpu->mode = OUTSIDE_GUEST_MODE; 542 542 kvm_guest_exit(); 543 - trace_kvm_exit(*vcpu_pc(vcpu)); 543 + trace_kvm_exit(kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu)); 544 544 /* 545 545 * We may have taken a host interrupt in HYP mode (ie 546 546 * while executing the guest). This interrupt is still
+7 -3
arch/arm/kvm/trace.h
··· 25 25 ); 26 26 27 27 TRACE_EVENT(kvm_exit, 28 - TP_PROTO(unsigned long vcpu_pc), 29 - TP_ARGS(vcpu_pc), 28 + TP_PROTO(unsigned int exit_reason, unsigned long vcpu_pc), 29 + TP_ARGS(exit_reason, vcpu_pc), 30 30 31 31 TP_STRUCT__entry( 32 + __field( unsigned int, exit_reason ) 32 33 __field( unsigned long, vcpu_pc ) 33 34 ), 34 35 35 36 TP_fast_assign( 37 + __entry->exit_reason = exit_reason; 36 38 __entry->vcpu_pc = vcpu_pc; 37 39 ), 38 40 39 - TP_printk("PC: 0x%08lx", __entry->vcpu_pc) 41 + TP_printk("HSR_EC: 0x%04x, PC: 0x%08lx", 42 + __entry->exit_reason, 43 + __entry->vcpu_pc) 40 44 ); 41 45 42 46 TRACE_EVENT(kvm_guest_fault,