From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE169C433EF for ; Thu, 7 Apr 2022 16:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345690AbiDGQaw (ORCPT ); Thu, 7 Apr 2022 12:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbiDGQas (ORCPT ); Thu, 7 Apr 2022 12:30:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F55824951 for ; Thu, 7 Apr 2022 09:28:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BF68B60B4D for ; Thu, 7 Apr 2022 16:28:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5421C385A0; Thu, 7 Apr 2022 16:28:14 +0000 (UTC) Date: Thu, 7 Apr 2022 17:28:10 +0100 From: Catalin Marinas To: Herbert Xu Cc: Ard Biesheuvel , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "David S. Miller" Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-8-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 07, 2022 at 07:40:59PM +0800, Herbert Xu wrote: > On Thu, Apr 07, 2022 at 12:01:02PM +0100, Catalin Marinas wrote: > > The only issue is whether the compiler gets confused by a pointer to a > > structure with a smaller alignment than alignof(struct ...). I don't see > > a performance or correctness issue on arm64 here. It would be a problem > > if instead of 16 we went down to 8 or 4 due to unaligned accesses but > > from 128 to 64 (or even 16), I don't think it matters. > > The issue is that there's code in the Crypto API which assumes > that all pointers returned by kmalloc are aligned to CRYPTO_MINALIGN, > if you break that then all that code would need to be modified. I'm not familiar with the crypto API, trying to make sense of it now ;). I can see in many cases that the kmalloc() caller aligns the requested size to something like crypto_tfm_ctx_alignment(). So this would guarantee a kmalloc() object aligned to CRYPTO_MINALIGN. > However, I think it's better to change the code that assumes > CRYPTO_MINALIGN guarantees DMA alignment. I saw Ard already started to refactor some of these. But in the meantime are there cases where the crypto code does a kmalloc() of less than CRYPTO_MINALIGN and expects it to be CRYPTO_MINALIGN aligned? -- Catalin