linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] crypto: use unaligned accessors in aligned fast paths
Date: Mon,  8 Oct 2018 23:15:51 +0200	[thread overview]
Message-ID: <20181008211554.5355-1-ard.biesheuvel@linaro.org> (raw)

CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS behaves a bit counterintuitively
on ARM: we set it for architecture revisions v6 and up, which support
any alignment for load/store instructions that operate on bytes, half
words or words. However, load/store double word and load store multiple
instructions still require 32-bit alignment, and using them on unaligned
quantities results in costly alignment traps that have to be fixed up by
the kernel's fixup code.

Fortunately, the unaligned accessors do the right thing here: on
architectures that really tolerate any misalignment, they simply resolve
to the aligned accessors, while on ARMv6+ (which uses the packed struct
wrappers for unaligned accesses), they result in load/store sequences
that avoid the instructions that require 32-bit alignment.

Since there is not really a downside to using the unaligned accessors on
aligned paths for architectures other than ARM that define
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, let's switch to them in a couple
of places in the crypto code.

Note that all patches are against code that has been observed to be emitted
with ldm or ldrd instructions when building ARM's multi_v7_defconfig.

Ard Biesheuvel (3):
  crypto: memneq - use unaligned accessors for aligned fast path
  crypto: crypto_xor - use unaligned accessors for aligned fast path
  crypto: siphash - drop _aligned variants

 crypto/algapi.c         |   7 +-
 crypto/memneq.c         |  24 +++--
 include/crypto/algapi.h |  11 +-
 include/linux/siphash.h | 106 +++++++++-----------
 lib/siphash.c           | 103 ++-----------------
 5 files changed, 83 insertions(+), 168 deletions(-)

-- 
2.11.0

             reply	other threads:[~2018-10-08 21:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 21:15 Ard Biesheuvel [this message]
2018-10-08 21:15 ` [PATCH 1/3] crypto: memneq - use unaligned accessors for aligned fast path Ard Biesheuvel
2018-10-09  3:34   ` Eric Biggers
2018-10-09  6:01     ` Ard Biesheuvel
2018-10-08 21:15 ` [PATCH 2/3] crypto: crypto_xor " Ard Biesheuvel
2018-10-09  3:47   ` Eric Biggers
2018-10-09  8:38     ` Ard Biesheuvel
2018-10-08 21:15 ` [PATCH 3/3] crypto: siphash - drop _aligned variants Ard Biesheuvel
2018-10-09  4:11   ` Jason A. Donenfeld
2018-10-09  5:59     ` Ard Biesheuvel
2018-10-09  6:10       ` Jeffrey Walton

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=20181008211554.5355-1-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --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).