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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3B6DC433EF for ; Thu, 7 Apr 2022 11:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A2vwVsJ92gUmSPW2lwCc+gBWVbiG1Ykn6a8eUmR7liQ=; b=g2RWKPhORDmyy6 ao9vajE/NuUOFcE+4wbvHxR8mJZFGPHNNRS4Naw0CQF4KPYTUsznWRzu+yZZUie7CMf27A4i2J2EZ hAL7v+ZMJdBeUiCZuxqTx3YD1hFOez1n+lFA7oHlu6edWzpSQ1jkWAhwVJk+qfAjEU7RgAV1S9U3M Np34xhsjvYDF7kGjQ83chwQjNe0v2C1f7GZ9cpVPZyHotJCq38gUdMyZiWC4+Yh4RBWwUVR+qEqnh 3z1fMNcHZgZuMjmQuBoeKqe11Tdl3y5wnYcklOGh84MbvL0bCnNYT9pQNUcu6fokFbGiZlI+EA4Nj ZtCC8HAwdvx7jvwDKsgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncPu1-00BRVP-2M; Thu, 07 Apr 2022 11:02:14 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncPt1-00BR71-Cq for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 11:01:13 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id A906AB81A13; Thu, 7 Apr 2022 11:01:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5464BC385A4; Thu, 7 Apr 2022 11:01:06 +0000 (UTC) Date: Thu, 7 Apr 2022 12:01:02 +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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_040111_617868_0333F8DD X-CRM114-Status: GOOD ( 21.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 07, 2022 at 02:30:54PM +1000, Herbert Xu wrote: > On Wed, Apr 06, 2022 at 09:49:42AM +0100, Catalin Marinas wrote: > > is any change to the crypto code. > > But the crypto API assumes that memory returned by kmalloc is > automatically aligned to CRYPTO_MINALIGN, would this still be > the case if you change it to ARCH_DMA_MINALIGN? No but I think that's a valid point. Taking the crypto_tfm structure as an example with ARCH_DMA_MINALIGN of 128: #define CRYPTO_MINALIGN 128 #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN))) struct crypto_tfm { u32 crt_flags; int node; void (*exit)(struct crypto_tfm *tfm); struct crypto_alg *__crt_alg; void *__crt_ctx[] CRYPTO_MINALIGN_ATTR; }; The alignof(struct crypto_tfm) is 128. However, a kmalloc() would only guarantee the smaller ARCH_KMALLOC_MINALIGN which, after this series, would be 64 for arm64. From the DMA perspective there's no issue with the smaller kmalloc() alignment since, if a crypto_tfm pointer is DMA-aligned for the hardware it is running on, so would __ctr_ctx[] at an offset multiple of the dynamic DMA alignment. If we used ARCH_KMALLOC_MINALIGN instead and the hardware alignment requirement was larger, than we would have a potential problem with non-coherent DMA. 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. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel