summaryrefslogtreecommitdiff
path: root/smcinvoke/trace_smcinvoke.h
blob: 97a66069c900f3dcc845ac65c18fb1392ccdc33a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2021, The Linux Foundation. All rights reserved.
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM smcinvoke

#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace_smcinvoke

#if !defined(_TRACE_SMCINVOKE) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SMCINVOKE_H
#include <linux/types.h>
#include <linux/tracepoint.h>
#include "smcinvoke.h"

TRACE_EVENT(put_pending_cbobj_locked,
	TP_PROTO(uint16_t srvr_id, uint16_t obj_id),
	TP_ARGS(srvr_id, obj_id),
	TP_STRUCT__entry(
		__field(uint16_t,	srvr_id)
		__field(uint16_t,	obj_id)
	),
	TP_fast_assign(
		__entry->srvr_id	= srvr_id;
		__entry->obj_id		= obj_id;
	),
	TP_printk("srvr_id=0x%x obj_id=0x%x",
			__entry->srvr_id, __entry->obj_id)
);

TRACE_EVENT(release_mem_obj_locked,
	TP_PROTO(uint32_t tzhandle, size_t buf_len),
	TP_ARGS(tzhandle, buf_len),
	TP_STRUCT__entry(
		__field(uint32_t,	tzhandle)
		__field(size_t,		buf_len)
	),
	TP_fast_assign(
		__entry->tzhandle	= tzhandle;
		__entry->buf_len	= buf_len;
	),
	TP_printk("tzhandle=0x%08x, buf_len=%zu",
			__entry->tzhandle, __entry->buf_len)
);

TRACE_EVENT(invoke_cmd_handler,
	TP_PROTO(int cmd, uint64_t response_type, int32_t result, int ret),
	TP_ARGS(cmd, response_type, result, ret),
	TP_STRUCT__entry(
		__field(int,		cmd)
		__field(uint64_t,	response_type)
		__field(int32_t,	result)
		__field(int,		ret)
	),
	TP_fast_assign(
		__entry->response_type	= response_type;
		__entry->result		= result;
		__entry->ret		= ret;
		__entry->cmd		= cmd;
	),
	TP_printk("cmd=0x%x (%d), response_type=%ld, result=0x%x (%d), ret=%d",
			__entry->cmd, __entry->cmd, __entry->response_type,
			__entry->result, __entry->result, __entry->ret)
);

TRACE_EVENT(process_tzcb_req_handle,
	TP_PROTO(uint32_t tzhandle, uint32_t op, uint32_t counts),
	TP_ARGS(tzhandle, op, counts),
	TP_STRUCT__entry(
		__field(uint32_t,	tzhandle)
		__field(uint32_t,	op)
		__field(uint32_t,	counts)
	),
	TP_fast_assign(
		__entry->tzhandle	= tzhandle;
		__entry->op		= op;
		__entry->counts		= counts;
	),
	TP_printk("tzhandle=0x%08x op=0x%02x counts=0x%04x",
			__entry->tzhandle, __entry->op, __entry->counts)
);

TRACE_EVENT(process_tzcb_req_wait,
	TP_PROTO(uint32_t tzhandle, int cbobj_retries, uint32_t txn_id, pid_t pid, pid_t tgid,
			uint16_t server_state, uint16_t server_id, unsigned int cb_reqs_inflight),
	TP_ARGS(tzhandle, cbobj_retries, txn_id, pid, tgid, server_state, server_id,
			cb_reqs_inflight),
	TP_STRUCT__entry(
		__field(uint32_t,	tzhandle)
		__field(int,		cbobj_retries)
		__field(uint32_t,	txn_id)
		__field(pid_t,		pid)
		__field(pid_t,		tgid)
		__field(uint16_t,	server_state)
		__field(uint16_t,	server_id)
		__field(unsigned int,	cb_reqs_inflight)
	),
	TP_fast_assign(
		__entry->tzhandle		= tzhandle;
		__entry->cbobj_retries		= cbobj_retries;
		__entry->txn_id			= txn_id;
		__entry->pid			= pid;
		__entry->tgid			= tgid;
		__entry->server_state		= server_state;
		__entry->server_id		= server_id;
		__entry->cb_reqs_inflight	= cb_reqs_inflight;
	),
	TP_printk("tzhandle=0x%08x, retries=%d, txn_id=%d, pid %x,tid %x, srvr state=%d, server_id=0x%x, cb_reqs_inflight=%d",
			__entry->tzhandle, __entry->cbobj_retries, __entry->txn_id,
			__entry->pid, __entry->tgid, __entry->server_state,
			__entry->server_id, __entry->cb_reqs_inflight)
);

TRACE_EVENT(process_tzcb_req_result,
	TP_PROTO(int32_t result, uint32_t tzhandle, uint32_t op, uint32_t counts,
			unsigned int cb_reqs_inflight),
	TP_ARGS(result, tzhandle, op, counts, cb_reqs_inflight),
	TP_STRUCT__entry(
		__field(int32_t,	result)
		__field(uint32_t,	tzhandle)
		__field(uint32_t,	op)
		__field(uint32_t,	counts)
		__field(unsigned int,	cb_reqs_inflight)
	),
	TP_fast_assign(
		__entry->result			= result;
		__entry->tzhandle		= tzhandle;
		__entry->op			= op;
		__entry->counts			= counts;
		__entry->cb_reqs_inflight	= cb_reqs_inflight;
	),
	TP_printk("result=%d tzhandle=0x%08x op=0x%02x counts=0x%04x, cb_reqs_inflight=%d",
			__entry->result, __entry->tzhandle, __entry->op, __entry->counts,
			__entry->cb_reqs_inflight)
);

TRACE_EVENT(marshal_out_invoke_req,
	TP_PROTO(int i, uint32_t tzhandle, uint16_t server, uint32_t fd),
	TP_ARGS(i, tzhandle, server, fd),
	TP_STRUCT__entry(
		__field(int,		i)
		__field(uint32_t,	tzhandle)
		__field(uint16_t,	server)
		__field(uint32_t,	fd)
	),
	TP_fast_assign(
		__entry->i		= i;
		__entry->tzhandle	= tzhandle;
		__entry->server		= server;
		__entry->fd		= fd;
	),
	TP_printk("OO[%d]: tzhandle=0x%x server=0x%x fd=0x%x",
			__entry->i, __entry->tzhandle, __entry->server, __entry->fd)
);

TRACE_EVENT(prepare_send_scm_msg,
	TP_PROTO(uint64_t response_type, int32_t result),
	TP_ARGS(response_type, result),
	TP_STRUCT__entry(
		__field(uint64_t,	response_type)
		__field(int32_t,	result)
	),
	TP_fast_assign(
		__entry->response_type	= response_type;
		__entry->result		= result;
	),
	TP_printk("response_type=0x%lx (%ld), result=0x%x (%d)",
			__entry->response_type, __entry->response_type,
			__entry->result, __entry->result)
);

TRACE_EVENT(marshal_in_invoke_req,
	TP_PROTO(int i, int64_t fd, int32_t cb_server_fd, uint32_t tzhandle),
	TP_ARGS(i, fd, cb_server_fd, tzhandle),
	TP_STRUCT__entry(
		__field(int,		i)
		__field(int64_t,	fd)
		__field(int32_t,	cb_server_fd)
		__field(uint32_t,	tzhandle)
	),
	TP_fast_assign(
		__entry->i		= i;
		__entry->fd		= fd;
		__entry->cb_server_fd	= cb_server_fd;
		__entry->tzhandle	= tzhandle;
	),
	TP_printk("OI[%d]: fd=0x%x cb_server_fd=0x%x tzhandle=0x%x",
			__entry->i, __entry->fd, __entry->cb_server_fd, __entry->tzhandle)
);

TRACE_EVENT(marshal_in_tzcb_req_handle,
	TP_PROTO(uint32_t tzhandle, int srvr_id, int32_t cbobj_id, uint32_t op, uint32_t counts),
	TP_ARGS(tzhandle, srvr_id, cbobj_id, op, counts),
	TP_STRUCT__entry(
		__field(uint32_t,	tzhandle)
		__field(int,		srvr_id)
		__field(int32_t,	cbobj_id)
		__field(uint32_t,	op)
		__field(uint32_t,	counts)
	),
	TP_fast_assign(
		__entry->tzhandle	= tzhandle;
		__entry->srvr_id	= srvr_id;
		__entry->cbobj_id	= cbobj_id;
		__entry->op		= op;
		__entry->counts		= counts;
	),
	TP_printk("tzhandle=0x%x srvr_id=0x%x cbobj_id=0x%08x op=0x%02x counts=0x%04x",
			__entry->tzhandle, __entry->srvr_id, __entry->cbobj_id,
			__entry->op, __entry->counts)
);

TRACE_EVENT(marshal_in_tzcb_req_fd,
	TP_PROTO(int i, uint32_t tzhandle, int srvr_id, int32_t fd),
	TP_ARGS(i, tzhandle, srvr_id, fd),
	TP_STRUCT__entry(
		__field(int,		i)
		__field(uint32_t,	tzhandle)
		__field(int,		srvr_id)
		__field(int32_t,	fd)
	),
	TP_fast_assign(
		__entry->i		= i;
		__entry->tzhandle	= tzhandle;
		__entry->srvr_id	= srvr_id;
		__entry->fd		= fd;
	),
	TP_printk("OI[%d]: tzhandle=0x%x srvr_id=0x%x fd=0x%x",
			__entry->i, __entry->tzhandle, __entry->srvr_id, __entry->fd)
);

TRACE_EVENT(marshal_out_tzcb_req,
	TP_PROTO(uint32_t i, int32_t fd, int32_t cb_server_fd, uint32_t tzhandle),
	TP_ARGS(i, fd, cb_server_fd, tzhandle),
	TP_STRUCT__entry(
		__field(int,		i)
		__field(int32_t,	fd)
		__field(int32_t,	cb_server_fd)
		__field(uint32_t,	tzhandle)
	),
	TP_fast_assign(
		__entry->i		= i;
		__entry->fd		= fd;
		__entry->cb_server_fd	= cb_server_fd;
		__entry->tzhandle	= tzhandle;
	),
	TP_printk("OO[%d]: fd=0x%x cb_server_fd=0x%x tzhandle=0x%x",
			__entry->i, __entry->fd, __entry->cb_server_fd, __entry->tzhandle)
);

TRACE_EVENT(process_invoke_req_tzhandle,
	TP_PROTO(uint32_t tzhandle, uint32_t op, uint32_t counts),
	TP_ARGS(tzhandle, op, counts),
	TP_STRUCT__entry(
		__field(uint32_t, tzhandle)
		__field(uint32_t, op)
		__field(uint32_t, counts)
	),
	TP_fast_assign(
		__entry->tzhandle	= tzhandle;
		__entry->op		= op;
		__entry->counts		= counts;
	),
	TP_printk("tzhandle=0x%08x op=0x%02x counts=0x%04x",
			__entry->tzhandle, __entry->op, __entry->counts)
);

TRACE_EVENT(process_invoke_req_result,
	TP_PROTO(int ret, int32_t result, uint32_t tzhandle, uint32_t op, uint32_t counts),
	TP_ARGS(ret, result, tzhandle, op, counts),
	TP_STRUCT__entry(
		__field(int,		ret)
		__field(int32_t,	result)
		__field(uint32_t,	tzhandle)
		__field(uint32_t,	op)
		__field(uint32_t,	counts)
	),
	TP_fast_assign(
		__entry->ret		= ret;
		__entry->result		= result;
		__entry->tzhandle	= tzhandle;
		__entry->op		= op;
		__entry->counts		= counts;
	),
	TP_printk("ret=%d result=%d tzhandle=0x%08x op=0x%02x counts=0x%04x",
			__entry->ret, __entry->result, __entry->tzhandle,
			__entry->op, __entry->counts)
);

TRACE_EVENT(process_log_info,
	TP_PROTO(char *buf, uint32_t context_type, uint32_t tzhandle),
	TP_ARGS(buf, context_type, tzhandle),
	TP_STRUCT__entry(
		__string(str,		buf)
		__field(uint32_t,	context_type)
		__field(uint32_t,	tzhandle)
	),
	TP_fast_assign(
		__assign_str(str, buf);
		__entry->context_type	= context_type;
		__entry->tzhandle	= tzhandle;
	),
	TP_printk("%s context_type=%d tzhandle=0x%08x",
			__get_str(str),
			__entry->context_type, __entry->tzhandle)
);

TRACE_EVENT_CONDITION(smcinvoke_ioctl,
	TP_PROTO(unsigned int cmd, long ret),
	TP_ARGS(cmd, ret),
	TP_CONDITION(ret),
	TP_STRUCT__entry(
		__field(unsigned int,	cmd)
		__field(long,		ret)
	),
	TP_fast_assign(
		__entry->cmd = cmd;
		__entry->ret = ret;
	),
	TP_printk("cmd=%s ret=%ld",
			__print_symbolic(__entry->cmd,
				{SMCINVOKE_IOCTL_INVOKE_REQ,	"SMCINVOKE_IOCTL_INVOKE_REQ"},
				{SMCINVOKE_IOCTL_ACCEPT_REQ,	"SMCINVOKE_IOCTL_ACCEPT_REQ"},
				{SMCINVOKE_IOCTL_SERVER_REQ,	"SMCINVOKE_IOCTL_SERVER_REQ"},
				{SMCINVOKE_IOCTL_ACK_LOCAL_OBJ,	"SMCINVOKE_IOCTL_ACK_LOCAL_OBJ"},
				{SMCINVOKE_IOCTL_LOG,		"SMCINVOKE_IOCTL_LOG"}
			), __entry->ret)
);

TRACE_EVENT(smcinvoke_create_bridge,
	TP_PROTO(uint64_t shmbridge_handle, uint16_t mem_region_id),
	TP_ARGS(shmbridge_handle, mem_region_id),
	TP_STRUCT__entry(
		__field(uint64_t,	shmbridge_handle)
		__field(uint16_t,	mem_region_id)
	),
	TP_fast_assign(
		__entry->shmbridge_handle	= shmbridge_handle;
		__entry->mem_region_id		= mem_region_id;
	),
	TP_printk("created shm bridge handle %llu for mem_region_id %u",
			__entry->shmbridge_handle, __entry->mem_region_id)
);

TRACE_EVENT(status,
	TP_PROTO(const char *func, const char *status),
	TP_ARGS(func, status),
	TP_STRUCT__entry(
		__string(str,	func)
		__string(str2,	status)
	),
	TP_fast_assign(
		__assign_str(str,	func);
		__assign_str(str2,	status);
	),
	TP_printk("%s status=%s", __get_str(str), __get_str(str2))
);

TRACE_EVENT(process_accept_req_has_response,
	TP_PROTO(pid_t pid, pid_t tgid),
	TP_ARGS(pid, tgid),
	TP_STRUCT__entry(
		__field(pid_t,	pid)
		__field(pid_t,	tgid)
	),
	TP_fast_assign(
		__entry->pid	= pid;
		__entry->tgid	= tgid;
	),
	TP_printk("pid=0x%x, tgid=0x%x", __entry->pid, __entry->tgid)
);

TRACE_EVENT(process_accept_req_ret,
	TP_PROTO(pid_t pid, pid_t tgid, int ret),
	TP_ARGS(pid, tgid, ret),
	TP_STRUCT__entry(
		__field(pid_t,	pid)
		__field(pid_t,	tgid)
		__field(int,	ret)
	),
	TP_fast_assign(
		__entry->pid	= pid;
		__entry->tgid	= tgid;
		__entry->ret	= ret;
	),
	TP_printk("pid=0x%x tgid=0x%x ret=%d", __entry->pid, __entry->tgid, __entry->ret)
);

TRACE_EVENT(process_accept_req_placed,
	TP_PROTO(pid_t pid, pid_t tgid),
	TP_ARGS(pid, tgid),
	TP_STRUCT__entry(
		__field(pid_t,	pid)
		__field(pid_t,	tgid)
	),
	TP_fast_assign(
		__entry->pid	= pid;
		__entry->tgid	= tgid;
	),
	TP_printk("pid=0x%x, tgid=0x%x", __entry->pid, __entry->tgid)
);

TRACE_EVENT(process_invoke_request_from_kernel_client,
	TP_PROTO(int fd, struct file *filp, int f_count),
	TP_ARGS(fd, filp, f_count),
	TP_STRUCT__entry(
		__field(int,		fd)
		__field(struct file*,	filp)
		__field(int,		f_count)
	),
	TP_fast_assign(
		__entry->fd		= fd;
		__entry->filp		= filp;
		__entry->f_count	= f_count;
	),
	TP_printk("fd=%d, filp=%p, f_count=%d",
			__entry->fd,
			__entry->filp,
			__entry->f_count)
);

TRACE_EVENT(smcinvoke_release_filp,
	TP_PROTO(struct files_struct *files, struct file *filp,
			int f_count, uint32_t context_type),
	TP_ARGS(files, filp, f_count, context_type),
	TP_STRUCT__entry(
		__field(struct files_struct*,	files)
		__field(struct file*,		filp)
		__field(int,			f_count)
		__field(uint32_t,		context_type)
	),
	TP_fast_assign(
		__entry->files		= files;
		__entry->filp		= filp;
		__entry->f_count	= f_count;
		__entry->context_type	= context_type;
	),
	TP_printk("files=%p, filp=%p, f_count=%u, cxt_type=%d",
			__entry->files,
			__entry->filp,
			__entry->f_count,
			__entry->context_type)
);

TRACE_EVENT(smcinvoke_release_from_kernel_client,
	TP_PROTO(struct files_struct *files, struct file *filp, int f_count),
	TP_ARGS(files, filp, f_count),
	TP_STRUCT__entry(
		__field(struct files_struct*,	files)
		__field(struct file*,		filp)
		__field(int,			f_count)
	),
	TP_fast_assign(
		__entry->files		= files;
		__entry->filp		= filp;
		__entry->f_count	= f_count;
	),
	TP_printk("files=%p, filp=%p, f_count=%u",
			__entry->files,
			__entry->filp,
			__entry->f_count)
);

TRACE_EVENT(smcinvoke_release,
	TP_PROTO(struct files_struct *files, struct file *filp,
			int f_count, void *private_data),
	TP_ARGS(files, filp, f_count, private_data),
	TP_STRUCT__entry(
		__field(struct files_struct*,	files)
		__field(struct file*,		filp)
		__field(int,			f_count)
		__field(void*,			private_data)
	),
	TP_fast_assign(
		__entry->files		= files;
		__entry->filp		= filp;
		__entry->f_count	= f_count;
		__entry->private_data	= private_data;
	),
	TP_printk("files=%p, filp=%p, f_count=%d, private_data=%p",
			__entry->files,
			__entry->filp,
			__entry->f_count,
			__entry->private_data)
);

#endif /* _TRACE_SMCINVOKE_H */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH ../../../../vendor/qcom/opensource/securemsm-kernel/smcinvoke

#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace_smcinvoke

/* This part must be outside protection */
#include <trace/define_trace.h>