Skip to contentSkip to conversation

perf arm-spe: Add raw decoding for SPEv1.2 previous branch address

PATCH Applied Rob Herring 2 participants 2 messages Feb 3, 2023 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf arm-spe: Add raw decoding for SPEv1.2 previous branch address

Arm SPEv1.2 adds a new optional address packet type: previous branch target. The recorded address is the target virtual address of the most recently taken branch in program order.

Add support for decoding the address packet in raw dumps.

---
v2:
- Use "PBT" instead of "LBR"

---
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 4 +++-
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c +3 -1
index 2f311189c6e8..fed4741f372e 100644
@@ -422,16 +422,18 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
 	int ch, pat;
 	u64 payload = packet->payload;
 	int err = 0;
+	static const char *idx_name[] = {"PC", "TGT", "VA", "PA", "PBT"};
 
 	switch (idx) {
 	case SPE_ADDR_PKT_HDR_INDEX_INS:
 	case SPE_ADDR_PKT_HDR_INDEX_BRANCH:
+	case SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH:
 		ns = !!SPE_ADDR_PKT_GET_NS(payload);
 		el = SPE_ADDR_PKT_GET_EL(payload);
 		payload = SPE_ADDR_PKT_ADDR_GET_BYTES_0_6(payload);
 		arm_spe_pkt_out_string(&err, &buf, &buf_len,
 				"%s 0x%llx el%d ns=%d",
-				(idx == 1) ? "TGT" : "PC", payload, el, ns);
+				idx_name[idx], payload, el, ns);
 		break;
 	case SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT:
 		arm_spe_pkt_out_string(&err, &buf, &buf_len,
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h +1 -0
index 9b970e7bf1e2..f75ed3a8a050 100644
@@ -65,6 +65,7 @@ struct arm_spe_pkt {
 #define SPE_ADDR_PKT_HDR_INDEX_BRANCH		0x1
 #define SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT	0x2
 #define SPE_ADDR_PKT_HDR_INDEX_DATA_PHYS	0x3
+#define SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH	0x4
 
 /* Address packet payload */
 #define SPE_ADDR_PKT_ADDR_BYTE7_SHIFT		56
Signature · 1 line
2.39.0
maintainer Applied
#1 lore raw

Em Fri, Feb 03, 2023 at 10:24:01AM -0600, Rob Herring escreveu:

Quoted 11 lines

Arm SPEv1.2 adds a new optional address packet type: previous branch target. The recorded address is the target virtual address of the most recently taken branch in program order.

Add support for decoding the address packet in raw dumps.

---
v2:
- Use "PBT" instead of "LBR"

Thanks, applied.

- Arnaldo

Quoted 44 lines
---
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 4 +++-
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c +3 -1
index 2f311189c6e8..fed4741f372e 100644
@@ -422,16 +422,18 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,
 	int ch, pat;
 	u64 payload = packet->payload;
 	int err = 0;
+	static const char *idx_name[] = {"PC", "TGT", "VA", "PA", "PBT"};
 
 	switch (idx) {
 	case SPE_ADDR_PKT_HDR_INDEX_INS:
 	case SPE_ADDR_PKT_HDR_INDEX_BRANCH:
+	case SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH:
 		ns = !!SPE_ADDR_PKT_GET_NS(payload);
 		el = SPE_ADDR_PKT_GET_EL(payload);
 		payload = SPE_ADDR_PKT_ADDR_GET_BYTES_0_6(payload);
 		arm_spe_pkt_out_string(&err, &buf, &buf_len,
 				"%s 0x%llx el%d ns=%d",
-				(idx == 1) ? "TGT" : "PC", payload, el, ns);
+				idx_name[idx], payload, el, ns);
 		break;
 	case SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT:
 		arm_spe_pkt_out_string(&err, &buf, &buf_len,
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h +1 -0
index 9b970e7bf1e2..f75ed3a8a050 100644
@@ -65,6 +65,7 @@ struct arm_spe_pkt {
 #define SPE_ADDR_PKT_HDR_INDEX_BRANCH		0x1
 #define SPE_ADDR_PKT_HDR_INDEX_DATA_VIRT	0x2
 #define SPE_ADDR_PKT_HDR_INDEX_DATA_PHYS	0x3
+#define SPE_ADDR_PKT_HDR_INDEX_PREV_BRANCH	0x4
 
 /* Address packet payload */
 #define SPE_ADDR_PKT_ADDR_BYTE7_SHIFT		56
Signature · 1 line
2.39.0
Signature · 1 line
- Arnaldo