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 A65ACC433EF for ; Thu, 7 Apr 2022 16:42:54 +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=04toP1CqpWk3OzFrnbD2VbdWXpFk0Gb669Fw7upZylQ=; b=nXyUDASNtpTYT4 A87xge4U8Z6VtJM517lKX4LhFi1oAi1mg2YLwuRSmZSXCQmSdBhmaKUWbWUed3UiRNYw+KGGXeIAV jGJG8tiEHeo/ZwpP+R/kQtFLtz9KNVmr/d4UkmbjIok6kh+/Umw1Od5L7lmv5BD4z/tn2S/LXDNBx XMcxLGUz0z42XMOitGeu6SvBP1sqi7rfZPwzVxRcMrEpeBmITMkmsRURdSJMnEB6iu1qpLA5pt2V3 K4mRVDmSxsgztdiQAdXgKF6nF9RWGwhBueM4EXMYfpb1iKIwUFspo5t75B/IV3zkTpDjKVozv98r8 8NgtmDSol0cLNd/lirJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncVCP-00D9D7-Qu; Thu, 07 Apr 2022 16:41:34 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncUza-00D3lT-K3 for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 16:28:20 +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 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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_092818_747043_D73E79B6 X-CRM114-Status: GOOD ( 23.17 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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