From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/5] arm64: add Crypto Extensions based synchronous core AES cipher
Date: Mon, 3 Feb 2014 16:17:50 +0000 [thread overview]
Message-ID: <20140203161750.GH14112@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <CAKv+Gu_NdVHawdVz3KUeZPHUL4ZPNSpeq7EWAgsVy+DfS6Kaqw@mail.gmail.com>
On Thu, Jan 30, 2014 at 07:20:38PM +0000, Ard Biesheuvel wrote:
> On 30 January 2014 19:56, Will Deacon <will.deacon@arm.com> wrote:
> > On Wed, Jan 29, 2014 at 04:50:46PM +0000, Ard Biesheuvel wrote:
> >> +static void aes_cipher_encrypt(struct crypto_tfm *tfm, u8 dst[], u8 const src[])
> >> +{
> >> + struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
> >> + u32 rounds = 6 + ctx->key_length / 4;
> >
> > Can you document these constants please?
> >
>
> Sure.
Thanks.
> >> +
> >> + kernel_neon_begin();
> >> +
> >> + __asm__(" ld1 {v0.16b}, [%[in]] ;"
> >> + " ld1 {v1.16b}, [%[key]], #16 ;"
> >> + "0: aese v0.16b, v1.16b ;"
> >> + " subs %[rounds], %[rounds], #1 ;"
> >> + " ld1 {v1.16b}, [%[key]], #16 ;"
> >> + " beq 1f ;"
> >> + " aesmc v0.16b, v0.16b ;"
> >> + " b 0b ;"
> >> + "1: eor v0.16b, v0.16b, v1.16b ;"
> >> + " st1 {v0.16b}, [%[out]] ;"
> >> + : :
> >> + [out] "r"(dst),
> >> + [in] "r"(src),
> >> + [rounds] "r"(rounds),
> >> + [key] "r"(ctx->key_enc)
> >> + : "cc");
> >
> > You probably need a memory output to stop this being re-ordered by the
> > compiler. Can GCC not generate the addressing modes you need directly,
> > allowing you to avoid moving everything into registers?
> >
>
> Would a memory clobber work as well?
It would, but it could lead to suboptimal code generation by GCC (although
neon_{begin,end} may well stop GCC in its tracks anyway, so worth looking at
the disassembly).
> Re addressing modes: I would prefer to explicitly use v0 and v1, I
> have another patch pending that allows partial saves/restores of the
> NEON register file when called from interrupt context. I suppose I
> could use 'register asm("v0")' or something like that, but that won't
> make it any prettier.
It's not the use of v0/v1 that I was objecting to. I was hoping that we
could describe [in] and [out] as memory operands, so that GCC could
potentially reduce register usage for base + offset style addressing modes.
Unfortunately, I don't think we have such a constraint for AArch64 :(
If the disassembly looks ok, the "memory" clobber is probably our best bet.
Will
prev parent reply other threads:[~2014-02-03 16:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-29 16:50 [PATCH 0/5] generic CPU feature based udev module autoprobing Ard Biesheuvel
2014-01-29 16:50 ` [PATCH 1/5] cpu: move arch_cpu_uevent() to generic code Ard Biesheuvel
2014-01-29 16:50 ` [PATCH 2/5] cpu: add generic support for CPU feature based module autoloading Ard Biesheuvel
2014-02-03 17:13 ` Ard Biesheuvel
2014-01-29 16:50 ` [PATCH 3/5] x86: align x86 arch with generic CPU modalias handling Ard Biesheuvel
2014-01-29 17:16 ` H. Peter Anvin
2014-01-29 16:50 ` [PATCH 4/5] arm64: enable generic CPU feature modalias matching for this arch Ard Biesheuvel
2014-01-29 16:50 ` [PATCH 5/5] arm64: add Crypto Extensions based synchronous core AES cipher Ard Biesheuvel
2014-01-30 18:56 ` Will Deacon
2014-01-30 19:20 ` Ard Biesheuvel
2014-02-03 16:17 ` Will Deacon [this message]
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=20140203161750.GH14112@mudshark.cambridge.arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).