lkml.org 
[lkml]   [2022]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN
On Sun, Apr 17, 2022 at 04:11:22PM +0800, Herbert Xu wrote:
> On Fri, Apr 15, 2022 at 01:31:32PM +0100, Catalin Marinas wrote:
> >
> > This needs a clarification. For the above structure, kmalloc() will
> > return a 128-byte aligned pointer since sizeof(x) is a multiple of 128.
> > The potential problem is if you have something like:
> >
> > kmalloc(sizeof(struct x) + 64);
> >
> > The above could end up as a kmalloc(192) which is available with an
> > ARCH_KMALLOC_MINALIGN of 64. If that's a real use-case, I can change the
> > slab patch to not create the 192 (or 48 if we go for an even smaller
> > ARCH_KMALLOC_MINALIGN) caches and we'd always have ARCH_DMA_MINALIGN
> > guarantee if the structure itself is correctly aligned. No lying to the
> > compiler.
>
> Yes I suppose that should work:
>
> 1) Enlarge each crypto API object so that they're >= 128 bytes;

I don't think we need to do anything here. A structure like:

struct x {
char y;
char z[] CRYPTO_MINALIGN_ATTR;
};

is already of size 128. Without CRYPTO_MINALIGN_ATTR, its size would be
1 but otherwise the whole structure inherits the alignment of its
member and this translates into an aligned size.

> 2) Modify kmalloc so that for sizes >= 128 bytes they're padded
> to multiples of 128.

This doesn't look like a hack, we want to honour the power of 2
alignments.

--
Catalin

\
 
 \ /
  Last update: 2022-04-17 10:39    [W:0.139 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site