trace_smcinvoke.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #undef TRACE_SYSTEM
  6. #define TRACE_SYSTEM smcinvoke
  7. #undef TRACE_INCLUDE_FILE
  8. #define TRACE_INCLUDE_FILE trace_smcinvoke
  9. #if !defined(_TRACE_SMCINVOKE) || defined(TRACE_HEADER_MULTI_READ)
  10. #define _TRACE_SMCINVOKE_H
  11. #include <linux/types.h>
  12. #include <linux/tracepoint.h>
  13. #include "smcinvoke.h"
  14. TRACE_EVENT(put_pending_cbobj_locked,
  15. TP_PROTO(uint16_t srvr_id, uint16_t obj_id),
  16. TP_ARGS(srvr_id, obj_id),
  17. TP_STRUCT__entry(
  18. __field(uint16_t, srvr_id)
  19. __field(uint16_t, obj_id)
  20. ),
  21. TP_fast_assign(
  22. __entry->srvr_id = srvr_id;
  23. __entry->obj_id = obj_id;
  24. ),
  25. TP_printk("srvr_id=0x%x obj_id=0x%x",
  26. __entry->srvr_id, __entry->obj_id)
  27. );
  28. TRACE_EVENT(release_mem_obj_locked,
  29. TP_PROTO(uint32_t tzhandle, size_t buf_len),
  30. TP_ARGS(tzhandle, buf_len),
  31. TP_STRUCT__entry(
  32. __field(uint32_t, tzhandle)
  33. __field(size_t, buf_len)
  34. ),
  35. TP_fast_assign(
  36. __entry->tzhandle = tzhandle;
  37. __entry->buf_len = buf_len;
  38. ),
  39. TP_printk("tzhandle=0x%08x, buf_len=%zu",
  40. __entry->tzhandle, __entry->buf_len)
  41. );
  42. TRACE_EVENT(invoke_cmd_handler,
  43. TP_PROTO(int cmd, uint64_t response_type, int32_t result, int ret),
  44. TP_ARGS(cmd, response_type, result, ret),
  45. TP_STRUCT__entry(
  46. __field(int, cmd)
  47. __field(uint64_t, response_type)
  48. __field(int32_t, result)
  49. __field(int, ret)
  50. ),
  51. TP_fast_assign(
  52. __entry->response_type = response_type;
  53. __entry->result = result;
  54. __entry->ret = ret;
  55. __entry->cmd = cmd;
  56. ),
  57. TP_printk("cmd=0x%x (%d), response_type=%ld, result=0x%x (%d), ret=%d",
  58. __entry->cmd, __entry->cmd, __entry->response_type,
  59. __entry->result, __entry->result, __entry->ret)
  60. );
  61. TRACE_EVENT(process_tzcb_req_handle,
  62. TP_PROTO(uint32_t tzhandle, uint32_t op, uint32_t counts),
  63. TP_ARGS(tzhandle, op, counts),
  64. TP_STRUCT__entry(
  65. __field(uint32_t, tzhandle)
  66. __field(uint32_t, op)
  67. __field(uint32_t, counts)
  68. ),
  69. TP_fast_assign(
  70. __entry->tzhandle = tzhandle;
  71. __entry->op = op;
  72. __entry->counts = counts;
  73. ),
  74. TP_printk("tzhandle=0x%08x op=0x%02x counts=0x%04x",
  75. __entry->tzhandle, __entry->op, __entry->counts)
  76. );
  77. TRACE_EVENT(process_tzcb_req_wait,
  78. TP_PROTO(uint32_t tzhandle, int cbobj_retries, uint32_t txn_id, pid_t pid, pid_t tgid,
  79. uint16_t server_state, uint16_t server_id, unsigned int cb_reqs_inflight),
  80. TP_ARGS(tzhandle, cbobj_retries, txn_id, pid, tgid, server_state, server_id,
  81. cb_reqs_inflight),
  82. TP_STRUCT__entry(
  83. __field(uint32_t, tzhandle)
  84. __field(int, cbobj_retries)
  85. __field(uint32_t, txn_id)
  86. __field(pid_t, pid)
  87. __field(pid_t, tgid)
  88. __field(uint16_t, server_state)
  89. __field(uint16_t, server_id)
  90. __field(unsigned int, cb_reqs_inflight)
  91. ),
  92. TP_fast_assign(
  93. __entry->tzhandle = tzhandle;
  94. __entry->cbobj_retries = cbobj_retries;
  95. __entry->txn_id = txn_id;
  96. __entry->pid = pid;
  97. __entry->tgid = tgid;
  98. __entry->server_state = server_state;
  99. __entry->server_id = server_id;
  100. __entry->cb_reqs_inflight = cb_reqs_inflight;
  101. ),
  102. 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",
  103. __entry->tzhandle, __entry->cbobj_retries, __entry->txn_id,
  104. __entry->pid, __entry->tgid, __entry->server_state,
  105. __entry->server_id, __entry->cb_reqs_inflight)
  106. );
  107. TRACE_EVENT(process_tzcb_req_result,
  108. TP_PROTO(int32_t result, uint32_t tzhandle, uint32_t op, uint32_t counts,
  109. unsigned int cb_reqs_inflight),
  110. TP_ARGS(result, tzhandle, op, counts, cb_reqs_inflight),
  111. TP_STRUCT__entry(
  112. __field(int32_t, result)
  113. __field(uint32_t, tzhandle)
  114. __field(uint32_t, op)
  115. __field(uint32_t, counts)
  116. __field(unsigned int, cb_reqs_inflight)
  117. ),
  118. TP_fast_assign(
  119. __entry->result = result;
  120. __entry->tzhandle = tzhandle;
  121. __entry->op = op;
  122. __entry->counts = counts;
  123. __entry->cb_reqs_inflight = cb_reqs_inflight;
  124. ),
  125. TP_printk("result=%d tzhandle=0x%08x op=0x%02x counts=0x%04x, cb_reqs_inflight=%d",
  126. __entry->result, __entry->tzhandle, __entry->op, __entry->counts,
  127. __entry->cb_reqs_inflight)
  128. );
  129. TRACE_EVENT(marshal_out_invoke_req,
  130. TP_PROTO(int i, uint32_t tzhandle, uint16_t server, uint32_t fd),
  131. TP_ARGS(i, tzhandle, server, fd),
  132. TP_STRUCT__entry(
  133. __field(int, i)
  134. __field(uint32_t, tzhandle)
  135. __field(uint16_t, server)
  136. __field(uint32_t, fd)
  137. ),
  138. TP_fast_assign(
  139. __entry->i = i;
  140. __entry->tzhandle = tzhandle;
  141. __entry->server = server;
  142. __entry->fd = fd;
  143. ),
  144. TP_printk("OO[%d]: tzhandle=0x%x server=0x%x fd=0x%x",
  145. __entry->i, __entry->tzhandle, __entry->server, __entry->fd)
  146. );
  147. TRACE_EVENT(prepare_send_scm_msg,
  148. TP_PROTO(uint64_t response_type, int32_t result),
  149. TP_ARGS(response_type, result),
  150. TP_STRUCT__entry(
  151. __field(uint64_t, response_type)
  152. __field(int32_t, result)
  153. ),
  154. TP_fast_assign(
  155. __entry->response_type = response_type;
  156. __entry->result = result;
  157. ),
  158. TP_printk("response_type=0x%lx (%ld), result=0x%x (%d)",
  159. __entry->response_type, __entry->response_type,
  160. __entry->result, __entry->result)
  161. );
  162. TRACE_EVENT(marshal_in_invoke_req,
  163. TP_PROTO(int i, int64_t fd, int32_t cb_server_fd, uint32_t tzhandle),
  164. TP_ARGS(i, fd, cb_server_fd, tzhandle),
  165. TP_STRUCT__entry(
  166. __field(int, i)
  167. __field(int64_t, fd)
  168. __field(int32_t, cb_server_fd)
  169. __field(uint32_t, tzhandle)
  170. ),
  171. TP_fast_assign(
  172. __entry->i = i;
  173. __entry->fd = fd;
  174. __entry->cb_server_fd = cb_server_fd;
  175. __entry->tzhandle = tzhandle;
  176. ),
  177. TP_printk("OI[%d]: fd=0x%x cb_server_fd=0x%x tzhandle=0x%x",
  178. __entry->i, __entry->fd, __entry->cb_server_fd, __entry->tzhandle)
  179. );
  180. TRACE_EVENT(marshal_in_tzcb_req_handle,
  181. TP_PROTO(uint32_t tzhandle, int srvr_id, int32_t cbobj_id, uint32_t op, uint32_t counts),
  182. TP_ARGS(tzhandle, srvr_id, cbobj_id, op, counts),
  183. TP_STRUCT__entry(
  184. __field(uint32_t, tzhandle)
  185. __field(int, srvr_id)
  186. __field(int32_t, cbobj_id)
  187. __field(uint32_t, op)
  188. __field(uint32_t, counts)
  189. ),
  190. TP_fast_assign(
  191. __entry->tzhandle = tzhandle;
  192. __entry->srvr_id = srvr_id;
  193. __entry->cbobj_id = cbobj_id;
  194. __entry->op = op;
  195. __entry->counts = counts;
  196. ),
  197. TP_printk("tzhandle=0x%x srvr_id=0x%x cbobj_id=0x%08x op=0x%02x counts=0x%04x",
  198. __entry->tzhandle, __entry->srvr_id, __entry->cbobj_id,
  199. __entry->op, __entry->counts)
  200. );
  201. TRACE_EVENT(marshal_in_tzcb_req_fd,
  202. TP_PROTO(int i, uint32_t tzhandle, int srvr_id, int32_t fd),
  203. TP_ARGS(i, tzhandle, srvr_id, fd),
  204. TP_STRUCT__entry(
  205. __field(int, i)
  206. __field(uint32_t, tzhandle)
  207. __field(int, srvr_id)
  208. __field(int32_t, fd)
  209. ),
  210. TP_fast_assign(
  211. __entry->i = i;
  212. __entry->tzhandle = tzhandle;
  213. __entry->srvr_id = srvr_id;
  214. __entry->fd = fd;
  215. ),
  216. TP_printk("OI[%d]: tzhandle=0x%x srvr_id=0x%x fd=0x%x",
  217. __entry->i, __entry->tzhandle, __entry->srvr_id, __entry->fd)
  218. );
  219. TRACE_EVENT(marshal_out_tzcb_req,
  220. TP_PROTO(uint32_t i, int32_t fd, int32_t cb_server_fd, uint32_t tzhandle),
  221. TP_ARGS(i, fd, cb_server_fd, tzhandle),
  222. TP_STRUCT__entry(
  223. __field(int, i)
  224. __field(int32_t, fd)
  225. __field(int32_t, cb_server_fd)
  226. __field(uint32_t, tzhandle)
  227. ),
  228. TP_fast_assign(
  229. __entry->i = i;
  230. __entry->fd = fd;
  231. __entry->cb_server_fd = cb_server_fd;
  232. __entry->tzhandle = tzhandle;
  233. ),
  234. TP_printk("OO[%d]: fd=0x%x cb_server_fd=0x%x tzhandle=0x%x",
  235. __entry->i, __entry->fd, __entry->cb_server_fd, __entry->tzhandle)
  236. );
  237. TRACE_EVENT(process_invoke_req_tzhandle,
  238. TP_PROTO(uint32_t tzhandle, uint32_t op, uint32_t counts),
  239. TP_ARGS(tzhandle, op, counts),
  240. TP_STRUCT__entry(
  241. __field(uint32_t, tzhandle)
  242. __field(uint32_t, op)
  243. __field(uint32_t, counts)
  244. ),
  245. TP_fast_assign(
  246. __entry->tzhandle = tzhandle;
  247. __entry->op = op;
  248. __entry->counts = counts;
  249. ),
  250. TP_printk("tzhandle=0x%08x op=0x%02x counts=0x%04x",
  251. __entry->tzhandle, __entry->op, __entry->counts)
  252. );
  253. TRACE_EVENT(process_invoke_req_result,
  254. TP_PROTO(int ret, int32_t result, uint32_t tzhandle, uint32_t op, uint32_t counts),
  255. TP_ARGS(ret, result, tzhandle, op, counts),
  256. TP_STRUCT__entry(
  257. __field(int, ret)
  258. __field(int32_t, result)
  259. __field(uint32_t, tzhandle)
  260. __field(uint32_t, op)
  261. __field(uint32_t, counts)
  262. ),
  263. TP_fast_assign(
  264. __entry->ret = ret;
  265. __entry->result = result;
  266. __entry->tzhandle = tzhandle;
  267. __entry->op = op;
  268. __entry->counts = counts;
  269. ),
  270. TP_printk("ret=%d result=%d tzhandle=0x%08x op=0x%02x counts=0x%04x",
  271. __entry->ret, __entry->result, __entry->tzhandle,
  272. __entry->op, __entry->counts)
  273. );
  274. TRACE_EVENT(process_log_info,
  275. TP_PROTO(char *buf, uint32_t context_type, uint32_t tzhandle),
  276. TP_ARGS(buf, context_type, tzhandle),
  277. TP_STRUCT__entry(
  278. __string(str, buf)
  279. __field(uint32_t, context_type)
  280. __field(uint32_t, tzhandle)
  281. ),
  282. TP_fast_assign(
  283. __assign_str(str, buf);
  284. __entry->context_type = context_type;
  285. __entry->tzhandle = tzhandle;
  286. ),
  287. TP_printk("%s context_type=%d tzhandle=0x%08x",
  288. __get_str(str),
  289. __entry->context_type, __entry->tzhandle)
  290. );
  291. TRACE_EVENT_CONDITION(smcinvoke_ioctl,
  292. TP_PROTO(unsigned int cmd, long ret),
  293. TP_ARGS(cmd, ret),
  294. TP_CONDITION(ret),
  295. TP_STRUCT__entry(
  296. __field(unsigned int, cmd)
  297. __field(long, ret)
  298. ),
  299. TP_fast_assign(
  300. __entry->cmd = cmd;
  301. __entry->ret = ret;
  302. ),
  303. TP_printk("cmd=%s ret=%ld",
  304. __print_symbolic(__entry->cmd,
  305. {SMCINVOKE_IOCTL_INVOKE_REQ, "SMCINVOKE_IOCTL_INVOKE_REQ"},
  306. {SMCINVOKE_IOCTL_ACCEPT_REQ, "SMCINVOKE_IOCTL_ACCEPT_REQ"},
  307. {SMCINVOKE_IOCTL_SERVER_REQ, "SMCINVOKE_IOCTL_SERVER_REQ"},
  308. {SMCINVOKE_IOCTL_ACK_LOCAL_OBJ, "SMCINVOKE_IOCTL_ACK_LOCAL_OBJ"},
  309. {SMCINVOKE_IOCTL_LOG, "SMCINVOKE_IOCTL_LOG"}
  310. ), __entry->ret)
  311. );
  312. TRACE_EVENT(smcinvoke_create_bridge,
  313. TP_PROTO(uint64_t shmbridge_handle, uint16_t mem_region_id),
  314. TP_ARGS(shmbridge_handle, mem_region_id),
  315. TP_STRUCT__entry(
  316. __field(uint64_t, shmbridge_handle)
  317. __field(uint16_t, mem_region_id)
  318. ),
  319. TP_fast_assign(
  320. __entry->shmbridge_handle = shmbridge_handle;
  321. __entry->mem_region_id = mem_region_id;
  322. ),
  323. TP_printk("created shm bridge handle %llu for mem_region_id %u",
  324. __entry->shmbridge_handle, __entry->mem_region_id)
  325. );
  326. TRACE_EVENT(status,
  327. TP_PROTO(const char *func, const char *status),
  328. TP_ARGS(func, status),
  329. TP_STRUCT__entry(
  330. __string(str, func)
  331. __string(str2, status)
  332. ),
  333. TP_fast_assign(
  334. __assign_str(str, func);
  335. __assign_str(str2, status);
  336. ),
  337. TP_printk("%s status=%s", __get_str(str), __get_str(str2))
  338. );
  339. TRACE_EVENT(process_accept_req_has_response,
  340. TP_PROTO(pid_t pid, pid_t tgid),
  341. TP_ARGS(pid, tgid),
  342. TP_STRUCT__entry(
  343. __field(pid_t, pid)
  344. __field(pid_t, tgid)
  345. ),
  346. TP_fast_assign(
  347. __entry->pid = pid;
  348. __entry->tgid = tgid;
  349. ),
  350. TP_printk("pid=0x%x, tgid=0x%x", __entry->pid, __entry->tgid)
  351. );
  352. TRACE_EVENT(process_accept_req_ret,
  353. TP_PROTO(pid_t pid, pid_t tgid, int ret),
  354. TP_ARGS(pid, tgid, ret),
  355. TP_STRUCT__entry(
  356. __field(pid_t, pid)
  357. __field(pid_t, tgid)
  358. __field(int, ret)
  359. ),
  360. TP_fast_assign(
  361. __entry->pid = pid;
  362. __entry->tgid = tgid;
  363. __entry->ret = ret;
  364. ),
  365. TP_printk("pid=0x%x tgid=0x%x ret=%d", __entry->pid, __entry->tgid, __entry->ret)
  366. );
  367. TRACE_EVENT(process_accept_req_placed,
  368. TP_PROTO(pid_t pid, pid_t tgid),
  369. TP_ARGS(pid, tgid),
  370. TP_STRUCT__entry(
  371. __field(pid_t, pid)
  372. __field(pid_t, tgid)
  373. ),
  374. TP_fast_assign(
  375. __entry->pid = pid;
  376. __entry->tgid = tgid;
  377. ),
  378. TP_printk("pid=0x%x, tgid=0x%x", __entry->pid, __entry->tgid)
  379. );
  380. TRACE_EVENT(process_invoke_request_from_kernel_client,
  381. TP_PROTO(int fd, struct file *filp, int f_count),
  382. TP_ARGS(fd, filp, f_count),
  383. TP_STRUCT__entry(
  384. __field(int, fd)
  385. __field(struct file*, filp)
  386. __field(int, f_count)
  387. ),
  388. TP_fast_assign(
  389. __entry->fd = fd;
  390. __entry->filp = filp;
  391. __entry->f_count = f_count;
  392. ),
  393. TP_printk("fd=%d, filp=%p, f_count=%d",
  394. __entry->fd,
  395. __entry->filp,
  396. __entry->f_count)
  397. );
  398. TRACE_EVENT(smcinvoke_release_filp,
  399. TP_PROTO(struct files_struct *files, struct file *filp,
  400. int f_count, uint32_t context_type),
  401. TP_ARGS(files, filp, f_count, context_type),
  402. TP_STRUCT__entry(
  403. __field(struct files_struct*, files)
  404. __field(struct file*, filp)
  405. __field(int, f_count)
  406. __field(uint32_t, context_type)
  407. ),
  408. TP_fast_assign(
  409. __entry->files = files;
  410. __entry->filp = filp;
  411. __entry->f_count = f_count;
  412. __entry->context_type = context_type;
  413. ),
  414. TP_printk("files=%p, filp=%p, f_count=%u, cxt_type=%d",
  415. __entry->files,
  416. __entry->filp,
  417. __entry->f_count,
  418. __entry->context_type)
  419. );
  420. TRACE_EVENT(smcinvoke_release_from_kernel_client,
  421. TP_PROTO(struct files_struct *files, struct file *filp, int f_count),
  422. TP_ARGS(files, filp, f_count),
  423. TP_STRUCT__entry(
  424. __field(struct files_struct*, files)
  425. __field(struct file*, filp)
  426. __field(int, f_count)
  427. ),
  428. TP_fast_assign(
  429. __entry->files = files;
  430. __entry->filp = filp;
  431. __entry->f_count = f_count;
  432. ),
  433. TP_printk("files=%p, filp=%p, f_count=%u",
  434. __entry->files,
  435. __entry->filp,
  436. __entry->f_count)
  437. );
  438. TRACE_EVENT(smcinvoke_release,
  439. TP_PROTO(struct files_struct *files, struct file *filp,
  440. int f_count, void *private_data),
  441. TP_ARGS(files, filp, f_count, private_data),
  442. TP_STRUCT__entry(
  443. __field(struct files_struct*, files)
  444. __field(struct file*, filp)
  445. __field(int, f_count)
  446. __field(void*, private_data)
  447. ),
  448. TP_fast_assign(
  449. __entry->files = files;
  450. __entry->filp = filp;
  451. __entry->f_count = f_count;
  452. __entry->private_data = private_data;
  453. ),
  454. TP_printk("files=%p, filp=%p, f_count=%d, private_data=%p",
  455. __entry->files,
  456. __entry->filp,
  457. __entry->f_count,
  458. __entry->private_data)
  459. );
  460. #endif /* _TRACE_SMCINVOKE_H */
  461. /*
  462. * Path must be relative to location of 'define_trace.h' header in kernel
  463. * Define path if not defined in bazel file
  464. */
  465. #ifndef SMCINVOKE_TRACE_INCLUDE_PATH
  466. #define SMCINVOKE_TRACE_INCLUDE_PATH ../../../../vendor/qcom/opensource/securemsm-kernel/smcinvoke
  467. #endif
  468. #undef TRACE_INCLUDE_PATH
  469. #define TRACE_INCLUDE_PATH SMCINVOKE_TRACE_INCLUDE_PATH
  470. #undef TRACE_INCLUDE_FILE
  471. #define TRACE_INCLUDE_FILE trace_smcinvoke
  472. /* This part must be outside protection */
  473. #include <trace/define_trace.h>