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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDEC7C433EF for ; Thu, 7 Apr 2022 16:28:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C78FE6B0072; Thu, 7 Apr 2022 12:28:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C27BC6B0073; Thu, 7 Apr 2022 12:28:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEEB96B0074; Thu, 7 Apr 2022 12:28:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id A018D6B0072 for ; Thu, 7 Apr 2022 12:28:29 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6F38622206 for ; Thu, 7 Apr 2022 16:28:19 +0000 (UTC) X-FDA: 79330615518.05.B9A872E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 935611C000E for ; Thu, 7 Apr 2022 16:28:18 +0000 (UTC) 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 BA5BE60B1B; 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: X-Stat-Signature: upmsjti8oq1nnnq19ye7ugfbb9xq8tch Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 935611C000E X-HE-Tag: 1649348898-951593 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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