intel-pt-pkt-decoder.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * intel_pt_pkt_decoder.c: Intel Processor Trace support
  3. * Copyright (c) 2013-2014, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <endian.h>
  18. #include <byteswap.h>
  19. #include <linux/compiler.h>
  20. #include "intel-pt-pkt-decoder.h"
  21. #define BIT(n) (1 << (n))
  22. #define BIT63 ((uint64_t)1 << 63)
  23. #define NR_FLAG BIT63
  24. #if __BYTE_ORDER == __BIG_ENDIAN
  25. #define le16_to_cpu bswap_16
  26. #define le32_to_cpu bswap_32
  27. #define le64_to_cpu bswap_64
  28. #define memcpy_le64(d, s, n) do { \
  29. memcpy((d), (s), (n)); \
  30. *(d) = le64_to_cpu(*(d)); \
  31. } while (0)
  32. #else
  33. #define le16_to_cpu
  34. #define le32_to_cpu
  35. #define le64_to_cpu
  36. #define memcpy_le64 memcpy
  37. #endif
  38. static const char * const packet_name[] = {
  39. [INTEL_PT_BAD] = "Bad Packet!",
  40. [INTEL_PT_PAD] = "PAD",
  41. [INTEL_PT_TNT] = "TNT",
  42. [INTEL_PT_TIP_PGD] = "TIP.PGD",
  43. [INTEL_PT_TIP_PGE] = "TIP.PGE",
  44. [INTEL_PT_TSC] = "TSC",
  45. [INTEL_PT_TMA] = "TMA",
  46. [INTEL_PT_MODE_EXEC] = "MODE.Exec",
  47. [INTEL_PT_MODE_TSX] = "MODE.TSX",
  48. [INTEL_PT_MTC] = "MTC",
  49. [INTEL_PT_TIP] = "TIP",
  50. [INTEL_PT_FUP] = "FUP",
  51. [INTEL_PT_CYC] = "CYC",
  52. [INTEL_PT_VMCS] = "VMCS",
  53. [INTEL_PT_PSB] = "PSB",
  54. [INTEL_PT_PSBEND] = "PSBEND",
  55. [INTEL_PT_CBR] = "CBR",
  56. [INTEL_PT_TRACESTOP] = "TraceSTOP",
  57. [INTEL_PT_PIP] = "PIP",
  58. [INTEL_PT_OVF] = "OVF",
  59. [INTEL_PT_MNT] = "MNT",
  60. [INTEL_PT_PTWRITE] = "PTWRITE",
  61. [INTEL_PT_PTWRITE_IP] = "PTWRITE",
  62. [INTEL_PT_EXSTOP] = "EXSTOP",
  63. [INTEL_PT_EXSTOP_IP] = "EXSTOP",
  64. [INTEL_PT_MWAIT] = "MWAIT",
  65. [INTEL_PT_PWRE] = "PWRE",
  66. [INTEL_PT_PWRX] = "PWRX",
  67. };
  68. const char *intel_pt_pkt_name(enum intel_pt_pkt_type type)
  69. {
  70. return packet_name[type];
  71. }
  72. static int intel_pt_get_long_tnt(const unsigned char *buf, size_t len,
  73. struct intel_pt_pkt *packet)
  74. {
  75. uint64_t payload;
  76. int count;
  77. if (len < 8)
  78. return INTEL_PT_NEED_MORE_BYTES;
  79. payload = le64_to_cpu(*(uint64_t *)buf);
  80. for (count = 47; count; count--) {
  81. if (payload & BIT63)
  82. break;
  83. payload <<= 1;
  84. }
  85. packet->type = INTEL_PT_TNT;
  86. packet->count = count;
  87. packet->payload = payload << 1;
  88. return 8;
  89. }
  90. static int intel_pt_get_pip(const unsigned char *buf, size_t len,
  91. struct intel_pt_pkt *packet)
  92. {
  93. uint64_t payload = 0;
  94. if (len < 8)
  95. return INTEL_PT_NEED_MORE_BYTES;
  96. packet->type = INTEL_PT_PIP;
  97. memcpy_le64(&payload, buf + 2, 6);
  98. packet->payload = payload >> 1;
  99. if (payload & 1)
  100. packet->payload |= NR_FLAG;
  101. return 8;
  102. }
  103. static int intel_pt_get_tracestop(struct intel_pt_pkt *packet)
  104. {
  105. packet->type = INTEL_PT_TRACESTOP;
  106. return 2;
  107. }
  108. static int intel_pt_get_cbr(const unsigned char *buf, size_t len,
  109. struct intel_pt_pkt *packet)
  110. {
  111. if (len < 4)
  112. return INTEL_PT_NEED_MORE_BYTES;
  113. packet->type = INTEL_PT_CBR;
  114. packet->payload = le16_to_cpu(*(uint16_t *)(buf + 2));
  115. return 4;
  116. }
  117. static int intel_pt_get_vmcs(const unsigned char *buf, size_t len,
  118. struct intel_pt_pkt *packet)
  119. {
  120. unsigned int count = (52 - 5) >> 3;
  121. if (count < 1 || count > 7)
  122. return INTEL_PT_BAD_PACKET;
  123. if (len < count + 2)
  124. return INTEL_PT_NEED_MORE_BYTES;
  125. packet->type = INTEL_PT_VMCS;
  126. packet->count = count;
  127. memcpy_le64(&packet->payload, buf + 2, count);
  128. return count + 2;
  129. }
  130. static int intel_pt_get_ovf(struct intel_pt_pkt *packet)
  131. {
  132. packet->type = INTEL_PT_OVF;
  133. return 2;
  134. }
  135. static int intel_pt_get_psb(const unsigned char *buf, size_t len,
  136. struct intel_pt_pkt *packet)
  137. {
  138. int i;
  139. if (len < 16)
  140. return INTEL_PT_NEED_MORE_BYTES;
  141. for (i = 2; i < 16; i += 2) {
  142. if (buf[i] != 2 || buf[i + 1] != 0x82)
  143. return INTEL_PT_BAD_PACKET;
  144. }
  145. packet->type = INTEL_PT_PSB;
  146. return 16;
  147. }
  148. static int intel_pt_get_psbend(struct intel_pt_pkt *packet)
  149. {
  150. packet->type = INTEL_PT_PSBEND;
  151. return 2;
  152. }
  153. static int intel_pt_get_tma(const unsigned char *buf, size_t len,
  154. struct intel_pt_pkt *packet)
  155. {
  156. if (len < 7)
  157. return INTEL_PT_NEED_MORE_BYTES;
  158. packet->type = INTEL_PT_TMA;
  159. packet->payload = buf[2] | (buf[3] << 8);
  160. packet->count = buf[5] | ((buf[6] & BIT(0)) << 8);
  161. return 7;
  162. }
  163. static int intel_pt_get_pad(struct intel_pt_pkt *packet)
  164. {
  165. packet->type = INTEL_PT_PAD;
  166. return 1;
  167. }
  168. static int intel_pt_get_mnt(const unsigned char *buf, size_t len,
  169. struct intel_pt_pkt *packet)
  170. {
  171. if (len < 11)
  172. return INTEL_PT_NEED_MORE_BYTES;
  173. packet->type = INTEL_PT_MNT;
  174. memcpy_le64(&packet->payload, buf + 3, 8);
  175. return 11
  176. ;
  177. }
  178. static int intel_pt_get_3byte(const unsigned char *buf, size_t len,
  179. struct intel_pt_pkt *packet)
  180. {
  181. if (len < 3)
  182. return INTEL_PT_NEED_MORE_BYTES;
  183. switch (buf[2]) {
  184. case 0x88: /* MNT */
  185. return intel_pt_get_mnt(buf, len, packet);
  186. default:
  187. return INTEL_PT_BAD_PACKET;
  188. }
  189. }
  190. static int intel_pt_get_ptwrite(const unsigned char *buf, size_t len,
  191. struct intel_pt_pkt *packet)
  192. {
  193. packet->count = (buf[1] >> 5) & 0x3;
  194. packet->type = buf[1] & BIT(7) ? INTEL_PT_PTWRITE_IP :
  195. INTEL_PT_PTWRITE;
  196. switch (packet->count) {
  197. case 0:
  198. if (len < 6)
  199. return INTEL_PT_NEED_MORE_BYTES;
  200. packet->payload = le32_to_cpu(*(uint32_t *)(buf + 2));
  201. return 6;
  202. case 1:
  203. if (len < 10)
  204. return INTEL_PT_NEED_MORE_BYTES;
  205. packet->payload = le64_to_cpu(*(uint64_t *)(buf + 2));
  206. return 10;
  207. default:
  208. return INTEL_PT_BAD_PACKET;
  209. }
  210. }
  211. static int intel_pt_get_exstop(struct intel_pt_pkt *packet)
  212. {
  213. packet->type = INTEL_PT_EXSTOP;
  214. return 2;
  215. }
  216. static int intel_pt_get_exstop_ip(struct intel_pt_pkt *packet)
  217. {
  218. packet->type = INTEL_PT_EXSTOP_IP;
  219. return 2;
  220. }
  221. static int intel_pt_get_mwait(const unsigned char *buf, size_t len,
  222. struct intel_pt_pkt *packet)
  223. {
  224. if (len < 10)
  225. return INTEL_PT_NEED_MORE_BYTES;
  226. packet->type = INTEL_PT_MWAIT;
  227. packet->payload = le64_to_cpu(*(uint64_t *)(buf + 2));
  228. return 10;
  229. }
  230. static int intel_pt_get_pwre(const unsigned char *buf, size_t len,
  231. struct intel_pt_pkt *packet)
  232. {
  233. if (len < 4)
  234. return INTEL_PT_NEED_MORE_BYTES;
  235. packet->type = INTEL_PT_PWRE;
  236. memcpy_le64(&packet->payload, buf + 2, 2);
  237. return 4;
  238. }
  239. static int intel_pt_get_pwrx(const unsigned char *buf, size_t len,
  240. struct intel_pt_pkt *packet)
  241. {
  242. if (len < 7)
  243. return INTEL_PT_NEED_MORE_BYTES;
  244. packet->type = INTEL_PT_PWRX;
  245. memcpy_le64(&packet->payload, buf + 2, 5);
  246. return 7;
  247. }
  248. static int intel_pt_get_ext(const unsigned char *buf, size_t len,
  249. struct intel_pt_pkt *packet)
  250. {
  251. if (len < 2)
  252. return INTEL_PT_NEED_MORE_BYTES;
  253. if ((buf[1] & 0x1f) == 0x12)
  254. return intel_pt_get_ptwrite(buf, len, packet);
  255. switch (buf[1]) {
  256. case 0xa3: /* Long TNT */
  257. return intel_pt_get_long_tnt(buf, len, packet);
  258. case 0x43: /* PIP */
  259. return intel_pt_get_pip(buf, len, packet);
  260. case 0x83: /* TraceStop */
  261. return intel_pt_get_tracestop(packet);
  262. case 0x03: /* CBR */
  263. return intel_pt_get_cbr(buf, len, packet);
  264. case 0xc8: /* VMCS */
  265. return intel_pt_get_vmcs(buf, len, packet);
  266. case 0xf3: /* OVF */
  267. return intel_pt_get_ovf(packet);
  268. case 0x82: /* PSB */
  269. return intel_pt_get_psb(buf, len, packet);
  270. case 0x23: /* PSBEND */
  271. return intel_pt_get_psbend(packet);
  272. case 0x73: /* TMA */
  273. return intel_pt_get_tma(buf, len, packet);
  274. case 0xC3: /* 3-byte header */
  275. return intel_pt_get_3byte(buf, len, packet);
  276. case 0x62: /* EXSTOP no IP */
  277. return intel_pt_get_exstop(packet);
  278. case 0xE2: /* EXSTOP with IP */
  279. return intel_pt_get_exstop_ip(packet);
  280. case 0xC2: /* MWAIT */
  281. return intel_pt_get_mwait(buf, len, packet);
  282. case 0x22: /* PWRE */
  283. return intel_pt_get_pwre(buf, len, packet);
  284. case 0xA2: /* PWRX */
  285. return intel_pt_get_pwrx(buf, len, packet);
  286. default:
  287. return INTEL_PT_BAD_PACKET;
  288. }
  289. }
  290. static int intel_pt_get_short_tnt(unsigned int byte,
  291. struct intel_pt_pkt *packet)
  292. {
  293. int count;
  294. for (count = 6; count; count--) {
  295. if (byte & BIT(7))
  296. break;
  297. byte <<= 1;
  298. }
  299. packet->type = INTEL_PT_TNT;
  300. packet->count = count;
  301. packet->payload = (uint64_t)byte << 57;
  302. return 1;
  303. }
  304. static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
  305. size_t len, struct intel_pt_pkt *packet)
  306. {
  307. unsigned int offs = 1, shift;
  308. uint64_t payload = byte >> 3;
  309. byte >>= 2;
  310. len -= 1;
  311. for (shift = 5; byte & 1; shift += 7) {
  312. if (offs > 9)
  313. return INTEL_PT_BAD_PACKET;
  314. if (len < offs)
  315. return INTEL_PT_NEED_MORE_BYTES;
  316. byte = buf[offs++];
  317. payload |= ((uint64_t)byte >> 1) << shift;
  318. }
  319. packet->type = INTEL_PT_CYC;
  320. packet->payload = payload;
  321. return offs;
  322. }
  323. static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte,
  324. const unsigned char *buf, size_t len,
  325. struct intel_pt_pkt *packet)
  326. {
  327. int ip_len;
  328. packet->count = byte >> 5;
  329. switch (packet->count) {
  330. case 0:
  331. ip_len = 0;
  332. break;
  333. case 1:
  334. if (len < 3)
  335. return INTEL_PT_NEED_MORE_BYTES;
  336. ip_len = 2;
  337. packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1));
  338. break;
  339. case 2:
  340. if (len < 5)
  341. return INTEL_PT_NEED_MORE_BYTES;
  342. ip_len = 4;
  343. packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1));
  344. break;
  345. case 3:
  346. case 4:
  347. if (len < 7)
  348. return INTEL_PT_NEED_MORE_BYTES;
  349. ip_len = 6;
  350. memcpy_le64(&packet->payload, buf + 1, 6);
  351. break;
  352. case 6:
  353. if (len < 9)
  354. return INTEL_PT_NEED_MORE_BYTES;
  355. ip_len = 8;
  356. packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1));
  357. break;
  358. default:
  359. return INTEL_PT_BAD_PACKET;
  360. }
  361. packet->type = type;
  362. return ip_len + 1;
  363. }
  364. static int intel_pt_get_mode(const unsigned char *buf, size_t len,
  365. struct intel_pt_pkt *packet)
  366. {
  367. if (len < 2)
  368. return INTEL_PT_NEED_MORE_BYTES;
  369. switch (buf[1] >> 5) {
  370. case 0:
  371. packet->type = INTEL_PT_MODE_EXEC;
  372. switch (buf[1] & 3) {
  373. case 0:
  374. packet->payload = 16;
  375. break;
  376. case 1:
  377. packet->payload = 64;
  378. break;
  379. case 2:
  380. packet->payload = 32;
  381. break;
  382. default:
  383. return INTEL_PT_BAD_PACKET;
  384. }
  385. break;
  386. case 1:
  387. packet->type = INTEL_PT_MODE_TSX;
  388. if ((buf[1] & 3) == 3)
  389. return INTEL_PT_BAD_PACKET;
  390. packet->payload = buf[1] & 3;
  391. break;
  392. default:
  393. return INTEL_PT_BAD_PACKET;
  394. }
  395. return 2;
  396. }
  397. static int intel_pt_get_tsc(const unsigned char *buf, size_t len,
  398. struct intel_pt_pkt *packet)
  399. {
  400. if (len < 8)
  401. return INTEL_PT_NEED_MORE_BYTES;
  402. packet->type = INTEL_PT_TSC;
  403. memcpy_le64(&packet->payload, buf + 1, 7);
  404. return 8;
  405. }
  406. static int intel_pt_get_mtc(const unsigned char *buf, size_t len,
  407. struct intel_pt_pkt *packet)
  408. {
  409. if (len < 2)
  410. return INTEL_PT_NEED_MORE_BYTES;
  411. packet->type = INTEL_PT_MTC;
  412. packet->payload = buf[1];
  413. return 2;
  414. }
  415. static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
  416. struct intel_pt_pkt *packet)
  417. {
  418. unsigned int byte;
  419. memset(packet, 0, sizeof(struct intel_pt_pkt));
  420. if (!len)
  421. return INTEL_PT_NEED_MORE_BYTES;
  422. byte = buf[0];
  423. if (!(byte & BIT(0))) {
  424. if (byte == 0)
  425. return intel_pt_get_pad(packet);
  426. if (byte == 2)
  427. return intel_pt_get_ext(buf, len, packet);
  428. return intel_pt_get_short_tnt(byte, packet);
  429. }
  430. if ((byte & 2))
  431. return intel_pt_get_cyc(byte, buf, len, packet);
  432. switch (byte & 0x1f) {
  433. case 0x0D:
  434. return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet);
  435. case 0x11:
  436. return intel_pt_get_ip(INTEL_PT_TIP_PGE, byte, buf, len,
  437. packet);
  438. case 0x01:
  439. return intel_pt_get_ip(INTEL_PT_TIP_PGD, byte, buf, len,
  440. packet);
  441. case 0x1D:
  442. return intel_pt_get_ip(INTEL_PT_FUP, byte, buf, len, packet);
  443. case 0x19:
  444. switch (byte) {
  445. case 0x99:
  446. return intel_pt_get_mode(buf, len, packet);
  447. case 0x19:
  448. return intel_pt_get_tsc(buf, len, packet);
  449. case 0x59:
  450. return intel_pt_get_mtc(buf, len, packet);
  451. default:
  452. return INTEL_PT_BAD_PACKET;
  453. }
  454. default:
  455. return INTEL_PT_BAD_PACKET;
  456. }
  457. }
  458. int intel_pt_get_packet(const unsigned char *buf, size_t len,
  459. struct intel_pt_pkt *packet)
  460. {
  461. int ret;
  462. ret = intel_pt_do_get_packet(buf, len, packet);
  463. if (ret > 0) {
  464. while (ret < 8 && len > (size_t)ret && !buf[ret])
  465. ret += 1;
  466. }
  467. return ret;
  468. }
  469. int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
  470. size_t buf_len)
  471. {
  472. int ret, i, nr;
  473. unsigned long long payload = packet->payload;
  474. const char *name = intel_pt_pkt_name(packet->type);
  475. switch (packet->type) {
  476. case INTEL_PT_BAD:
  477. case INTEL_PT_PAD:
  478. case INTEL_PT_PSB:
  479. case INTEL_PT_PSBEND:
  480. case INTEL_PT_TRACESTOP:
  481. case INTEL_PT_OVF:
  482. return snprintf(buf, buf_len, "%s", name);
  483. case INTEL_PT_TNT: {
  484. size_t blen = buf_len;
  485. ret = snprintf(buf, blen, "%s ", name);
  486. if (ret < 0)
  487. return ret;
  488. buf += ret;
  489. blen -= ret;
  490. for (i = 0; i < packet->count; i++) {
  491. if (payload & BIT63)
  492. ret = snprintf(buf, blen, "T");
  493. else
  494. ret = snprintf(buf, blen, "N");
  495. if (ret < 0)
  496. return ret;
  497. buf += ret;
  498. blen -= ret;
  499. payload <<= 1;
  500. }
  501. ret = snprintf(buf, blen, " (%d)", packet->count);
  502. if (ret < 0)
  503. return ret;
  504. blen -= ret;
  505. return buf_len - blen;
  506. }
  507. case INTEL_PT_TIP_PGD:
  508. case INTEL_PT_TIP_PGE:
  509. case INTEL_PT_TIP:
  510. case INTEL_PT_FUP:
  511. if (!(packet->count))
  512. return snprintf(buf, buf_len, "%s no ip", name);
  513. __fallthrough;
  514. case INTEL_PT_CYC:
  515. case INTEL_PT_VMCS:
  516. case INTEL_PT_MTC:
  517. case INTEL_PT_MNT:
  518. case INTEL_PT_CBR:
  519. case INTEL_PT_TSC:
  520. return snprintf(buf, buf_len, "%s 0x%llx", name, payload);
  521. case INTEL_PT_TMA:
  522. return snprintf(buf, buf_len, "%s CTC 0x%x FC 0x%x", name,
  523. (unsigned)payload, packet->count);
  524. case INTEL_PT_MODE_EXEC:
  525. return snprintf(buf, buf_len, "%s %lld", name, payload);
  526. case INTEL_PT_MODE_TSX:
  527. return snprintf(buf, buf_len, "%s TXAbort:%u InTX:%u",
  528. name, (unsigned)(payload >> 1) & 1,
  529. (unsigned)payload & 1);
  530. case INTEL_PT_PIP:
  531. nr = packet->payload & NR_FLAG ? 1 : 0;
  532. payload &= ~NR_FLAG;
  533. ret = snprintf(buf, buf_len, "%s 0x%llx (NR=%d)",
  534. name, payload, nr);
  535. return ret;
  536. case INTEL_PT_PTWRITE:
  537. return snprintf(buf, buf_len, "%s 0x%llx IP:0", name, payload);
  538. case INTEL_PT_PTWRITE_IP:
  539. return snprintf(buf, buf_len, "%s 0x%llx IP:1", name, payload);
  540. case INTEL_PT_EXSTOP:
  541. return snprintf(buf, buf_len, "%s IP:0", name);
  542. case INTEL_PT_EXSTOP_IP:
  543. return snprintf(buf, buf_len, "%s IP:1", name);
  544. case INTEL_PT_MWAIT:
  545. return snprintf(buf, buf_len, "%s 0x%llx Hints 0x%x Extensions 0x%x",
  546. name, payload, (unsigned int)(payload & 0xff),
  547. (unsigned int)((payload >> 32) & 0x3));
  548. case INTEL_PT_PWRE:
  549. return snprintf(buf, buf_len, "%s 0x%llx HW:%u CState:%u Sub-CState:%u",
  550. name, payload, !!(payload & 0x80),
  551. (unsigned int)((payload >> 12) & 0xf),
  552. (unsigned int)((payload >> 8) & 0xf));
  553. case INTEL_PT_PWRX:
  554. return snprintf(buf, buf_len, "%s 0x%llx Last CState:%u Deepest CState:%u Wake Reason 0x%x",
  555. name, payload,
  556. (unsigned int)((payload >> 4) & 0xf),
  557. (unsigned int)(payload & 0xf),
  558. (unsigned int)((payload >> 8) & 0xf));
  559. default:
  560. break;
  561. }
  562. return snprintf(buf, buf_len, "%s 0x%llx (%d)",
  563. name, payload, packet->count);
  564. }