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: Tue, 26 Oct 2021 09:46:52 -0300 [thread overview]
Message-ID: <a24fad7e-fa2f-4a05-5bfd-ea9e289a6c12@linaro.org> (raw)
In-Reply-To: <20211025114705.32548-1-Kuan-Ying.Lee@mediatek.com>
Hi!
Second time's the charm.
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)
I think we should define this constant in aarch64-tdep.h to make it more
obvious:
#define AARCH64_PAC_VA_RANGE_BIT 55
#define AARCH64_PAC_VA_RANGE_MASK (1ULL << AARCH64_PAC_VA_RANGE_BIT)
> + addr = addr | cmask;
> + else
> + addr = addr & ~cmask;
For the unmasking of the address, it would be nice to put this into a
separate function that unmasks an address given a particular mask value.
Something like this:
static CORE_ADDR
aarch64_unmask_address (CORE_ADDR address, CORE_ADDR mask)
{
/* Unmask kernel mode and user mode addresses appropriately based on
the VA range bit. */
if (address & AARCH64_PAC_VA_RANGE_MASK)
address | mask;
else
address & ~mask;
return address;
}
If we ever need to unmask kernel/user addresses somewhere else in the
code, we can just call this function from now on.
Could you please send a v2 of the patch with the suggested changes?
Thanks for the patch.
next prev parent reply other threads:[~2021-10-26 12:48 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
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 [this message]
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=a24fad7e-fa2f-4a05-5bfd-ea9e289a6c12@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