xref: /openbmc/linux/arch/arm64/kvm/trace.h (revision ebd09753)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #if !defined(_TRACE_ARM64_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
3 #define _TRACE_ARM64_KVM_H
4 
5 #include <linux/tracepoint.h>
6 
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM kvm
9 
10 TRACE_EVENT(kvm_wfx_arm64,
11 	TP_PROTO(unsigned long vcpu_pc, bool is_wfe),
12 	TP_ARGS(vcpu_pc, is_wfe),
13 
14 	TP_STRUCT__entry(
15 		__field(unsigned long,	vcpu_pc)
16 		__field(bool,		is_wfe)
17 	),
18 
19 	TP_fast_assign(
20 		__entry->vcpu_pc = vcpu_pc;
21 		__entry->is_wfe  = is_wfe;
22 	),
23 
24 	TP_printk("guest executed wf%c at: 0x%08lx",
25 		  __entry->is_wfe ? 'e' : 'i', __entry->vcpu_pc)
26 );
27 
28 TRACE_EVENT(kvm_hvc_arm64,
29 	TP_PROTO(unsigned long vcpu_pc, unsigned long r0, unsigned long imm),
30 	TP_ARGS(vcpu_pc, r0, imm),
31 
32 	TP_STRUCT__entry(
33 		__field(unsigned long, vcpu_pc)
34 		__field(unsigned long, r0)
35 		__field(unsigned long, imm)
36 	),
37 
38 	TP_fast_assign(
39 		__entry->vcpu_pc = vcpu_pc;
40 		__entry->r0 = r0;
41 		__entry->imm = imm;
42 	),
43 
44 	TP_printk("HVC at 0x%08lx (r0: 0x%08lx, imm: 0x%lx)",
45 		  __entry->vcpu_pc, __entry->r0, __entry->imm)
46 );
47 
48 TRACE_EVENT(kvm_arm_setup_debug,
49 	TP_PROTO(struct kvm_vcpu *vcpu, __u32 guest_debug),
50 	TP_ARGS(vcpu, guest_debug),
51 
52 	TP_STRUCT__entry(
53 		__field(struct kvm_vcpu *, vcpu)
54 		__field(__u32, guest_debug)
55 	),
56 
57 	TP_fast_assign(
58 		__entry->vcpu = vcpu;
59 		__entry->guest_debug = guest_debug;
60 	),
61 
62 	TP_printk("vcpu: %p, flags: 0x%08x", __entry->vcpu, __entry->guest_debug)
63 );
64 
65 TRACE_EVENT(kvm_arm_clear_debug,
66 	TP_PROTO(__u32 guest_debug),
67 	TP_ARGS(guest_debug),
68 
69 	TP_STRUCT__entry(
70 		__field(__u32, guest_debug)
71 	),
72 
73 	TP_fast_assign(
74 		__entry->guest_debug = guest_debug;
75 	),
76 
77 	TP_printk("flags: 0x%08x", __entry->guest_debug)
78 );
79 
80 TRACE_EVENT(kvm_arm_set_dreg32,
81 	TP_PROTO(const char *name, __u32 value),
82 	TP_ARGS(name, value),
83 
84 	TP_STRUCT__entry(
85 		__field(const char *, name)
86 		__field(__u32, value)
87 	),
88 
89 	TP_fast_assign(
90 		__entry->name = name;
91 		__entry->value = value;
92 	),
93 
94 	TP_printk("%s: 0x%08x", __entry->name, __entry->value)
95 );
96 
97 TRACE_DEFINE_SIZEOF(__u64);
98 
99 TRACE_EVENT(kvm_arm_set_regset,
100 	TP_PROTO(const char *type, int len, __u64 *control, __u64 *value),
101 	TP_ARGS(type, len, control, value),
102 	TP_STRUCT__entry(
103 		__field(const char *, name)
104 		__field(int, len)
105 		__array(u64, ctrls, 16)
106 		__array(u64, values, 16)
107 	),
108 	TP_fast_assign(
109 		__entry->name = type;
110 		__entry->len = len;
111 		memcpy(__entry->ctrls, control, len << 3);
112 		memcpy(__entry->values, value, len << 3);
113 	),
114 	TP_printk("%d %s CTRL:%s VALUE:%s", __entry->len, __entry->name,
115 		__print_array(__entry->ctrls, __entry->len, sizeof(__u64)),
116 		__print_array(__entry->values, __entry->len, sizeof(__u64)))
117 );
118 
119 TRACE_EVENT(trap_reg,
120 	TP_PROTO(const char *fn, int reg, bool is_write, u64 write_value),
121 	TP_ARGS(fn, reg, is_write, write_value),
122 
123 	TP_STRUCT__entry(
124 		__field(const char *, fn)
125 		__field(int, reg)
126 		__field(bool, is_write)
127 		__field(u64, write_value)
128 	),
129 
130 	TP_fast_assign(
131 		__entry->fn = fn;
132 		__entry->reg = reg;
133 		__entry->is_write = is_write;
134 		__entry->write_value = write_value;
135 	),
136 
137 	TP_printk("%s %s reg %d (0x%08llx)", __entry->fn,  __entry->is_write?"write to":"read from", __entry->reg, __entry->write_value)
138 );
139 
140 TRACE_EVENT(kvm_handle_sys_reg,
141 	TP_PROTO(unsigned long hsr),
142 	TP_ARGS(hsr),
143 
144 	TP_STRUCT__entry(
145 		__field(unsigned long,	hsr)
146 	),
147 
148 	TP_fast_assign(
149 		__entry->hsr = hsr;
150 	),
151 
152 	TP_printk("HSR 0x%08lx", __entry->hsr)
153 );
154 
155 TRACE_EVENT(kvm_set_guest_debug,
156 	TP_PROTO(struct kvm_vcpu *vcpu, __u32 guest_debug),
157 	TP_ARGS(vcpu, guest_debug),
158 
159 	TP_STRUCT__entry(
160 		__field(struct kvm_vcpu *, vcpu)
161 		__field(__u32, guest_debug)
162 	),
163 
164 	TP_fast_assign(
165 		__entry->vcpu = vcpu;
166 		__entry->guest_debug = guest_debug;
167 	),
168 
169 	TP_printk("vcpu: %p, flags: 0x%08x", __entry->vcpu, __entry->guest_debug)
170 );
171 
172 
173 #endif /* _TRACE_ARM64_KVM_H */
174 
175 #undef TRACE_INCLUDE_PATH
176 #define TRACE_INCLUDE_PATH .
177 #undef TRACE_INCLUDE_FILE
178 #define TRACE_INCLUDE_FILE trace
179 
180 /* This part must be outside protection */
181 #include <trace/define_trace.h>
182