switch (ctx) { case INTEL_PT_NO_CTX: break; case INTEL_PT_BLK_4_CTX: if ((byte & 0x7) == 4) return intel_pt_get_bip_4(buf, len, packet); break; case INTEL_PT_BLK_8_CTX: if ((byte & 0x7) == 4) return intel_pt_get_bip_8(buf, len, packet); break; default: break;
}
if (!(byte & BIT(0))) { if (byte == 0) return intel_pt_get_pad(packet); if (byte == 2) return intel_pt_get_ext(buf, len, packet); return intel_pt_get_short_tnt(byte, packet);
}
if ((byte & 2)) return intel_pt_get_cyc(byte, buf, len, packet);
switch (byte & 0x1f) { case 0x0D: return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet); case 0x11: return intel_pt_get_ip(INTEL_PT_TIP_PGE, byte, buf, len,
packet); case 0x01: return intel_pt_get_ip(INTEL_PT_TIP_PGD, byte, buf, len,
packet); case 0x1D: return intel_pt_get_ip(INTEL_PT_FUP, byte, buf, len, packet); case 0x19: switch (byte) { case 0x99: return intel_pt_get_mode(buf, len, packet); case 0x19: return intel_pt_get_tsc(buf, len, packet); case 0x59: return intel_pt_get_mtc(buf, len, packet); default: return INTEL_PT_BAD_PACKET;
} default: return INTEL_PT_BAD_PACKET;
}
}
void intel_pt_upd_pkt_ctx(conststruct intel_pt_pkt *packet, enum intel_pt_pkt_ctx *ctx)
{ switch (packet->type) { case INTEL_PT_BAD: case INTEL_PT_PAD: case INTEL_PT_TSC: case INTEL_PT_TMA: case INTEL_PT_MTC: case INTEL_PT_FUP: case INTEL_PT_CYC: case INTEL_PT_CBR: case INTEL_PT_MNT: case INTEL_PT_EXSTOP: case INTEL_PT_EXSTOP_IP: case INTEL_PT_PWRE: case INTEL_PT_PWRX: case INTEL_PT_BIP: break; case INTEL_PT_TNT: case INTEL_PT_TIP: case INTEL_PT_TIP_PGD: case INTEL_PT_TIP_PGE: case INTEL_PT_MODE_EXEC: case INTEL_PT_MODE_TSX: case INTEL_PT_PIP: case INTEL_PT_OVF: case INTEL_PT_VMCS: case INTEL_PT_TRACESTOP: case INTEL_PT_PSB: case INTEL_PT_PSBEND: case INTEL_PT_PTWRITE: case INTEL_PT_PTWRITE_IP: case INTEL_PT_MWAIT: case INTEL_PT_BEP: case INTEL_PT_BEP_IP: case INTEL_PT_CFE: case INTEL_PT_CFE_IP: case INTEL_PT_EVD:
*ctx = INTEL_PT_NO_CTX; break; case INTEL_PT_BBP: if (packet->count)
*ctx = INTEL_PT_BLK_4_CTX; else
*ctx = INTEL_PT_BLK_8_CTX; break; default: break;
}
}
int intel_pt_get_packet(constunsignedchar *buf, size_t len, struct intel_pt_pkt *packet, enum intel_pt_pkt_ctx *ctx)
{ int ret;
ret = intel_pt_do_get_packet(buf, len, packet, *ctx); if (ret > 0) { while (ret < 8 && len > (size_t)ret && !buf[ret])
ret += 1;
intel_pt_upd_pkt_ctx(packet, ctx);
} return ret;
}
int intel_pt_pkt_desc(conststruct intel_pt_pkt *packet, char *buf,
size_t buf_len)
{ int ret, i, nr; unsignedlonglong payload = packet->payload; constchar *name = intel_pt_pkt_name(packet->type);
switch (packet->type) { case INTEL_PT_BAD: case INTEL_PT_PAD: case INTEL_PT_PSB: case INTEL_PT_PSBEND: case INTEL_PT_TRACESTOP: case INTEL_PT_OVF: return snprintf(buf, buf_len, "%s", name); case INTEL_PT_TNT: {
size_t blen = buf_len;
ret = snprintf(buf, blen, "%s ", name); if (ret < 0) return ret;
buf += ret;
blen -= ret; for (i = 0; i < packet->count; i++) { if (payload & BIT63)
ret = snprintf(buf, blen, "T"); else
ret = snprintf(buf, blen, "N"); if (ret < 0) return ret;
buf += ret;
blen -= ret;
payload <<= 1;
}
ret = snprintf(buf, blen, " (%d)", packet->count); if (ret < 0) return ret;
blen -= ret; return buf_len - blen;
} case INTEL_PT_TIP_PGD: case INTEL_PT_TIP_PGE: case INTEL_PT_TIP: case INTEL_PT_FUP: if (!(packet->count)) return snprintf(buf, buf_len, "%s no ip", name);
fallthrough; case INTEL_PT_CYC: case INTEL_PT_VMCS: case INTEL_PT_MTC: case INTEL_PT_MNT: case INTEL_PT_CBR: case INTEL_PT_TSC: return snprintf(buf, buf_len, "%s 0x%llx", name, payload); case INTEL_PT_TMA: return snprintf(buf, buf_len, "%s CTC 0x%x FC 0x%x", name,
(unsigned)payload, packet->count); case INTEL_PT_MODE_EXEC: return snprintf(buf, buf_len, "%s IF:%d %lld",
name, !!(packet->count & 4), payload); case INTEL_PT_MODE_TSX: return snprintf(buf, buf_len, "%s TXAbort:%u InTX:%u",
name, (unsigned)(payload >> 1) & 1,
(unsigned)payload & 1); case INTEL_PT_PIP:
nr = packet->payload & INTEL_PT_VMX_NR_FLAG ? 1 : 0;
payload &= ~INTEL_PT_VMX_NR_FLAG;
ret = snprintf(buf, buf_len, "%s 0x%llx (NR=%d)",
name, payload >> 1, nr); return ret; case INTEL_PT_PTWRITE: return snprintf(buf, buf_len, "%s 0x%llx IP:0", name, payload); case INTEL_PT_PTWRITE_IP: return snprintf(buf, buf_len, "%s 0x%llx IP:1", name, payload); case INTEL_PT_BEP: case INTEL_PT_EXSTOP: return snprintf(buf, buf_len, "%s IP:0", name); case INTEL_PT_BEP_IP: case INTEL_PT_EXSTOP_IP: return snprintf(buf, buf_len, "%s IP:1", name); case INTEL_PT_MWAIT: return snprintf(buf, buf_len, "%s 0x%llx Hints 0x%x Extensions 0x%x",
name, payload, (unsignedint)(payload & 0xff),
(unsignedint)((payload >> 32) & 0x3)); case INTEL_PT_PWRE: return snprintf(buf, buf_len, "%s 0x%llx HW:%u CState:%u Sub-CState:%u",
name, payload, !!(payload & 0x80),
(unsignedint)((payload >> 12) & 0xf),
(unsignedint)((payload >> 8) & 0xf)); case INTEL_PT_PWRX: return snprintf(buf, buf_len, "%s 0x%llx Last CState:%u Deepest CState:%u Wake Reason 0x%x",
name, payload,
(unsignedint)((payload >> 4) & 0xf),
(unsignedint)(payload & 0xf),
(unsignedint)((payload >> 8) & 0xf)); case INTEL_PT_BBP: return snprintf(buf, buf_len, "%s SZ %s-byte Type 0x%llx",
name, packet->count ? "4" : "8", payload); case INTEL_PT_BIP: return snprintf(buf, buf_len, "%s ID 0x%02x Value 0x%llx",
name, packet->count, payload); case INTEL_PT_CFE: case INTEL_PT_CFE_IP: return snprintf(buf, buf_len, "%s IP:%d Type 0x%02x Vector 0x%llx",
name, packet->type == INTEL_PT_CFE_IP, packet->count, payload); case INTEL_PT_EVD: return snprintf(buf, buf_len, "%s Type 0x%02x Payload 0x%llx",
name, packet->count, payload); default: break;
} return snprintf(buf, buf_len, "%s 0x%llx (%d)",
name, payload, packet->count);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.