From: Luis Machado via Gdb-patches <gdb-patches@sourceware.org>
To: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>, gdb-patches@sourceware.org
Cc: james.hsu@mediatek.com, nicholas.tang@mediatek.com,
zhiyong.wang@mediatek.com, chinwen.chang@mediatek.com
Subject: Re: [PATCH] AArch64 pauth: Indicate addresses in backtrace for kernel
Date: Mon, 25 Oct 2021 09:07:43 -0300 [thread overview]
Message-ID: <cfa8cb57-f3ae-ed09-e83e-68cf41307a48@linaro.org> (raw)
In-Reply-To: <20211025114705.32548-1-Kuan-Ying.Lee@mediatek.com>
On 10/25/21 8:47 AM, Kuan-Ying Lee via Gdb-patches wrote:
> 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);
>
Could you please share more information about this problem? Why is it
GDB needs to do things differently for a kernel mode and user mode
address? What is the test setup?
If we entered the above conditional block, that means DWARF has told GDB
that LR is masked (ra_state_regnum), and so it needs to be unmasked.
Given this is generic AArch64 code, we don't want to risk breaking
existing use cases, and I'd like to understand what is not being handled
properly.
We have another gdbarch method that handles sign-extending kernel mode
addresses (gdbarch_significant_addr_bit), but it is not clear if that
could be used here without some examples.
Thanks,
Luis
next prev parent reply other threads:[~2021-10-25 12:12 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
2021-10-25 12:07 ` Luis Machado via Gdb-patches [this message]
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=cfa8cb57-f3ae-ed09-e83e-68cf41307a48@linaro.org \
--to=gdb-patches@sourceware.org \
--cc=Kuan-Ying.Lee@mediatek.com \
--cc=chinwen.chang@mediatek.com \
--cc=james.hsu@mediatek.com \
--cc=luis.machado@linaro.org \
--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