Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-crypto@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"Elliott, Robert (Servers)" <elliott@hpe.com>
Subject: Re: [RFC PATCH] crypto: use kmap_local() not kmap_atomic()
Date: Tue, 13 Dec 2022 11:50:52 -0800	[thread overview]
Message-ID: <Y5jXnE8e2SRHFRQN@sol.localdomain> (raw)
In-Reply-To: <20221213161310.2205802-1-ardb@kernel.org>

On Tue, Dec 13, 2022 at 05:13:10PM +0100, Ard Biesheuvel wrote:
> kmap_atomic() is used to create short-lived mappings of pages that may
> not be accessible via the kernel direct map. This is only needed on
> 32-bit architectures that implement CONFIG_HIGHMEM, but it can be used
> on 64-bit other architectures too, where the returned mapping is simply
> the kernel direct address of the page.
> 
> However, kmap_atomic() does not support migration on CONFIG_HIGHMEM
> configurations, due to the use of per-CPU kmap slots, and so it disables
> preemption on all architectures, not just the 32-bit ones. This implies
> that all scatterwalk based crypto routines essentially execute with
> preemption disabled all the time, which is less than ideal.
> 
> So let's switch scatterwalk_map/_unmap and the shash/ahash routines to
> kmap_local() instead, which serves a similar purpose, but without the
> resulting impact on preemption on architectures that have no need for
> CONFIG_HIGHMEM.
> 
> Cc: Eric Biggers <ebiggers@kernel.org>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: "Elliott, Robert (Servers)" <elliott@hpe.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
>  crypto/ahash.c               | 4 ++--
>  crypto/shash.c               | 4 ++--
>  include/crypto/scatterwalk.h | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 

Thanks Ard, this looks good to me, especially given the broader effort to
replace kmap_atomic() with kmap_local_page() in the kernel.

One question: should the kmap_atomic() in crypto/skcipher.c be replaced as well?

- Eric

  reply	other threads:[~2022-12-13 19:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 16:13 [RFC PATCH] crypto: use kmap_local() not kmap_atomic() Ard Biesheuvel
2022-12-13 19:50 ` Eric Biggers [this message]
2022-12-13 20:58   ` Ard Biesheuvel
2022-12-30 15:11 ` 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=Y5jXnE8e2SRHFRQN@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=ardb@kernel.org \
    --cc=elliott@hpe.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.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