diff options
Diffstat (limited to 'tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c')
-rw-r--r-- | tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c | 24 |
1 files changed, 17 insertions, 7 deletions
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 b1257c816310..4f7b32020487 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 | |||
@@ -292,36 +292,46 @@ static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte, | |||
292 | const unsigned char *buf, size_t len, | 292 | const unsigned char *buf, size_t len, |
293 | struct intel_pt_pkt *packet) | 293 | struct intel_pt_pkt *packet) |
294 | { | 294 | { |
295 | switch (byte >> 5) { | 295 | int ip_len; |
296 | |||
297 | packet->count = byte >> 5; | ||
298 | |||
299 | switch (packet->count) { | ||
296 | case 0: | 300 | case 0: |
297 | packet->count = 0; | 301 | ip_len = 0; |
298 | break; | 302 | break; |
299 | case 1: | 303 | case 1: |
300 | if (len < 3) | 304 | if (len < 3) |
301 | return INTEL_PT_NEED_MORE_BYTES; | 305 | return INTEL_PT_NEED_MORE_BYTES; |
302 | packet->count = 2; | 306 | ip_len = 2; |
303 | packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1)); | 307 | packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1)); |
304 | break; | 308 | break; |
305 | case 2: | 309 | case 2: |
306 | if (len < 5) | 310 | if (len < 5) |
307 | return INTEL_PT_NEED_MORE_BYTES; | 311 | return INTEL_PT_NEED_MORE_BYTES; |
308 | packet->count = 4; | 312 | ip_len = 4; |
309 | packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1)); | 313 | packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1)); |
310 | break; | 314 | break; |
311 | case 3: | 315 | case 3: |
312 | case 6: | 316 | case 4: |
313 | if (len < 7) | 317 | if (len < 7) |
314 | return INTEL_PT_NEED_MORE_BYTES; | 318 | return INTEL_PT_NEED_MORE_BYTES; |
315 | packet->count = 6; | 319 | ip_len = 6; |
316 | memcpy_le64(&packet->payload, buf + 1, 6); | 320 | memcpy_le64(&packet->payload, buf + 1, 6); |
317 | break; | 321 | break; |
322 | case 6: | ||
323 | if (len < 9) | ||
324 | return INTEL_PT_NEED_MORE_BYTES; | ||
325 | ip_len = 8; | ||
326 | packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1)); | ||
327 | break; | ||
318 | default: | 328 | default: |
319 | return INTEL_PT_BAD_PACKET; | 329 | return INTEL_PT_BAD_PACKET; |
320 | } | 330 | } |
321 | 331 | ||
322 | packet->type = type; | 332 | packet->type = type; |
323 | 333 | ||
324 | return packet->count + 1; | 334 | return ip_len + 1; |
325 | } | 335 | } |
326 | 336 | ||
327 | static int intel_pt_get_mode(const unsigned char *buf, size_t len, | 337 | static int intel_pt_get_mode(const unsigned char *buf, size_t len, |