2022-07-04 14:58:54

by Andrew Kilroy

[permalink] [raw]
Subject: [PATCH 6/8] perf libunwind: arm64 pointer authentication

Make use of new changes in libunwind to decode a pointer which has a
pointer authentication code (PAC) in it.

Before this patch, perf is not able to produce stack traces where the
instruction addresses had PACs in them.

This commit has a dependency on a libunwind pull request:

https://github.com/libunwind/libunwind/pull/360

Signed-off-by: Andrew Kilroy <[email protected]>
---
tools/perf/util/unwind-libunwind-local.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 6e5b8cce47bf..6983a3e76a71 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -652,6 +652,15 @@ static void display_error(int err)
}
}

+#ifndef NO_LIBUNWIND_ARM64_PTRAUTH
+static unw_word_t get_insn_mask(unw_addr_space_t addr_space __maybe_unused, void *unwind_info_ptr)
+{
+ struct unwind_info *ui = unwind_info_ptr;
+ unw_word_t mask = ui->sample->ptrauth.insn_mask;
+ return mask;
+}
+#endif
+
static unw_accessors_t accessors = {
.find_proc_info = find_proc_info,
.put_unwind_info = put_unwind_info,
@@ -661,6 +670,9 @@ static unw_accessors_t accessors = {
.access_fpreg = access_fpreg,
.resume = resume,
.get_proc_name = get_proc_name,
+#ifndef NO_LIBUNWIND_ARM64_PTRAUTH
+ .ptrauth_insn_mask = get_insn_mask,
+#endif
};

static int _unwind__prepare_access(struct maps *maps)
--
2.17.1