Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] AArch64 pauth: Indicate addresses in backtrace for kernel
@ 2021-10-25 11:47 Kuan-Ying Lee via Gdb-patches
  2021-10-25 12:07 ` Luis Machado via Gdb-patches
  2021-10-26 12:46 ` Luis Machado via Gdb-patches
  0 siblings, 2 replies; 6+ messages in thread
From: Kuan-Ying Lee via Gdb-patches @ 2021-10-25 11:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: james.hsu, nicholas.tang, zhiyong.wang, chinwen.chang

Armv8.3-a Pointer Authentication cause the function return address to
be changed. GDB need to use address bit[55] to know which mode is active
and mask/unmask the link register in order to get backtrace.

If address is in kernel mode, we mask the address. If address is in user mode,
we need to unmask the address.
---
 gdb/aarch64-tdep.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 4b5af4616af..d4bb4305cea 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -257,7 +257,10 @@ aarch64_frame_unmask_lr (struct gdbarch_tdep *tdep,
     {
       int cmask_num = AARCH64_PAUTH_CMASK_REGNUM (tdep->pauth_reg_base);
       CORE_ADDR cmask = frame_unwind_register_unsigned (this_frame, cmask_num);
-      addr = addr & ~cmask;
+      if (addr & 0x0080000000000000ULL)
+        addr = addr | cmask;
+      else
+        addr = addr & ~cmask;
 
       /* Record in the frame that the link register required unmasking.  */
       set_frame_previous_pc_masked (this_frame);
-- 
2.25.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-27  3:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 11:47 [PATCH] AArch64 pauth: Indicate addresses in backtrace for kernel Kuan-Ying Lee via Gdb-patches
2021-10-25 12:07 ` Luis Machado via Gdb-patches
2021-10-26 12:22   ` Kuan-Ying Lee via Gdb-patches
2021-10-26 12:30     ` Luis Machado via Gdb-patches
2021-10-26 12:46 ` Luis Machado via Gdb-patches
2021-10-27  3:27   ` Kuan-Ying Lee via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox