[PATCH 7/8] perf tools: Print ptrauth struct in perf report

Andrew Kilroy andrew.kilroy at arm.com
Mon Jul 4 07:53:31 PDT 2022


This patch prints a perf sample's ptrauth struct so that the PAC masks
can be seen.  To aid debugging.

Signed-off-by: Andrew Kilroy <andrew.kilroy at arm.com>
---
 tools/perf/util/session.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 37f833c3c81b..6b56e638d4dd 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1329,6 +1329,13 @@ char *get_page_size_name(u64 size, char *str)
 	return str;
 }
 
+static void ptrauth__printf(struct ptrauth_info *ptrauth)
+{
+	printf(" . ptrauth enabled keys:     0x%016"PRIx64"\n", ptrauth->enabled_keys);
+	printf(" . ptrauth instruction mask: 0x%016"PRIx64"\n", ptrauth->insn_mask);
+	printf(" . ptrauth data mask:        0x%016"PRIx64"\n", ptrauth->data_mask);
+}
+
 static void dump_sample(struct evsel *evsel, union perf_event *event,
 			struct perf_sample *sample, const char *arch)
 {
@@ -1385,6 +1392,14 @@ static void dump_sample(struct evsel *evsel, union perf_event *event,
 
 	if (sample_type & PERF_SAMPLE_READ)
 		sample_read__printf(sample, evsel->core.attr.read_format);
+
+	if (sample_type & PERF_SAMPLE_ARCH_1) {
+		const char *normlzd_arch = perf_env__arch(evsel->evlist->env);
+
+		if (normlzd_arch && strcmp(normlzd_arch, "arm64") == 0)
+			ptrauth__printf(&sample->ptrauth);
+	}
+
 }
 
 static void dump_read(struct evsel *evsel, union perf_event *event)
-- 
2.17.1




More information about the linux-arm-kernel mailing list