linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-sunxi <linux-sunxi@googlegroups.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	"open list:HARDWARE RANDOM NUMBER GENERATOR CORE"
	<linux-crypto@vger.kernel.org>,
	"# 3.4.x" <stable@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 4/7] crypto: sun4i-ss: handle BigEndian for cipher
Date: Mon, 16 Nov 2020 16:47:11 +0100	[thread overview]
Message-ID: <CAK8P3a0UZHmM2xfKegZ4mo_7N15614YPhx_FoY_h6WWF9M58Uw@mail.gmail.com> (raw)
In-Reply-To: <20201116135345.11834-5-clabbe@baylibre.com>

On Mon, Nov 16, 2020 at 2:53 PM Corentin Labbe <clabbe@baylibre.com> wrote:
>
> Ciphers produce invalid results on BE.
> Key and IV need to be written in LE.
>
> Fixes: 6298e948215f2 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c
> index 53478c3feca6..8f4621826330 100644
> --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c
> +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c
> @@ -52,13 +52,13 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
>
>         spin_lock_irqsave(&ss->slock, flags);
>
> -       for (i = 0; i < op->keylen; i += 4)
> -               writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
> +       for (i = 0; i < op->keylen / 4; i++)
> +               writesl(ss->base + SS_KEY0 + i * 4, &op->key[i], 1);
>

This looks correct, but I wonder if we should just introduce
memcpy_toio32() and memcpy_fromio32() as a generic interface,
as this seems to come up occasionally, and the method here
(a loop around an inline function with another loop) is a bit clumsy.

      Arnd

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

  reply	other threads:[~2020-11-16 15:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 13:53 [PATCH v3 0/7] crypto: sun4i-ss: prevent always fallback for ciphers Corentin Labbe
2020-11-16 13:53 ` [PATCH v3 1/7] crypto: sun4i-ss: linearize buffers content must be kept Corentin Labbe
2020-11-16 13:53 ` [PATCH v3 2/7] crypto: sun4i-ss: checking sg length is not sufficient Corentin Labbe
2020-11-16 14:54   ` David Laight
2020-11-16 13:53 ` [PATCH v3 3/7] crypto: sun4i-ss: IV register does not work on A10 and A13 Corentin Labbe
2020-11-16 13:53 ` [PATCH v3 4/7] crypto: sun4i-ss: handle BigEndian for cipher Corentin Labbe
2020-11-16 15:47   ` Arnd Bergmann [this message]
2020-11-16 13:53 ` [PATCH v3 5/7] crypto: sun4i-ss: initialize need_fallback Corentin Labbe
2020-11-16 13:53 ` [PATCH v3 6/7] crypto: sun4i-ss: enabled stats via debugfs Corentin Labbe
2020-11-27  5:57   ` Herbert Xu
2020-11-16 13:53 ` [PATCH v3 7/7] crypto: sun4i-ss: add SPDX header and remove blank lines Corentin Labbe

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=CAK8P3a0UZHmM2xfKegZ4mo_7N15614YPhx_FoY_h6WWF9M58Uw@mail.gmail.com \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=clabbe@baylibre.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=jernej.skrabec@siol.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mripard@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wens@csie.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).