All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Eric Biggers <ebiggers@google.com>
Cc: Stefan Agner <stefan@agner.ch>,
	"open list:HARDWARE RANDOM NUMBER GENERATOR CORE"
	<linux-crypto@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: [PATCH] crypto: arm/speck - fix building in Thumb2 mode
Date: Tue, 19 Jun 2018 08:38:13 +0200	[thread overview]
Message-ID: <CAKv+Gu-P3_zn41jeTmh=vojcoBhF_g_2FvYTq_8A3PJku3efVA@mail.gmail.com> (raw)
In-Reply-To: <20180618223323.130072-1-ebiggers@google.com>

On 19 June 2018 at 00:33, Eric Biggers <ebiggers@google.com> wrote:
> Building the kernel with CONFIG_THUMB2_KERNEL=y and
> CONFIG_CRYPTO_SPECK_NEON set fails with the following errors:
>
>     arch/arm/crypto/speck-neon-core.S: Assembler messages:
>
>     arch/arm/crypto/speck-neon-core.S:419: Error: r13 not allowed here -- `bic sp,#0xf'
>     arch/arm/crypto/speck-neon-core.S:423: Error: r13 not allowed here -- `bic sp,#0xf'
>     arch/arm/crypto/speck-neon-core.S:427: Error: r13 not allowed here -- `bic sp,#0xf'
>     arch/arm/crypto/speck-neon-core.S:431: Error: r13 not allowed here -- `bic sp,#0xf'
>
> The problem is that the 'bic' instruction can't operate on the 'sp'
> register in Thumb2 mode.  Fix it by using a temporary register.  This
> isn't in the main loop, so the performance difference is negligible.
> This also matches what aes-neonbs-core.S does.
>
> Reported-by: Stefan Agner <stefan@agner.ch>
> Fixes: ede9622162fa ("crypto: arm/speck - add NEON-accelerated implementation of Speck-XTS")
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  arch/arm/crypto/speck-neon-core.S | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/crypto/speck-neon-core.S b/arch/arm/crypto/speck-neon-core.S
> index 3c1e203e53b9..57caa742016e 100644
> --- a/arch/arm/crypto/speck-neon-core.S
> +++ b/arch/arm/crypto/speck-neon-core.S
> @@ -272,9 +272,11 @@
>          * Allocate stack space to store 128 bytes worth of tweaks.  For
>          * performance, this space is aligned to a 16-byte boundary so that we
>          * can use the load/store instructions that declare 16-byte alignment.
> +        * For Thumb2 compatibility, don't do the 'bic' directly on 'sp'.
>          */
> -       sub             sp, #128
> -       bic             sp, #0xf
> +       sub             r12, sp, #128
> +       bic             r12, #0xf
> +       mov             sp, r12
>
>  .if \n == 64
>         // Load first tweak

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

WARNING: multiple messages have this Message-ID (diff)
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] crypto: arm/speck - fix building in Thumb2 mode
Date: Tue, 19 Jun 2018 08:38:13 +0200	[thread overview]
Message-ID: <CAKv+Gu-P3_zn41jeTmh=vojcoBhF_g_2FvYTq_8A3PJku3efVA@mail.gmail.com> (raw)
In-Reply-To: <20180618223323.130072-1-ebiggers@google.com>

On 19 June 2018 at 00:33, Eric Biggers <ebiggers@google.com> wrote:
> Building the kernel with CONFIG_THUMB2_KERNEL=y and
> CONFIG_CRYPTO_SPECK_NEON set fails with the following errors:
>
>     arch/arm/crypto/speck-neon-core.S: Assembler messages:
>
>     arch/arm/crypto/speck-neon-core.S:419: Error: r13 not allowed here -- `bic sp,#0xf'
>     arch/arm/crypto/speck-neon-core.S:423: Error: r13 not allowed here -- `bic sp,#0xf'
>     arch/arm/crypto/speck-neon-core.S:427: Error: r13 not allowed here -- `bic sp,#0xf'
>     arch/arm/crypto/speck-neon-core.S:431: Error: r13 not allowed here -- `bic sp,#0xf'
>
> The problem is that the 'bic' instruction can't operate on the 'sp'
> register in Thumb2 mode.  Fix it by using a temporary register.  This
> isn't in the main loop, so the performance difference is negligible.
> This also matches what aes-neonbs-core.S does.
>
> Reported-by: Stefan Agner <stefan@agner.ch>
> Fixes: ede9622162fa ("crypto: arm/speck - add NEON-accelerated implementation of Speck-XTS")
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  arch/arm/crypto/speck-neon-core.S | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/crypto/speck-neon-core.S b/arch/arm/crypto/speck-neon-core.S
> index 3c1e203e53b9..57caa742016e 100644
> --- a/arch/arm/crypto/speck-neon-core.S
> +++ b/arch/arm/crypto/speck-neon-core.S
> @@ -272,9 +272,11 @@
>          * Allocate stack space to store 128 bytes worth of tweaks.  For
>          * performance, this space is aligned to a 16-byte boundary so that we
>          * can use the load/store instructions that declare 16-byte alignment.
> +        * For Thumb2 compatibility, don't do the 'bic' directly on 'sp'.
>          */
> -       sub             sp, #128
> -       bic             sp, #0xf
> +       sub             r12, sp, #128
> +       bic             r12, #0xf
> +       mov             sp, r12
>
>  .if \n == 64
>         // Load first tweak

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

  reply	other threads:[~2018-06-19  6:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 22:33 [PATCH] crypto: arm/speck - fix building in Thumb2 mode Eric Biggers
2018-06-18 22:33 ` Eric Biggers
2018-06-19  6:38 ` Ard Biesheuvel [this message]
2018-06-19  6:38   ` Ard Biesheuvel
2018-06-19  8:34 ` Stefan Agner
2018-06-19  8:34   ` Stefan Agner
2018-07-01 13:18 ` Herbert Xu
2018-07-01 13:18   ` Herbert Xu

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='CAKv+Gu-P3_zn41jeTmh=vojcoBhF_g_2FvYTq_8A3PJku3efVA@mail.gmail.com' \
    --to=ard.biesheuvel@linaro.org \
    --cc=ebiggers@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=stefan@agner.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.