From: Andrea Corallo <andrea.corallo@arm.com>
To: Feng Xue OS via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Feng Xue OS <fxue@os.amperecomputing.com>
Subject: Re: [PATCH] arm/aarch64: Add bti for all functions [PR106671]
Date: Tue, 9 Jan 2024 15:10:10 +0100 [thread overview]
Message-ID: <gkr8r4y4myl.fsf@arm.com> (raw)
In-Reply-To: <LV2PR01MB783923BF951C8BDF5B3D5BA9F70BA@LV2PR01MB7839.prod.exchangelabs.com> (Feng Xue's message of "Wed, 2 Aug 2023 15:48:59 +0000")
Feng Xue OS via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> This patch extends option -mbranch-protection=bti with an optional argument
> as bti[+all] to force compiler to unconditionally insert bti for all
> functions. Because a direct function call at the stage of compiling might be
> rewritten to an indirect call with some kind of linker-generated thunk stub
> as invocation relay for some reasons. One instance is if a direct callee is
> placed far from its caller, direct BL {imm} instruction could not represent
> the distance, so indirect BLR {reg} should be used. For this case, a bti is
> required at the beginning of the callee.
>
> caller() {
> bl callee
> }
>
> =>
>
> caller() {
> adrp reg, <callee>
> add reg, reg, #constant
> blr reg
> }
>
> Although the issue could be fixed with a pretty new version of ld, here we
> provide another means for user who has to rely on the old ld or other non-ld
> linker. I also checked LLVM, by default, it implements bti just as the proposed
> -mbranch-protection=bti+all.
>
> Feng
>
> ---
> gcc/config/aarch64/aarch64.cc | 12 +++++++-----
> gcc/config/aarch64/aarch64.opt | 2 +-
> gcc/config/arm/aarch-bti-insert.cc | 3 ++-
> gcc/config/arm/aarch-common.cc | 22 ++++++++++++++++++----
> gcc/config/arm/aarch-common.h | 18 ++++++++++++++++++
> gcc/config/arm/arm.cc | 4 ++--
> gcc/config/arm/arm.opt | 2 +-
> gcc/doc/invoke.texi | 16 ++++++++++------
> gcc/testsuite/gcc.target/aarch64/bti-5.c | 17 +++++++++++++++++
> 9 files changed, 76 insertions(+), 20 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/aarch64/bti-5.c
[...]
Hi Feng,
I think this patch is missing its ChangeLog entry. Also you should
specify the state of the testing and regression for this patch, please
see [1].
> diff --git a/gcc/testsuite/gcc.target/aarch64/bti-5.c b/gcc/testsuite/gcc.target/aarch64/bti-5.c
> new file mode 100644
> index 00000000000..654cd0cce7e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/bti-5.c
> @@ -0,0 +1,17 @@
> +/* { dg-do run } */
> +/* { dg-options "-O1 -save-temps" } */
> +/* { dg-require-effective-target lp64 } */
> +/* { dg-additional-options "-mbranch-protection=bti+all" { target { ! default_branch_protection } } } */
I see the other bti execution tests we have require "aarch64_bti_hw" as
effective target, do you think here is not necessary? If yes why?
Thanks
Andrea
[1] <https://gcc.gnu.org/contribute.html#patches>
next prev parent reply other threads:[~2024-01-09 14:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 15:48 Feng Xue OS
2024-01-09 14:10 ` Andrea Corallo [this message]
2024-01-09 14:34 ` Andrea Corallo
2024-02-14 10:53 ` Kyrylo Tkachov
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=gkr8r4y4myl.fsf@arm.com \
--to=andrea.corallo@arm.com \
--cc=fxue@os.amperecomputing.com \
--cc=gcc-patches@gcc.gnu.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).