1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
6 #if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
9 #include <linux/tracepoint.h>
10 #include <asm/kvm_csr.h>
13 #define TRACE_SYSTEM kvm
16 * Tracepoints for VM enters
18 DECLARE_EVENT_CLASS(kvm_transition
,
19 TP_PROTO(struct kvm_vcpu
*vcpu
),
22 __field(unsigned int, vcpu_id
)
23 __field(unsigned long, pc
)
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
),
38 DEFINE_EVENT(kvm_transition
, kvm_reenter
,
39 TP_PROTO(struct kvm_vcpu
*vcpu
),
42 DEFINE_EVENT(kvm_transition
, kvm_out
,
43 TP_PROTO(struct kvm_vcpu
*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
),
59 __field(unsigned int, vcpu_id
)
60 __field(unsigned long, pc
)
61 __field(unsigned int, reason
)
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",
72 __print_symbolic(__entry
->reason
,
73 kvm_trace_symbol_exit_types
),
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
),
93 __field(unsigned int, vcpu_id
)
94 __field(unsigned int, inst_word
)
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
,
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" }
129 TP_PROTO(struct kvm_vcpu
*vcpu
, unsigned int op
,
131 TP_ARGS(vcpu
, op
, state
),
133 __field(unsigned long, pc
)
139 __entry
->pc
= vcpu
->arch
.pc
;
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
),
152 TRACE_EVENT(kvm_vpid_change
,
153 TP_PROTO(struct kvm_vcpu
*vcpu
, unsigned long vpid
),
156 __field(unsigned long, vpid
)
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>