public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] arm64: asmlinkage: Enable use of BTI_C macro in SYM_CODE
Date: Mon, 6 Dec 2021 17:11:20 +0000	[thread overview]
Message-ID: <Ya5EOLruTzBhjQ3P@FVFF77S0Q05N> (raw)
In-Reply-To: <CAMj1kXFXPQWMoAw3NbfBXfKyZsKM=Qpv1vkDNbCkBY6G9LMiuA@mail.gmail.com>

On Mon, Dec 06, 2021 at 05:52:16PM +0100, Ard Biesheuvel wrote:
> On Mon, 6 Dec 2021 at 17:30, Mark Rutland <mark.rutland@arm.com> wrote:
> >
> > On Fri, Dec 03, 2021 at 01:03:35PM +0000, Mark Brown wrote:
> > > A couple of SYM_CODE sections have added usage of BTI_C which is
> > > currently only defined when building for BTI.  This means that the
> > > users have ugly ifdefs for the case where BTI is disabled so let's
> > > provide an empty definition in that case and remove the ifdefs.
> > >
> > > Signed-off-by: Mark Brown <broonie@kernel.org>
> > > ---
> > >  arch/arm64/include/asm/linkage.h | 4 ++++
> > >  arch/arm64/kernel/entry-ftrace.S | 4 ----
> > >  arch/arm64/lib/kasan_sw_tags.S   | 2 --
> > >  3 files changed, 4 insertions(+), 6 deletions(-)
> >
> > Looking around, there are other places that open-code `hint 34`, e.g.
> > arch/arm64/crypto/aes-modes.S. Those are unconditional, so we should probably
> > figure out whether we want those to be conditional (or if we're happy to make
> > the other cases similarly unconditional).
> >
> > I'd argue we should probably place BTIs in assembly unconditionally, on the
> > assumption that they shouldn't have an measureable performance impact in
> > practice (as we're already assuming that when CONFIG_ARM64_BTI_KERNEL is
> > selected anyhow). Thoughts?
> 
> From the top of my head, I can't say for sure but there are some
> computed gotos in the crypto code where removing an instruction may
> throw off the calculation. So keeping the hint unconditionally makes
> sense to me, and by the same reasoning, it would be better not to
> introduce macros that shadow existing instructions if they may resolve
> to a sequence of a different size.

As an aside, while that code works, it's using `BTI C` in an odd way, since the
those are internal labels rather than callable function entry points (but the
`BR` works because of the X16/X17 exemption that makes PLTs work).

For consistency, we might want to make that use `BTI J`, and an X register
other than X16/X17, which is what the compiler should generate for cases like
this. That would minimize the set of targets the `BR` can legitimately hit
(though AFAICT this cannot be gadgetized anyway, so this'd just be for
consistency/lack-of-surprise).

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-12-06 17:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 13:03 [PATCH] arm64: asmlinkage: Enable use of BTI_C macro in SYM_CODE Mark Brown
2021-12-06 16:30 ` Mark Rutland
2021-12-06 16:52   ` Ard Biesheuvel
2021-12-06 17:11     ` Mark Rutland [this message]
2021-12-06 18:05   ` Mark Brown
2021-12-06 18:38     ` Mark Rutland
2021-12-06 19:31       ` Mark Brown

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=Ya5EOLruTzBhjQ3P@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.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