1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2020-2023 Loongson Technology Corporation Limited 4 */ 5 6 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) 7 #define _TRACE_KVM_H 8 9 #include <linux/tracepoint.h> 10 #include <asm/kvm_csr.h> 11 12 #undef TRACE_SYSTEM 13 #define TRACE_SYSTEM kvm 14 15 /* 16 * Tracepoints for VM enters 17 */ 18 DECLARE_EVENT_CLASS(kvm_transition, 19 TP_PROTO(struct kvm_vcpu *vcpu), 20 TP_ARGS(vcpu), 21 TP_STRUCT__entry( 22 __field(unsigned int, vcpu_id) 23 __field(unsigned long, pc) 24 ), 25 26 TP_fast_assign( 27 __entry->vcpu_id = vcpu->vcpu_id; 28 __entry->pc = vcpu->arch.pc; 29 ), 30 31 TP_printk("vcpu %u PC: 0x%08lx", __entry->vcpu_id, __entry->pc) 32 ); 33 34 DEFINE_EVENT(kvm_transition, kvm_enter, 35 TP_PROTO(struct kvm_vcpu *vcpu), 36 TP_ARGS(vcpu)); 37 38 DEFINE_EVENT(kvm_transition, kvm_reenter, 39 TP_PROTO(struct kvm_vcpu *vcpu), 40 TP_ARGS(vcpu)); 41 42 DEFINE_EVENT(kvm_transition, kvm_out, 43 TP_PROTO(struct kvm_vcpu *vcpu), 44 TP_ARGS(vcpu)); 45 46 /* Further exit reasons */ 47 #define KVM_TRACE_EXIT_IDLE 64 48 #define KVM_TRACE_EXIT_CACHE 65 49 50 /* Tracepoints for VM exits */ 51 #define kvm_trace_symbol_exit_types \ 52 { KVM_TRACE_EXIT_IDLE, "IDLE" }, \ 53 { KVM_TRACE_EXIT_CACHE, "CACHE" } 54 55 DECLARE_EVENT_CLASS(kvm_exit, 56 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), 57 TP_ARGS(vcpu, reason), 58 TP_STRUCT__entry( 59 __field(unsigned int, vcpu_id) 60 __field(unsigned long, pc) 61 __field(unsigned int, reason) 62 ), 63 64 TP_fast_assign( 65 __entry->vcpu_id = vcpu->vcpu_id; 66 __entry->pc = vcpu->arch.pc; 67 __entry->reason = reason; 68 ), 69 70 TP_printk("vcpu %u [%s] PC: 0x%08lx", 71 __entry->vcpu_id, 72 __print_symbolic(__entry->reason, 73 kvm_trace_symbol_exit_types), 74 __entry->pc) 75 ); 76 77 DEFINE_EVENT(kvm_exit, kvm_exit_idle, 78 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), 79 TP_ARGS(vcpu, reason)); 80 81 DEFINE_EVENT(kvm_exit, kvm_exit_cache, 82 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), 83 TP_ARGS(vcpu, reason)); 84 85 DEFINE_EVENT(kvm_exit, kvm_exit, 86 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason), 87 TP_ARGS(vcpu, reason)); 88 89 TRACE_EVENT(kvm_exit_gspr, 90 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int inst_word), 91 TP_ARGS(vcpu, inst_word), 92 TP_STRUCT__entry( 93 __field(unsigned int, vcpu_id) 94 __field(unsigned int, inst_word) 95 ), 96 97 TP_fast_assign( 98 __entry->vcpu_id = vcpu->vcpu_id; 99 __entry->inst_word = inst_word; 100 ), 101 102 TP_printk("vcpu %u Inst word: 0x%08x", __entry->vcpu_id, 103 __entry->inst_word) 104 ); 105 106 #define KVM_TRACE_AUX_SAVE 0 107 #define KVM_TRACE_AUX_RESTORE 1 108 #define KVM_TRACE_AUX_ENABLE 2 109 #define KVM_TRACE_AUX_DISABLE 3 110 #define KVM_TRACE_AUX_DISCARD 4 111 112 #define KVM_TRACE_AUX_FPU 1 113 #define KVM_TRACE_AUX_LSX 2 114 #define KVM_TRACE_AUX_LASX 3 115 116 #define kvm_trace_symbol_aux_op \ 117 { KVM_TRACE_AUX_SAVE, "save" }, \ 118 { KVM_TRACE_AUX_RESTORE, "restore" }, \ 119 { KVM_TRACE_AUX_ENABLE, "enable" }, \ 120 { KVM_TRACE_AUX_DISABLE, "disable" }, \ 121 { KVM_TRACE_AUX_DISCARD, "discard" } 122 123 #define kvm_trace_symbol_aux_state \ 124 { KVM_TRACE_AUX_FPU, "FPU" }, \ 125 { KVM_TRACE_AUX_LSX, "LSX" }, \ 126 { KVM_TRACE_AUX_LASX, "LASX" } 127 128 TRACE_EVENT(kvm_aux, 129 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int op, 130 unsigned int state), 131 TP_ARGS(vcpu, op, state), 132 TP_STRUCT__entry( 133 __field(unsigned long, pc) 134 __field(u8, op) 135 __field(u8, state) 136 ), 137 138 TP_fast_assign( 139 __entry->pc = vcpu->arch.pc; 140 __entry->op = op; 141 __entry->state = state; 142 ), 143 144 TP_printk("%s %s PC: 0x%08lx", 145 __print_symbolic(__entry->op, 146 kvm_trace_symbol_aux_op), 147 __print_symbolic(__entry->state, 148 kvm_trace_symbol_aux_state), 149 __entry->pc) 150 ); 151 152 TRACE_EVENT(kvm_vpid_change, 153 TP_PROTO(struct kvm_vcpu *vcpu, unsigned long vpid), 154 TP_ARGS(vcpu, vpid), 155 TP_STRUCT__entry( 156 __field(unsigned long, vpid) 157 ), 158 159 TP_fast_assign( 160 __entry->vpid = vpid; 161 ), 162 163 TP_printk("VPID: 0x%08lx", __entry->vpid) 164 ); 165 166 #endif /* _TRACE_KVM_H */ 167 168 #undef TRACE_INCLUDE_PATH 169 #define TRACE_INCLUDE_PATH ../../arch/loongarch/kvm 170 #undef TRACE_INCLUDE_FILE 171 #define TRACE_INCLUDE_FILE trace 172 173 /* This part must be outside protection */ 174 #include <trace/define_trace.h> 175
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.