From: LABBE Corentin <clabbe@baylibre.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
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 v2 4/7] crypto: sun4i-ss: handle BigEndian for cipher
Date: Wed, 23 Sep 2020 20:06:08 +0200 [thread overview]
Message-ID: <20200923180608.GA26666@Red> (raw)
In-Reply-To: <CAK8P3a34V16PUoVJjoUOVCik_rdb6vAy=54qRzWdO+aJcwUwsg@mail.gmail.com>
On Wed, Sep 23, 2020 at 04:00:32PM +0200, Arnd Bergmann wrote:
> On Sun, Sep 20, 2020 at 8:37 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 c6c25204780d..a05889745097 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++)
> > + writel(cpu_to_le32(op->key[i]), ss->base + SS_KEY0 + i * 4);
>
> I suspect what you actually want here is writesl() in place of the
> loop. This skips the byteswap on big-endian, rather than swapping
> each word twice.
>
> The point is that this register seems to act as a FIFO for a byte-stream
> rather than a 32-bit fixed-endian register.
>
> Arnd
Thanks, using writesl() fixes the warning, but I need to keep the loop since the register is different each time.
Or does it is better to use directly __raw_writel() ?
_______________________________________________
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-09-23 18:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-20 18:37 [PATCH v2 0/7] crypto: sun4i-ss: prevent always fallback for ciphers Corentin Labbe
2020-09-20 18:37 ` [PATCH v2 1/7] crypto: sun4i-ss: linearize buffers content must be kept Corentin Labbe
2020-09-25 7:30 ` Herbert Xu
2020-09-20 18:37 ` [PATCH v2 2/7] crypto: sun4i-ss: checking sg length is not sufficient Corentin Labbe
2020-09-20 18:37 ` [PATCH v2 3/7] crypto: sun4i-ss: IV register does not work on A10 and A13 Corentin Labbe
2020-09-20 18:37 ` [PATCH v2 4/7] crypto: sun4i-ss: handle BigEndian for cipher Corentin Labbe
2020-09-23 13:33 ` kernel test robot
2020-09-23 14:00 ` Arnd Bergmann
2020-09-23 18:06 ` LABBE Corentin [this message]
2020-09-23 18:59 ` Arnd Bergmann
2020-09-20 18:37 ` [PATCH v2 5/7] crypto: sun4i-ss: initialize need_fallback Corentin Labbe
2020-09-20 18:37 ` [PATCH v2 6/7] crypto: sun4i-ss: enabled stats via debugfs Corentin Labbe
2020-09-25 7:36 ` Herbert Xu
2020-09-20 18:37 ` [PATCH v2 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=20200923180608.GA26666@Red \
--to=clabbe@baylibre.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--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).