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 775B2C433F5 for ; Sun, 17 Apr 2022 08:39:51 +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=uT36xOjatcyQ89enYvHsLMfq3d3b0xLVphnoKbQntNs=; b=LQ7g0iXf+YqOOT KfjIS/DOSTlM9caq5fliocqgd6zAtlX9g1pLgsq0omkDxgsFDlp7h0bGMZweyfnVo5gYNnmakhUuO qp3JZeIqKzSuYa2fXJp58WGUHZQNS7bamy/V2wqYwFQI0y71vu6A+qAr1+e5l3dfGg7gZ4k/1oMM4 gjIM9paZurBIAFWkuMKlrO0Dfh3tMa7UCesfKSfjQT2VUg5HWgACgK/iPvrjXyyXPChqpDz1HgYgo TnMOROWTKFcKjFb49GNUPfYHb4wiLs2m9djs5v7tEAqu0MGopdp6RHhCv1OeUYUqHQQsW8UyHoryw fXP8LZkbwh87F5ybXatg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ng0Qk-00E6Tk-AU; Sun, 17 Apr 2022 08:38:50 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ng0Qh-00E6Sr-8S for linux-arm-kernel@lists.infradead.org; Sun, 17 Apr 2022 08:38:48 +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 8A1756115A; Sun, 17 Apr 2022 08:38:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8B32C385A4; Sun, 17 Apr 2022 08:38:43 +0000 (UTC) Date: Sun, 17 Apr 2022 09:38:40 +0100 From: Catalin Marinas To: Herbert Xu Cc: Ard Biesheuvel , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , Linux Memory Management List , Linux ARM , Linux Kernel Mailing List , "David S. Miller" Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: 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-20220417_013847_380852_C28A4EF0 X-CRM114-Status: GOOD ( 24.04 ) 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 Sun, Apr 17, 2022 at 04:11:22PM +0800, Herbert Xu wrote: > On Fri, Apr 15, 2022 at 01:31:32PM +0100, Catalin Marinas wrote: > > > > This needs a clarification. For the above structure, kmalloc() will > > return a 128-byte aligned pointer since sizeof(x) is a multiple of 128. > > The potential problem is if you have something like: > > > > kmalloc(sizeof(struct x) + 64); > > > > The above could end up as a kmalloc(192) which is available with an > > ARCH_KMALLOC_MINALIGN of 64. If that's a real use-case, I can change the > > slab patch to not create the 192 (or 48 if we go for an even smaller > > ARCH_KMALLOC_MINALIGN) caches and we'd always have ARCH_DMA_MINALIGN > > guarantee if the structure itself is correctly aligned. No lying to the > > compiler. > > Yes I suppose that should work: > > 1) Enlarge each crypto API object so that they're >= 128 bytes; I don't think we need to do anything here. A structure like: struct x { char y; char z[] CRYPTO_MINALIGN_ATTR; }; is already of size 128. Without CRYPTO_MINALIGN_ATTR, its size would be 1 but otherwise the whole structure inherits the alignment of its member and this translates into an aligned size. > 2) Modify kmalloc so that for sizes >= 128 bytes they're padded > to multiples of 128. This doesn't look like a hack, we want to honour the power of 2 alignments. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel