[PATCH] crypto - shash: reduce minimum alignment of shash_desc structure

Ard Biesheuvel ardb at kernel.org
Fri Jan 8 06:31:59 EST 2021


On Fri, 8 Jan 2021 at 11:59, Arnd Bergmann <arnd at kernel.org> wrote:
>
> On Fri, Jan 8, 2021 at 11:44 AM Herbert Xu <herbert at gondor.apana.org.au> wrote:
> >
> > On Fri, Jan 08, 2021 at 11:42:53AM +0100, Arnd Bergmann wrote:
> > >
> > > How does this work for kernels with CONFIG_VMAP_STACK?
> > > I remember some other subsystems (usb, hid) adding workarounds
> > > for that, but I don't see those in drivers/crypto
> >
> > I'm referring to the situation in general and not the subject of
> > this thread.
> >
> > For shash_desc of course it doesn't happen since it sync only.
>
> Ah, got it.
>

I can fold in the following

--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -151,9 +151,12 @@
  * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual
  * declaration) is used to ensure that the crypto_tfm context structure is
  * aligned correctly for the given architecture so that there are no alignment
- * faults for C data types.  In particular, this is required on platforms such
- * as arm where pointers are 32-bit aligned but there are data types such as
- * u64 which require 64-bit alignment.
+ * faults for C data types.  On architectures that support non-cache coherent
+ * DMA, such as ARM or arm64, it also takes into account the minimal alignment
+ * that is required to ensure that the context struct member does not share any
+ * cachelines with the rest of the struct. This is needed to ensure that cache
+ * maintenance for non-coherent DMA does not affect data that may be accessed
+ * by the CPU concurrently.
  */
 #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN


(or send it as a separate patch)

Note that the comment about 64-bit alignment for 64-bit types on ARM
is incorrect.



More information about the linux-arm-kernel mailing list