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 4FBC7C433EF for ; Fri, 8 Apr 2022 09:11:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF02B6B0071; Fri, 8 Apr 2022 05:11:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9FFA6B0072; Fri, 8 Apr 2022 05:11:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B47D76B0074; Fri, 8 Apr 2022 05:11:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id A17AF6B0071 for ; Fri, 8 Apr 2022 05:11:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3D3DDA45D6 for ; Fri, 8 Apr 2022 09:11:46 +0000 (UTC) X-FDA: 79333144212.21.06FF7BE Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by imf30.hostedemail.com (Postfix) with ESMTP id 0DFA580007 for ; Fri, 8 Apr 2022 09:11:44 +0000 (UTC) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1nckeN-000Szc-Vn; Fri, 08 Apr 2022 19:11:29 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 08 Apr 2022 17:11:28 +0800 Date: Fri, 8 Apr 2022 17:11:28 +0800 From: Herbert Xu To: Catalin Marinas 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-8-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0DFA580007 X-Stat-Signature: 3r57caji7hdw9kkzwjt3sio163nxsryp Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of herbert@gondor.apana.org.au designates 216.24.177.18 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au; dmarc=none X-Rspam-User: X-HE-Tag: 1649409104-890724 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 Fri, Apr 08, 2022 at 10:04:54AM +0100, Catalin Marinas wrote: > > My point is that if the crypto code kmallocs a size aligned to > crypto_tfm_ctx_alignment() (and CRYPTO_MINALIGN), the slab allocator > will return memory aligned to CRYPTO_MINALIGN even if > ARCH_KMALLOC_MINALIGN is smaller. No we don't align the size to CRYPTO_MINALIGN at all. We simply assume that this is the alignment returned by kmalloc. > Would the crypto code, say, do a kmalloc(64) and expect a 128 byte > alignment (when CRYPTO_MINALIGN == 128)? Or does it align the size to > CRYPTO_MINALIGN and do a kmalloc(128) directly? If it's the latter, I > don't think there's a problem. It's the former. I think you can still make the change you want, but first you need to modify the affected drivers to specify their actual alignment requirement explicitly through cra_alignmask and then use the correct methods to access the context pointer. Basically these drivers have been broken from day one, but their brokenness has been hidden by the extra-large KMALLOC_MINALIGN value on arm. So to reduce the KMALLOC_MINALIGN value, you have to modify the drivers and set the cra_alignmask value. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt