20 #include <linux/compiler.h> 24 #define BIT(n) (1 << (n)) 26 #define BIT63 ((uint64_t)1 << 63) 30 #if __BYTE_ORDER == __BIG_ENDIAN 31 #define le16_to_cpu bswap_16 32 #define le32_to_cpu bswap_32 33 #define le64_to_cpu bswap_64 34 #define memcpy_le64(d, s, n) do { \ 35 memcpy((d), (s), (n)); \ 36 *(d) = le64_to_cpu(*(d)); \ 42 #define memcpy_le64 memcpy 92 for (count = 47; count; count--) {
99 packet->
count = count;
100 packet->
payload = payload << 1;
107 uint64_t payload = 0;
114 packet->
payload = payload >> 1;
140 unsigned int count = (52 - 5) >> 3;
142 if (count < 1 || count > 7)
149 packet->
count = count;
169 for (i = 2; i < 16; i += 2) {
170 if (buf[i] != 2 || buf[i + 1] != 0x82)
191 packet->
payload = buf[2] | (buf[3] << 8);
192 packet->
count = buf[5] | ((buf[6] &
BIT(0)) << 8);
230 packet->
count = (buf[1] >> 5) & 0x3;
234 switch (packet->
count) {
298 if ((buf[1] & 0x1f) == 0x12)
342 for (count = 6; count; count--) {
349 packet->
count = count;
350 packet->
payload = (uint64_t)byte << 57;
358 unsigned int offs = 1, shift;
359 uint64_t payload = byte >> 3;
363 for (shift = 5; byte & 1; shift += 7) {
369 payload |= (byte >> 1) << shift;
378 const unsigned char *
buf,
size_t len,
383 packet->
count = byte >> 5;
385 switch (packet->
count) {
429 switch (buf[1] >> 5) {
432 switch (buf[1] & 3) {
448 if ((buf[1] & 3) == 3)
490 if (!(byte &
BIT(0))) {
501 switch (byte & 0x1f) {
535 while (ret < 8 && len > (
size_t)ret && !buf[ret])
545 unsigned long long payload = packet->
payload;
548 switch (packet->
type) {
555 return snprintf(buf, buf_len,
"%s", name);
557 size_t blen = buf_len;
559 ret = snprintf(buf, blen,
"%s ", name);
564 for (i = 0; i < packet->
count; i++) {
566 ret = snprintf(buf, blen,
"T");
568 ret = snprintf(buf, blen,
"N");
575 ret = snprintf(buf, blen,
" (%d)", packet->
count);
579 return buf_len - blen;
585 if (!(packet->
count))
586 return snprintf(buf, buf_len,
"%s no ip", name);
594 return snprintf(buf, buf_len,
"%s 0x%llx", name, payload);
596 return snprintf(buf, buf_len,
"%s CTC 0x%x FC 0x%x", name,
597 (
unsigned)payload, packet->
count);
599 return snprintf(buf, buf_len,
"%s %lld", name, payload);
601 return snprintf(buf, buf_len,
"%s TXAbort:%u InTX:%u",
602 name, (
unsigned)(payload >> 1) & 1,
603 (
unsigned)payload & 1);
607 ret = snprintf(buf, buf_len,
"%s 0x%llx (NR=%d)",
611 return snprintf(buf, buf_len,
"%s 0x%llx IP:0", name, payload);
613 return snprintf(buf, buf_len,
"%s 0x%llx IP:1", name, payload);
615 return snprintf(buf, buf_len,
"%s IP:0", name);
617 return snprintf(buf, buf_len,
"%s IP:1", name);
619 return snprintf(buf, buf_len,
"%s 0x%llx Hints 0x%x Extensions 0x%x",
620 name, payload, (
unsigned int)(payload & 0xff),
621 (
unsigned int)((payload >> 32) & 0x3));
623 return snprintf(buf, buf_len,
"%s 0x%llx HW:%u CState:%u Sub-CState:%u",
624 name, payload, !!(payload & 0x80),
625 (
unsigned int)((payload >> 12) & 0xf),
626 (
unsigned int)((payload >> 8) & 0xf));
628 return snprintf(buf, buf_len,
"%s 0x%llx Last CState:%u Deepest CState:%u Wake Reason 0x%x",
630 (
unsigned int)((payload >> 4) & 0xf),
631 (
unsigned int)(payload & 0xf),
632 (
unsigned int)((payload >> 8) & 0xf));
636 return snprintf(buf, buf_len,
"%s 0x%llx (%d)",
637 name, payload, packet->
count);
const char * intel_pt_pkt_name(enum intel_pt_pkt_type type)
static int intel_pt_get_short_tnt(unsigned int byte, struct intel_pt_pkt *packet)
static int intel_pt_do_get_packet(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_cbr(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_ovf(struct intel_pt_pkt *packet)
int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf, size_t buf_len)
static int intel_pt_get_pad(struct intel_pt_pkt *packet)
static int intel_pt_get_3byte(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_psb(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_mtc(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_ext(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_pwrx(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
#define memcpy_le64(d, s, n)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
unsigned char buf[INTEL_PT_INSN_BUF_SZ]
static int intel_pt_get_tsc(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_vmcs(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
int intel_pt_get_packet(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_mwait(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_psbend(struct intel_pt_pkt *packet)
static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_long_tnt(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_tracestop(struct intel_pt_pkt *packet)
static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte, const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static const char *const packet_name[]
static int intel_pt_get_pwre(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
#define INTEL_PT_NEED_MORE_BYTES
static int intel_pt_get_tma(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
#define INTEL_PT_BAD_PACKET
static int intel_pt_get_mnt(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_exstop_ip(struct intel_pt_pkt *packet)
static int intel_pt_get_exstop(struct intel_pt_pkt *packet)
enum intel_pt_pkt_type type
static int intel_pt_get_ptwrite(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_mode(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)
static int intel_pt_get_pip(const unsigned char *buf, size_t len, struct intel_pt_pkt *packet)