From: Kuan-Ying Lee via Gdb-patches <gdb-patches@sourceware.org>
To: <gdb-patches@sourceware.org>
Cc: james.hsu@mediatek.com, nicholas.tang@mediatek.com,
zhiyong.wang@mediatek.com, chinwen.chang@mediatek.com
Subject: [PATCH] AArch64 pauth: Indicate addresses in backtrace for kernel
Date: Mon, 25 Oct 2021 19:47:05 +0800 [thread overview]
Message-ID: <20211025114705.32548-1-Kuan-Ying.Lee@mediatek.com> (raw)
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
next reply other threads:[~2021-10-25 11:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 11:47 Kuan-Ying Lee via Gdb-patches [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211025114705.32548-1-Kuan-Ying.Lee@mediatek.com \
--to=gdb-patches@sourceware.org \
--cc=Kuan-Ying.Lee@mediatek.com \
--cc=chinwen.chang@mediatek.com \
--cc=james.hsu@mediatek.com \
--cc=nicholas.tang@mediatek.com \
--cc=zhiyong.wang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox