• Ard Biesheuvel's avatar
    crypto: scatterwalk - use kmap_local() not kmap_atomic() · aa969515
    Ard Biesheuvel authored
    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: default avatarArd Biesheuvel <ardb@kernel.org>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    aa969515
scatterwalk.h 2.74 KB