14 #define BIT(n) (1ULL << (n)) 16 #define NS_FLAG BIT(63) 17 #define EL_FLAG (BIT(62) | BIT(61)) 19 #define SPE_HEADER0_PAD 0x0 20 #define SPE_HEADER0_END 0x1 21 #define SPE_HEADER0_ADDRESS 0x30 22 #define SPE_HEADER0_ADDRESS_MASK 0x38 23 #define SPE_HEADER0_COUNTER 0x18 24 #define SPE_HEADER0_COUNTER_MASK 0x38 25 #define SPE_HEADER0_TIMESTAMP 0x71 26 #define SPE_HEADER0_TIMESTAMP 0x71 27 #define SPE_HEADER0_EVENTS 0x2 28 #define SPE_HEADER0_EVENTS_MASK 0xf 29 #define SPE_HEADER0_SOURCE 0x3 30 #define SPE_HEADER0_SOURCE_MASK 0xf 31 #define SPE_HEADER0_CONTEXT 0x24 32 #define SPE_HEADER0_CONTEXT_MASK 0x3c 33 #define SPE_HEADER0_OP_TYPE 0x8 34 #define SPE_HEADER0_OP_TYPE_MASK 0x3c 35 #define SPE_HEADER1_ALIGNMENT 0x0 36 #define SPE_HEADER1_ADDRESS 0xb0 37 #define SPE_HEADER1_ADDRESS_MASK 0xf8 38 #define SPE_HEADER1_COUNTER 0x98 39 #define SPE_HEADER1_COUNTER_MASK 0xf8 41 #if __BYTE_ORDER == __BIG_ENDIAN 42 #define le16_to_cpu bswap_16 43 #define le32_to_cpu bswap_32 44 #define le64_to_cpu bswap_64 45 #define memcpy_le64(d, s, n) do { \ 46 memcpy((d), (s), (n)); \ 47 *(d) = le64_to_cpu(*(d)); \ 53 #define memcpy_le64 memcpy 82 return 1 << ((byte & 0x30) >> 4);
90 if (len < 1 + payload_len)
95 switch (payload_len) {
96 case 1: packet->
payload = *(uint8_t *)buf;
break;
103 return 1 + payload_len;
115 unsigned int alignment = 1 << ((buf[0] & 0xf) + 1);
121 return alignment - (((uintptr_t)buf) & (alignment - 1));
149 packet->
index = ret - 1;
165 packet->
index = buf[0] & 0x3;
174 packet->
index = buf[0] & 0x3;
179 const unsigned char ext_hdr,
struct arm_spe_pkt *packet)
186 packet->
index = ((buf[0] & 0x3) << 3) | (buf[1] & 0x7);
188 packet->
index = buf[0] & 0x7;
192 return 1 + ext_hdr + 2;
196 const unsigned char ext_hdr,
struct arm_spe_pkt *packet)
203 packet->
index = ((buf[0] & 0x3) << 3) | (buf[1] & 0x7);
205 packet->
index = buf[0] & 0x7;
209 return 1 + ext_hdr + 8;
227 else if (byte & 0xc0 ) {
244 }
else if ((byte & 0xe0) == 0x20 ) {
268 while (ret < 16 && len > (
size_t)ret && !buf[ret])
277 int ret,
ns, el, idx = packet->
index;
278 unsigned long long payload = packet->
payload;
281 switch (packet->
type) {
285 return snprintf(buf, buf_len,
"%s", name);
287 size_t blen = buf_len;
290 ret = snprintf(buf, buf_len,
"EV");
294 ret = snprintf(buf, buf_len,
" EXCEPTION-GEN");
299 ret = snprintf(buf, buf_len,
" RETIRED");
304 ret = snprintf(buf, buf_len,
" L1D-ACCESS");
309 ret = snprintf(buf, buf_len,
" L1D-REFILL");
313 if (payload & 0x10) {
314 ret = snprintf(buf, buf_len,
" TLB-ACCESS");
318 if (payload & 0x20) {
319 ret = snprintf(buf, buf_len,
" TLB-REFILL");
323 if (payload & 0x40) {
324 ret = snprintf(buf, buf_len,
" NOT-TAKEN");
328 if (payload & 0x80) {
329 ret = snprintf(buf, buf_len,
" MISPRED");
334 if (payload & 0x100) {
335 ret = snprintf(buf, buf_len,
" LLC-ACCESS");
339 if (payload & 0x200) {
340 ret = snprintf(buf, buf_len,
" LLC-REFILL");
344 if (payload & 0x400) {
345 ret = snprintf(buf, buf_len,
" REMOTE-ACCESS");
353 return buf_len - blen;
357 case 0:
return snprintf(buf, buf_len,
"%s", payload & 0x1 ?
358 "COND-SELECT" :
"INSN-OTHER");
360 size_t blen = buf_len;
363 ret = snprintf(buf, buf_len,
"ST");
365 ret = snprintf(buf, buf_len,
"LD");
370 ret = snprintf(buf, buf_len,
" AT");
375 ret = snprintf(buf, buf_len,
" EXCL");
379 if (payload & 0x10) {
380 ret = snprintf(buf, buf_len,
" AR");
384 }
else if (payload & 0x4) {
385 ret = snprintf(buf, buf_len,
" SIMD-FP");
392 return buf_len - blen;
395 size_t blen = buf_len;
397 ret = snprintf(buf, buf_len,
"B");
401 ret = snprintf(buf, buf_len,
" COND");
406 ret = snprintf(buf, buf_len,
" IND");
413 return buf_len - blen;
419 return snprintf(buf, buf_len,
"%s %lld", name, payload);
425 payload &= ~(0xffULL << 56);
426 return snprintf(buf, buf_len,
"%s 0x%llx el%d ns=%d",
427 (idx == 1) ?
"TGT" :
"PC", payload, el, ns);
428 case 2:
return snprintf(buf, buf_len,
"VA 0x%llx", payload);
430 payload &= ~(0xffULL << 56);
431 return snprintf(buf, buf_len,
"PA 0x%llx ns=%d",
436 return snprintf(buf, buf_len,
"%s 0x%lx el%d", name,
437 (
unsigned long)payload, idx + 1);
439 size_t blen = buf_len;
441 ret = snprintf(buf, buf_len,
"%s %d ", name,
442 (
unsigned short)payload);
446 case 0: ret = snprintf(buf, buf_len,
"TOT");
break;
447 case 1: ret = snprintf(buf, buf_len,
"ISSUE");
break;
448 case 2: ret = snprintf(buf, buf_len,
"XLAT");
break;
454 return buf_len - blen;
460 return snprintf(buf, buf_len,
"%s 0x%llx (%d)",
461 name, payload, packet->
index);
#define SPE_HEADER0_COUNTER_MASK
#define SPE_HEADER0_OP_TYPE_MASK
int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf, size_t buf_len)
#define SPE_HEADER0_ADDRESS
static int arm_spe_get_end(struct arm_spe_pkt *packet)
static int arm_spe_get_timestamp(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
#define SPE_HEADER0_OP_TYPE
static int arm_spe_get_data_source(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
static int arm_spe_get_payload(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
static int arm_spe_get_context(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
enum arm_spe_pkt_type type
#define SPE_HEADER0_ADDRESS_MASK
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
static int arm_spe_get_counter(const unsigned char *buf, size_t len, const unsigned char ext_hdr, struct arm_spe_pkt *packet)
#define SPE_HEADER0_COUNTER
#define SPE_HEADER0_EVENTS
#define memcpy_le64(d, s, n)
#define SPE_HEADER0_SOURCE
#define SPE_HEADER0_SOURCE_MASK
static int arm_spe_get_pad(struct arm_spe_pkt *packet)
#define SPE_HEADER1_COUNTER
int arm_spe_get_packet(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
#define SPE_HEADER1_ADDRESS_MASK
#define SPE_HEADER0_EVENTS_MASK
#define SPE_HEADER1_ADDRESS
#define SPE_HEADER0_CONTEXT_MASK
static int arm_spe_get_events(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
#define SPE_HEADER1_COUNTER_MASK
static int arm_spe_get_op_type(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
static int arm_spe_get_alignment(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
#define SPE_HEADER1_ALIGNMENT
const char * arm_spe_pkt_name(enum arm_spe_pkt_type type)
#define SPE_HEADER0_CONTEXT
static int arm_spe_get_addr(const unsigned char *buf, size_t len, const unsigned char ext_hdr, struct arm_spe_pkt *packet)
#define ARM_SPE_BAD_PACKET
static int arm_spe_do_get_packet(const unsigned char *buf, size_t len, struct arm_spe_pkt *packet)
static int payloadlen(unsigned char byte)
#define SPE_HEADER0_TIMESTAMP
#define ARM_SPE_NEED_MORE_BYTES
static const char *const arm_spe_packet_name[]