aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-07-17 12:33:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-24 16:46:06 -0400
commit3d49807870f08d6f3406b77efd94bb3788372162 (patch)
treeac0dc34a4d4edd39ea0960f32874ecf047e77dbd /tools
parentbc9b6bf07c8b3f4e85509f9b3a552c86e567b4ae (diff)
perf tools: Add new Intel PT packet definitions
New features have been added to Intel PT which include a number of new packet definitions. This patch adds packet definitions for new packets: TMA, MTC, CYC, VMCS, TRACESTOP and MNT. Also another bit in PIP is defined. This patch only adds support for the definitions. Later patches add support for decoding TMA, MTC, CYC and TRACESTOP which is where those packets are explained. VMCS and the newly defined bit in PIP are used with virtualization which is not supported yet. MNT is a maintenance packet which the decoder should ignore. For details, refer to the June 2015 or later Intel 64 and IA-32 Architectures SDM Chapter 36 Intel Processor Trace. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1437150840-31811-19-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c70
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c142
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h6
3 files changed, 201 insertions, 17 deletions
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 56790ea1e88e..4a0e9fb1d173 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -923,6 +923,7 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
923 case INTEL_PT_TIP_PGE: 923 case INTEL_PT_TIP_PGE:
924 case INTEL_PT_TIP: 924 case INTEL_PT_TIP:
925 case INTEL_PT_TNT: 925 case INTEL_PT_TNT:
926 case INTEL_PT_TRACESTOP:
926 case INTEL_PT_BAD: 927 case INTEL_PT_BAD:
927 case INTEL_PT_PSB: 928 case INTEL_PT_PSB:
928 intel_pt_log("ERROR: Unexpected packet\n"); 929 intel_pt_log("ERROR: Unexpected packet\n");
@@ -935,6 +936,9 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
935 intel_pt_calc_tsc_timestamp(decoder); 936 intel_pt_calc_tsc_timestamp(decoder);
936 break; 937 break;
937 938
939 case INTEL_PT_TMA:
940 break;
941
938 case INTEL_PT_CBR: 942 case INTEL_PT_CBR:
939 decoder->cbr = decoder->packet.payload; 943 decoder->cbr = decoder->packet.payload;
940 break; 944 break;
@@ -944,7 +948,7 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
944 break; 948 break;
945 949
946 case INTEL_PT_PIP: 950 case INTEL_PT_PIP:
947 decoder->cr3 = decoder->packet.payload; 951 decoder->cr3 = decoder->packet.payload & (BIT63 - 1);
948 break; 952 break;
949 953
950 case INTEL_PT_FUP: 954 case INTEL_PT_FUP:
@@ -956,6 +960,12 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
956 intel_pt_update_in_tx(decoder); 960 intel_pt_update_in_tx(decoder);
957 break; 961 break;
958 962
963 case INTEL_PT_MTC:
964 break;
965
966 case INTEL_PT_CYC:
967 case INTEL_PT_VMCS:
968 case INTEL_PT_MNT:
959 case INTEL_PT_PAD: 969 case INTEL_PT_PAD:
960 default: 970 default:
961 break; 971 break;
@@ -983,8 +993,10 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
983 switch (decoder->packet.type) { 993 switch (decoder->packet.type) {
984 case INTEL_PT_TNT: 994 case INTEL_PT_TNT:
985 case INTEL_PT_FUP: 995 case INTEL_PT_FUP:
996 case INTEL_PT_TRACESTOP:
986 case INTEL_PT_PSB: 997 case INTEL_PT_PSB:
987 case INTEL_PT_TSC: 998 case INTEL_PT_TSC:
999 case INTEL_PT_TMA:
988 case INTEL_PT_CBR: 1000 case INTEL_PT_CBR:
989 case INTEL_PT_MODE_TSX: 1001 case INTEL_PT_MODE_TSX:
990 case INTEL_PT_BAD: 1002 case INTEL_PT_BAD:
@@ -1032,13 +1044,21 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
1032 return 0; 1044 return 0;
1033 1045
1034 case INTEL_PT_PIP: 1046 case INTEL_PT_PIP:
1035 decoder->cr3 = decoder->packet.payload; 1047 decoder->cr3 = decoder->packet.payload & (BIT63 - 1);
1048 break;
1049
1050 case INTEL_PT_MTC:
1051 break;
1052
1053 case INTEL_PT_CYC:
1036 break; 1054 break;
1037 1055
1038 case INTEL_PT_MODE_EXEC: 1056 case INTEL_PT_MODE_EXEC:
1039 decoder->exec_mode = decoder->packet.payload; 1057 decoder->exec_mode = decoder->packet.payload;
1040 break; 1058 break;
1041 1059
1060 case INTEL_PT_VMCS:
1061 case INTEL_PT_MNT:
1042 case INTEL_PT_PAD: 1062 case INTEL_PT_PAD:
1043 break; 1063 break;
1044 1064
@@ -1122,6 +1142,9 @@ next:
1122 } 1142 }
1123 return intel_pt_walk_fup_tip(decoder); 1143 return intel_pt_walk_fup_tip(decoder);
1124 1144
1145 case INTEL_PT_TRACESTOP:
1146 break;
1147
1125 case INTEL_PT_PSB: 1148 case INTEL_PT_PSB:
1126 intel_pt_clear_stack(&decoder->stack); 1149 intel_pt_clear_stack(&decoder->stack);
1127 err = intel_pt_walk_psbend(decoder); 1150 err = intel_pt_walk_psbend(decoder);
@@ -1132,13 +1155,22 @@ next:
1132 break; 1155 break;
1133 1156
1134 case INTEL_PT_PIP: 1157 case INTEL_PT_PIP:
1135 decoder->cr3 = decoder->packet.payload; 1158 decoder->cr3 = decoder->packet.payload & (BIT63 - 1);
1159 break;
1160
1161 case INTEL_PT_MTC:
1136 break; 1162 break;
1137 1163
1138 case INTEL_PT_TSC: 1164 case INTEL_PT_TSC:
1139 intel_pt_calc_tsc_timestamp(decoder); 1165 intel_pt_calc_tsc_timestamp(decoder);
1140 break; 1166 break;
1141 1167
1168 case INTEL_PT_TMA:
1169 break;
1170
1171 case INTEL_PT_CYC:
1172 break;
1173
1142 case INTEL_PT_CBR: 1174 case INTEL_PT_CBR:
1143 decoder->cbr = decoder->packet.payload; 1175 decoder->cbr = decoder->packet.payload;
1144 break; 1176 break;
@@ -1162,6 +1194,8 @@ next:
1162 return intel_pt_bug(decoder); 1194 return intel_pt_bug(decoder);
1163 1195
1164 case INTEL_PT_PSBEND: 1196 case INTEL_PT_PSBEND:
1197 case INTEL_PT_VMCS:
1198 case INTEL_PT_MNT:
1165 case INTEL_PT_PAD: 1199 case INTEL_PT_PAD:
1166 break; 1200 break;
1167 1201
@@ -1202,16 +1236,25 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
1202 } 1236 }
1203 break; 1237 break;
1204 1238
1239 case INTEL_PT_MTC:
1240 break;
1241
1205 case INTEL_PT_TSC: 1242 case INTEL_PT_TSC:
1206 intel_pt_calc_tsc_timestamp(decoder); 1243 intel_pt_calc_tsc_timestamp(decoder);
1207 break; 1244 break;
1208 1245
1246 case INTEL_PT_TMA:
1247 break;
1248
1249 case INTEL_PT_CYC:
1250 break;
1251
1209 case INTEL_PT_CBR: 1252 case INTEL_PT_CBR:
1210 decoder->cbr = decoder->packet.payload; 1253 decoder->cbr = decoder->packet.payload;
1211 break; 1254 break;
1212 1255
1213 case INTEL_PT_PIP: 1256 case INTEL_PT_PIP:
1214 decoder->cr3 = decoder->packet.payload; 1257 decoder->cr3 = decoder->packet.payload & (BIT63 - 1);
1215 break; 1258 break;
1216 1259
1217 case INTEL_PT_MODE_EXEC: 1260 case INTEL_PT_MODE_EXEC:
@@ -1222,6 +1265,7 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
1222 intel_pt_update_in_tx(decoder); 1265 intel_pt_update_in_tx(decoder);
1223 break; 1266 break;
1224 1267
1268 case INTEL_PT_TRACESTOP:
1225 case INTEL_PT_TNT: 1269 case INTEL_PT_TNT:
1226 intel_pt_log("ERROR: Unexpected packet\n"); 1270 intel_pt_log("ERROR: Unexpected packet\n");
1227 if (decoder->ip) 1271 if (decoder->ip)
@@ -1240,6 +1284,8 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
1240 return 0; 1284 return 0;
1241 1285
1242 case INTEL_PT_PSB: 1286 case INTEL_PT_PSB:
1287 case INTEL_PT_VMCS:
1288 case INTEL_PT_MNT:
1243 case INTEL_PT_PAD: 1289 case INTEL_PT_PAD:
1244 default: 1290 default:
1245 break; 1291 break;
@@ -1282,16 +1328,25 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
1282 intel_pt_set_last_ip(decoder); 1328 intel_pt_set_last_ip(decoder);
1283 break; 1329 break;
1284 1330
1331 case INTEL_PT_MTC:
1332 break;
1333
1285 case INTEL_PT_TSC: 1334 case INTEL_PT_TSC:
1286 intel_pt_calc_tsc_timestamp(decoder); 1335 intel_pt_calc_tsc_timestamp(decoder);
1287 break; 1336 break;
1288 1337
1338 case INTEL_PT_TMA:
1339 break;
1340
1341 case INTEL_PT_CYC:
1342 break;
1343
1289 case INTEL_PT_CBR: 1344 case INTEL_PT_CBR:
1290 decoder->cbr = decoder->packet.payload; 1345 decoder->cbr = decoder->packet.payload;
1291 break; 1346 break;
1292 1347
1293 case INTEL_PT_PIP: 1348 case INTEL_PT_PIP:
1294 decoder->cr3 = decoder->packet.payload; 1349 decoder->cr3 = decoder->packet.payload & (BIT63 - 1);
1295 break; 1350 break;
1296 1351
1297 case INTEL_PT_MODE_EXEC: 1352 case INTEL_PT_MODE_EXEC:
@@ -1308,6 +1363,9 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
1308 case INTEL_PT_BAD: /* Does not happen */ 1363 case INTEL_PT_BAD: /* Does not happen */
1309 return intel_pt_bug(decoder); 1364 return intel_pt_bug(decoder);
1310 1365
1366 case INTEL_PT_TRACESTOP:
1367 break;
1368
1311 case INTEL_PT_PSB: 1369 case INTEL_PT_PSB:
1312 err = intel_pt_walk_psb(decoder); 1370 err = intel_pt_walk_psb(decoder);
1313 if (err) 1371 if (err)
@@ -1321,6 +1379,8 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
1321 1379
1322 case INTEL_PT_TNT: 1380 case INTEL_PT_TNT:
1323 case INTEL_PT_PSBEND: 1381 case INTEL_PT_PSBEND:
1382 case INTEL_PT_VMCS:
1383 case INTEL_PT_MNT:
1324 case INTEL_PT_PAD: 1384 case INTEL_PT_PAD:
1325 default: 1385 default:
1326 break; 1386 break;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
index 988c82c6652d..b1257c816310 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
@@ -24,6 +24,8 @@
24 24
25#define BIT63 ((uint64_t)1 << 63) 25#define BIT63 ((uint64_t)1 << 63)
26 26
27#define NR_FLAG BIT63
28
27#if __BYTE_ORDER == __BIG_ENDIAN 29#if __BYTE_ORDER == __BIG_ENDIAN
28#define le16_to_cpu bswap_16 30#define le16_to_cpu bswap_16
29#define le32_to_cpu bswap_32 31#define le32_to_cpu bswap_32
@@ -46,15 +48,21 @@ static const char * const packet_name[] = {
46 [INTEL_PT_TIP_PGD] = "TIP.PGD", 48 [INTEL_PT_TIP_PGD] = "TIP.PGD",
47 [INTEL_PT_TIP_PGE] = "TIP.PGE", 49 [INTEL_PT_TIP_PGE] = "TIP.PGE",
48 [INTEL_PT_TSC] = "TSC", 50 [INTEL_PT_TSC] = "TSC",
51 [INTEL_PT_TMA] = "TMA",
49 [INTEL_PT_MODE_EXEC] = "MODE.Exec", 52 [INTEL_PT_MODE_EXEC] = "MODE.Exec",
50 [INTEL_PT_MODE_TSX] = "MODE.TSX", 53 [INTEL_PT_MODE_TSX] = "MODE.TSX",
54 [INTEL_PT_MTC] = "MTC",
51 [INTEL_PT_TIP] = "TIP", 55 [INTEL_PT_TIP] = "TIP",
52 [INTEL_PT_FUP] = "FUP", 56 [INTEL_PT_FUP] = "FUP",
57 [INTEL_PT_CYC] = "CYC",
58 [INTEL_PT_VMCS] = "VMCS",
53 [INTEL_PT_PSB] = "PSB", 59 [INTEL_PT_PSB] = "PSB",
54 [INTEL_PT_PSBEND] = "PSBEND", 60 [INTEL_PT_PSBEND] = "PSBEND",
55 [INTEL_PT_CBR] = "CBR", 61 [INTEL_PT_CBR] = "CBR",
62 [INTEL_PT_TRACESTOP] = "TraceSTOP",
56 [INTEL_PT_PIP] = "PIP", 63 [INTEL_PT_PIP] = "PIP",
57 [INTEL_PT_OVF] = "OVF", 64 [INTEL_PT_OVF] = "OVF",
65 [INTEL_PT_MNT] = "MNT",
58}; 66};
59 67
60const char *intel_pt_pkt_name(enum intel_pt_pkt_type type) 68const char *intel_pt_pkt_name(enum intel_pt_pkt_type type)
@@ -96,10 +104,18 @@ static int intel_pt_get_pip(const unsigned char *buf, size_t len,
96 packet->type = INTEL_PT_PIP; 104 packet->type = INTEL_PT_PIP;
97 memcpy_le64(&payload, buf + 2, 6); 105 memcpy_le64(&payload, buf + 2, 6);
98 packet->payload = payload >> 1; 106 packet->payload = payload >> 1;
107 if (payload & 1)
108 packet->payload |= NR_FLAG;
99 109
100 return 8; 110 return 8;
101} 111}
102 112
113static int intel_pt_get_tracestop(struct intel_pt_pkt *packet)
114{
115 packet->type = INTEL_PT_TRACESTOP;
116 return 2;
117}
118
103static int intel_pt_get_cbr(const unsigned char *buf, size_t len, 119static int intel_pt_get_cbr(const unsigned char *buf, size_t len,
104 struct intel_pt_pkt *packet) 120 struct intel_pt_pkt *packet)
105{ 121{
@@ -110,6 +126,24 @@ static int intel_pt_get_cbr(const unsigned char *buf, size_t len,
110 return 4; 126 return 4;
111} 127}
112 128
129static int intel_pt_get_vmcs(const unsigned char *buf, size_t len,
130 struct intel_pt_pkt *packet)
131{
132 unsigned int count = (52 - 5) >> 3;
133
134 if (count < 1 || count > 7)
135 return INTEL_PT_BAD_PACKET;
136
137 if (len < count + 2)
138 return INTEL_PT_NEED_MORE_BYTES;
139
140 packet->type = INTEL_PT_VMCS;
141 packet->count = count;
142 memcpy_le64(&packet->payload, buf + 2, count);
143
144 return count + 2;
145}
146
113static int intel_pt_get_ovf(struct intel_pt_pkt *packet) 147static int intel_pt_get_ovf(struct intel_pt_pkt *packet)
114{ 148{
115 packet->type = INTEL_PT_OVF; 149 packet->type = INTEL_PT_OVF;
@@ -139,12 +173,49 @@ static int intel_pt_get_psbend(struct intel_pt_pkt *packet)
139 return 2; 173 return 2;
140} 174}
141 175
176static int intel_pt_get_tma(const unsigned char *buf, size_t len,
177 struct intel_pt_pkt *packet)
178{
179 if (len < 7)
180 return INTEL_PT_NEED_MORE_BYTES;
181
182 packet->type = INTEL_PT_TMA;
183 packet->payload = buf[2] | (buf[3] << 8);
184 packet->count = buf[5] | ((buf[6] & BIT(0)) << 8);
185 return 7;
186}
187
142static int intel_pt_get_pad(struct intel_pt_pkt *packet) 188static int intel_pt_get_pad(struct intel_pt_pkt *packet)
143{ 189{
144 packet->type = INTEL_PT_PAD; 190 packet->type = INTEL_PT_PAD;
145 return 1; 191 return 1;
146} 192}
147 193
194static int intel_pt_get_mnt(const unsigned char *buf, size_t len,
195 struct intel_pt_pkt *packet)
196{
197 if (len < 11)
198 return INTEL_PT_NEED_MORE_BYTES;
199 packet->type = INTEL_PT_MNT;
200 memcpy_le64(&packet->payload, buf + 3, 8);
201 return 11
202;
203}
204
205static int intel_pt_get_3byte(const unsigned char *buf, size_t len,
206 struct intel_pt_pkt *packet)
207{
208 if (len < 3)
209 return INTEL_PT_NEED_MORE_BYTES;
210
211 switch (buf[2]) {
212 case 0x88: /* MNT */
213 return intel_pt_get_mnt(buf, len, packet);
214 default:
215 return INTEL_PT_BAD_PACKET;
216 }
217}
218
148static int intel_pt_get_ext(const unsigned char *buf, size_t len, 219static int intel_pt_get_ext(const unsigned char *buf, size_t len,
149 struct intel_pt_pkt *packet) 220 struct intel_pt_pkt *packet)
150{ 221{
@@ -156,14 +227,22 @@ static int intel_pt_get_ext(const unsigned char *buf, size_t len,
156 return intel_pt_get_long_tnt(buf, len, packet); 227 return intel_pt_get_long_tnt(buf, len, packet);
157 case 0x43: /* PIP */ 228 case 0x43: /* PIP */
158 return intel_pt_get_pip(buf, len, packet); 229 return intel_pt_get_pip(buf, len, packet);
230 case 0x83: /* TraceStop */
231 return intel_pt_get_tracestop(packet);
159 case 0x03: /* CBR */ 232 case 0x03: /* CBR */
160 return intel_pt_get_cbr(buf, len, packet); 233 return intel_pt_get_cbr(buf, len, packet);
234 case 0xc8: /* VMCS */
235 return intel_pt_get_vmcs(buf, len, packet);
161 case 0xf3: /* OVF */ 236 case 0xf3: /* OVF */
162 return intel_pt_get_ovf(packet); 237 return intel_pt_get_ovf(packet);
163 case 0x82: /* PSB */ 238 case 0x82: /* PSB */
164 return intel_pt_get_psb(buf, len, packet); 239 return intel_pt_get_psb(buf, len, packet);
165 case 0x23: /* PSBEND */ 240 case 0x23: /* PSBEND */
166 return intel_pt_get_psbend(packet); 241 return intel_pt_get_psbend(packet);
242 case 0x73: /* TMA */
243 return intel_pt_get_tma(buf, len, packet);
244 case 0xC3: /* 3-byte header */
245 return intel_pt_get_3byte(buf, len, packet);
167 default: 246 default:
168 return INTEL_PT_BAD_PACKET; 247 return INTEL_PT_BAD_PACKET;
169 } 248 }
@@ -187,6 +266,28 @@ static int intel_pt_get_short_tnt(unsigned int byte,
187 return 1; 266 return 1;
188} 267}
189 268
269static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
270 size_t len, struct intel_pt_pkt *packet)
271{
272 unsigned int offs = 1, shift;
273 uint64_t payload = byte >> 3;
274
275 byte >>= 2;
276 len -= 1;
277 for (shift = 5; byte & 1; shift += 7) {
278 if (offs > 9)
279 return INTEL_PT_BAD_PACKET;
280 if (len < offs)
281 return INTEL_PT_NEED_MORE_BYTES;
282 byte = buf[offs++];
283 payload |= (byte >> 1) << shift;
284 }
285
286 packet->type = INTEL_PT_CYC;
287 packet->payload = payload;
288 return offs;
289}
290
190static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte, 291static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte,
191 const unsigned char *buf, size_t len, 292 const unsigned char *buf, size_t len,
192 struct intel_pt_pkt *packet) 293 struct intel_pt_pkt *packet)
@@ -269,6 +370,16 @@ static int intel_pt_get_tsc(const unsigned char *buf, size_t len,
269 return 8; 370 return 8;
270} 371}
271 372
373static int intel_pt_get_mtc(const unsigned char *buf, size_t len,
374 struct intel_pt_pkt *packet)
375{
376 if (len < 2)
377 return INTEL_PT_NEED_MORE_BYTES;
378 packet->type = INTEL_PT_MTC;
379 packet->payload = buf[1];
380 return 2;
381}
382
272static int intel_pt_do_get_packet(const unsigned char *buf, size_t len, 383static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
273 struct intel_pt_pkt *packet) 384 struct intel_pt_pkt *packet)
274{ 385{
@@ -288,6 +399,9 @@ static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
288 return intel_pt_get_short_tnt(byte, packet); 399 return intel_pt_get_short_tnt(byte, packet);
289 } 400 }
290 401
402 if ((byte & 2))
403 return intel_pt_get_cyc(byte, buf, len, packet);
404
291 switch (byte & 0x1f) { 405 switch (byte & 0x1f) {
292 case 0x0D: 406 case 0x0D:
293 return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet); 407 return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet);
@@ -305,6 +419,8 @@ static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
305 return intel_pt_get_mode(buf, len, packet); 419 return intel_pt_get_mode(buf, len, packet);
306 case 0x19: 420 case 0x19:
307 return intel_pt_get_tsc(buf, len, packet); 421 return intel_pt_get_tsc(buf, len, packet);
422 case 0x59:
423 return intel_pt_get_mtc(buf, len, packet);
308 default: 424 default:
309 return INTEL_PT_BAD_PACKET; 425 return INTEL_PT_BAD_PACKET;
310 } 426 }
@@ -329,7 +445,7 @@ int intel_pt_get_packet(const unsigned char *buf, size_t len,
329int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf, 445int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
330 size_t buf_len) 446 size_t buf_len)
331{ 447{
332 int ret, i; 448 int ret, i, nr;
333 unsigned long long payload = packet->payload; 449 unsigned long long payload = packet->payload;
334 const char *name = intel_pt_pkt_name(packet->type); 450 const char *name = intel_pt_pkt_name(packet->type);
335 451
@@ -338,6 +454,7 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
338 case INTEL_PT_PAD: 454 case INTEL_PT_PAD:
339 case INTEL_PT_PSB: 455 case INTEL_PT_PSB:
340 case INTEL_PT_PSBEND: 456 case INTEL_PT_PSBEND:
457 case INTEL_PT_TRACESTOP:
341 case INTEL_PT_OVF: 458 case INTEL_PT_OVF:
342 return snprintf(buf, buf_len, "%s", name); 459 return snprintf(buf, buf_len, "%s", name);
343 case INTEL_PT_TNT: { 460 case INTEL_PT_TNT: {
@@ -371,17 +488,16 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
371 case INTEL_PT_FUP: 488 case INTEL_PT_FUP:
372 if (!(packet->count)) 489 if (!(packet->count))
373 return snprintf(buf, buf_len, "%s no ip", name); 490 return snprintf(buf, buf_len, "%s no ip", name);
491 case INTEL_PT_CYC:
492 case INTEL_PT_VMCS:
493 case INTEL_PT_MTC:
494 case INTEL_PT_MNT:
374 case INTEL_PT_CBR: 495 case INTEL_PT_CBR:
375 return snprintf(buf, buf_len, "%s 0x%llx", name, payload);
376 case INTEL_PT_TSC: 496 case INTEL_PT_TSC:
377 if (packet->count) 497 return snprintf(buf, buf_len, "%s 0x%llx", name, payload);
378 return snprintf(buf, buf_len, 498 case INTEL_PT_TMA:
379 "%s 0x%llx CTC 0x%x FC 0x%x", 499 return snprintf(buf, buf_len, "%s CTC 0x%x FC 0x%x", name,
380 name, payload, packet->count & 0xffff, 500 (unsigned)payload, packet->count);
381 (packet->count >> 16) & 0x1ff);
382 else
383 return snprintf(buf, buf_len, "%s 0x%llx",
384 name, payload);
385 case INTEL_PT_MODE_EXEC: 501 case INTEL_PT_MODE_EXEC:
386 return snprintf(buf, buf_len, "%s %lld", name, payload); 502 return snprintf(buf, buf_len, "%s %lld", name, payload);
387 case INTEL_PT_MODE_TSX: 503 case INTEL_PT_MODE_TSX:
@@ -389,8 +505,10 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
389 name, (unsigned)(payload >> 1) & 1, 505 name, (unsigned)(payload >> 1) & 1,
390 (unsigned)payload & 1); 506 (unsigned)payload & 1);
391 case INTEL_PT_PIP: 507 case INTEL_PT_PIP:
392 ret = snprintf(buf, buf_len, "%s 0x%llx", 508 nr = packet->payload & NR_FLAG ? 1 : 0;
393 name, payload); 509 payload &= ~NR_FLAG;
510 ret = snprintf(buf, buf_len, "%s 0x%llx (NR=%d)",
511 name, payload, nr);
394 return ret; 512 return ret;
395 default: 513 default:
396 break; 514 break;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h
index 53404fa942b3..781bb79883bd 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h
@@ -37,15 +37,21 @@ enum intel_pt_pkt_type {
37 INTEL_PT_TIP_PGD, 37 INTEL_PT_TIP_PGD,
38 INTEL_PT_TIP_PGE, 38 INTEL_PT_TIP_PGE,
39 INTEL_PT_TSC, 39 INTEL_PT_TSC,
40 INTEL_PT_TMA,
40 INTEL_PT_MODE_EXEC, 41 INTEL_PT_MODE_EXEC,
41 INTEL_PT_MODE_TSX, 42 INTEL_PT_MODE_TSX,
43 INTEL_PT_MTC,
42 INTEL_PT_TIP, 44 INTEL_PT_TIP,
43 INTEL_PT_FUP, 45 INTEL_PT_FUP,
46 INTEL_PT_CYC,
47 INTEL_PT_VMCS,
44 INTEL_PT_PSB, 48 INTEL_PT_PSB,
45 INTEL_PT_PSBEND, 49 INTEL_PT_PSBEND,
46 INTEL_PT_CBR, 50 INTEL_PT_CBR,
51 INTEL_PT_TRACESTOP,
47 INTEL_PT_PIP, 52 INTEL_PT_PIP,
48 INTEL_PT_OVF, 53 INTEL_PT_OVF,
54 INTEL_PT_MNT,
49}; 55};
50 56
51struct intel_pt_pkt { 57struct intel_pt_pkt {