[PATCH v2 13/14] perf arm_spe: Decode memory tagging properties

From: Leo Yan
Date: Tue Sep 29 2020 - 09:41:24 EST


From: Andre Przywara <andre.przywara@xxxxxxx>

When SPE records a physical address, it can additionally tag the event
with information from the Memory Tagging architecture extension.

Decode the two additional fields in the SPE event payload.

[leoy: Refined patch to use predefined macros]

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>
---
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 7 ++++++-
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index 57a2d5494838..05a4c74399d7 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -270,6 +270,7 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
size_t buf_len)
{
int ret, ns, el, idx = packet->index;
+ int ch, pat;
unsigned long long payload = packet->payload;
const char *name = arm_spe_pkt_name(packet->type);
size_t blen = buf_len;
@@ -438,9 +439,13 @@ int arm_spe_pkt_desc(const struct arm_spe_pkt *packet, char *buf,
"VA 0x%llx", payload);
case SPE_ADDR_PKT_HDR_INDEX_DATA_PHYS:
ns = !!(packet->payload & SPE_ADDR_PKT_INST_VA_NS);
+ ch = !!(packet->payload & SPE_ADDR_PKT_DATA_PA_CH);
+ pat = (packet->payload & SPE_ADDR_PKT_DATA_PA_PAT_MASK)
+ >> SPE_ADDR_PKT_DATA_PA_PAT_SHIFT;
payload &= SPE_ADDR_PKT_ADDR_MASK;
return arm_spe_pkt_snprintf(&buf, &blen,
- "PA 0x%llx ns=%d", payload, ns);
+ "PA 0x%llx ns=%d ch=%d, pat=%x",
+ payload, ns, ch, pat);
default:
return 0;
}
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
index 2c4086bf3149..1847cad517db 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
@@ -76,6 +76,8 @@ struct arm_spe_pkt {

#define SPE_ADDR_PKT_DATA_PA_NS BIT(63)
#define SPE_ADDR_PKT_DATA_PA_CH BIT(62)
+#define SPE_ADDR_PKT_DATA_PA_PAT_SHIFT (56)
+#define SPE_ADDR_PKT_DATA_PA_PAT_MASK GENMASK_ULL(59, 56)

/* Address packet payload for instrcution virtual address */
#define SPE_ADDR_PKT_INST_VA_NS BIT(63)
--
2.20.1