Merge tag 'rproc-v6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc...
[linux.git] / arch / loongarch / kvm / trace.h
blob1783397b1bc88e852b5b424549e00acc1cce0ff8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
4 */
6 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define _TRACE_KVM_H
9 #include <linux/tracepoint.h>
10 #include <asm/kvm_csr.h>
12 #undef TRACE_SYSTEM
13 #define TRACE_SYSTEM kvm
16 * Tracepoints for VM enters
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)
26 TP_fast_assign(
27 __entry->vcpu_id = vcpu->vcpu_id;
28 __entry->pc = vcpu->arch.pc;
31 TP_printk("vcpu %u PC: 0x%08lx", __entry->vcpu_id, __entry->pc)
34 DEFINE_EVENT(kvm_transition, kvm_enter,
35 TP_PROTO(struct kvm_vcpu *vcpu),
36 TP_ARGS(vcpu));
38 DEFINE_EVENT(kvm_transition, kvm_reenter,
39 TP_PROTO(struct kvm_vcpu *vcpu),
40 TP_ARGS(vcpu));
42 DEFINE_EVENT(kvm_transition, kvm_out,
43 TP_PROTO(struct kvm_vcpu *vcpu),
44 TP_ARGS(vcpu));
46 /* Further exit reasons */
47 #define KVM_TRACE_EXIT_IDLE 64
48 #define KVM_TRACE_EXIT_CACHE 65
50 /* Tracepoints for VM exits */
51 #define kvm_trace_symbol_exit_types \
52 { KVM_TRACE_EXIT_IDLE, "IDLE" }, \
53 { KVM_TRACE_EXIT_CACHE, "CACHE" }
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)
64 TP_fast_assign(
65 __entry->vcpu_id = vcpu->vcpu_id;
66 __entry->pc = vcpu->arch.pc;
67 __entry->reason = reason;
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)
77 DEFINE_EVENT(kvm_exit, kvm_exit_idle,
78 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
79 TP_ARGS(vcpu, reason));
81 DEFINE_EVENT(kvm_exit, kvm_exit_cache,
82 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
83 TP_ARGS(vcpu, reason));
85 DEFINE_EVENT(kvm_exit, kvm_exit,
86 TP_PROTO(struct kvm_vcpu *vcpu, unsigned int reason),
87 TP_ARGS(vcpu, reason));
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)
97 TP_fast_assign(
98 __entry->vcpu_id = vcpu->vcpu_id;
99 __entry->inst_word = inst_word;
102 TP_printk("vcpu %u Inst word: 0x%08x", __entry->vcpu_id,
103 __entry->inst_word)
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
112 #define KVM_TRACE_AUX_FPU 1
113 #define KVM_TRACE_AUX_LSX 2
114 #define KVM_TRACE_AUX_LASX 3
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" }
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" }
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)
138 TP_fast_assign(
139 __entry->pc = vcpu->arch.pc;
140 __entry->op = op;
141 __entry->state = state;
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)
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)
159 TP_fast_assign(
160 __entry->vpid = vpid;
163 TP_printk("VPID: 0x%08lx", __entry->vpid)
166 #endif /* _TRACE_KVM_H */
168 #undef TRACE_INCLUDE_PATH
169 #define TRACE_INCLUDE_PATH ../../arch/loongarch/kvm
170 #undef TRACE_INCLUDE_FILE
171 #define TRACE_INCLUDE_FILE trace
173 /* This part must be outside protection */
174 #include <trace/define_trace.h>