From: Catalin Marinas <catalin.marinas@arm.com>
To: Dave Martin <Dave.Martin@arm.com>
Cc: herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org,
Jeremy Linton <jeremy.linton@arm.com>,
davem@davemloft.net, broonie@kernel.org,
linux-crypto@vger.kernel.org, Will Deacon <will@kernel.org>,
ardb@kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [BUG][PATCH] crypto: arm64: Avoid indirect branch to bti_c
Date: Tue, 6 Oct 2020 11:25:11 +0100 [thread overview]
Message-ID: <20201006102507.GA19213@gaia> (raw)
In-Reply-To: <20201006100121.GW6642@arm.com>
On Tue, Oct 06, 2020 at 11:01:21AM +0100, Dave P Martin wrote:
> On Tue, Oct 06, 2020 at 09:27:48AM +0100, Will Deacon wrote:
> > On Mon, Oct 05, 2020 at 10:48:54PM -0500, Jeremy Linton wrote:
> > > The AES code uses a 'br x7' as part of a function called by
> > > a macro. That branch needs a bti_j as a target. This results
> > > in a panic as seen below. Instead of trying to replace the branch
> > > target with a bti_jc, lets replace the indirect branch with a
> > > bl/ret, bl sequence that can target the existing bti_c.
> > >
> > > Bad mode in Synchronous Abort handler detected on CPU1, code 0x34000003 -- BTI
> > > CPU: 1 PID: 265 Comm: cryptomgr_test Not tainted 5.8.11-300.fc33.aarch64 #1
> > > pstate: 20400c05 (nzCv daif +PAN -UAO BTYPE=j-)
> > > pc : aesbs_encrypt8+0x0/0x5f0 [aes_neon_bs]
> > > lr : aesbs_xts_encrypt+0x48/0xe0 [aes_neon_bs]
> > > sp : ffff80001052b730
> > >
> > > aesbs_encrypt8+0x0/0x5f0 [aes_neon_bs]
> > > __xts_crypt+0xb0/0x2dc [aes_neon_bs]
> > > xts_encrypt+0x28/0x3c [aes_neon_bs]
> > > crypto_skcipher_encrypt+0x50/0x84
> > > simd_skcipher_encrypt+0xc8/0xe0
> > > crypto_skcipher_encrypt+0x50/0x84
> > > test_skcipher_vec_cfg+0x224/0x5f0
> > > test_skcipher+0xbc/0x120
> > > alg_test_skcipher+0xa0/0x1b0
> > > alg_test+0x3dc/0x47c
> > > cryptomgr_test+0x38/0x60
> > >
> > > Fixes: commit 0e89640b640d ("crypto: arm64 - Use modern annotations for assembly functions")
> >
> > nit: the "commit" string shouldn't be here, and I think the linux-next
> > scripts will yell at us if we don't remove it.
> >
> > > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> > > ---
> > > arch/arm64/crypto/aes-neonbs-core.S | 6 +++---
> > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/arm64/crypto/aes-neonbs-core.S b/arch/arm64/crypto/aes-neonbs-core.S
> > > index b357164379f6..32f53ebe5e2c 100644
> > > --- a/arch/arm64/crypto/aes-neonbs-core.S
> > > +++ b/arch/arm64/crypto/aes-neonbs-core.S
> > > @@ -788,7 +788,7 @@ SYM_FUNC_START_LOCAL(__xts_crypt8)
> > >
> > > 0: mov bskey, x21
> > > mov rounds, x22
> > > - br x7
> > > + ret
>
> Dang, replied on an old version.
Which I ignored (by default, when the kbuild test robot complains ;)).
> Since this is logically a tail call, could we simply be using br x16 or
> br x17 for this?
>
> The architecture makes special provision for that so that the compiler
> can generate tail-calls.
So a "br x16" is compatible with a bti_c landing pad. I think it makes
more sense to keep it as a tail call.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-10-06 10:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-06 3:48 [BUG][PATCH] crypto: arm64: Avoid indirect branch to bti_c Jeremy Linton
2020-10-06 8:27 ` Will Deacon
2020-10-06 10:01 ` Dave Martin
2020-10-06 10:21 ` Will Deacon
2020-10-06 10:25 ` Catalin Marinas [this message]
2020-10-06 10:43 ` Dave Martin
2020-10-06 12:33 ` Catalin Marinas
2020-10-06 12:36 ` Ard Biesheuvel
2020-10-06 13:45 ` Jeremy Linton
2020-10-06 10:35 ` 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=20201006102507.GA19213@gaia \
--to=catalin.marinas@arm.com \
--cc=Dave.Martin@arm.com \
--cc=ardb@kernel.org \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jeremy.linton@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).