Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp59490lfe; Fri, 15 Apr 2022 19:27:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlVZy3KqldHMWTDHtamYK63y3RzE2LdgbGtf0p6oMRBD6YEvFYZo8c4W0l9b6DRZ+ien4f X-Received: by 2002:a05:6a00:24cf:b0:505:d9fd:e415 with SMTP id d15-20020a056a0024cf00b00505d9fde415mr1639985pfv.78.1650076039811; Fri, 15 Apr 2022 19:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650076039; cv=none; d=google.com; s=arc-20160816; b=r4HxPzSFgm+JkrlUDXRwzBWOmx74OvRsBziV/Bv8gQUcQ7INKrz3iLIn/EG/TUWo8g Q/Ar7YUY3KN5dpHO/TT5lyDS0T7q5cen4MR8dGeu6xyDD/CcdQMFS2arP1E8Ha6iPcjP MdCY/rKKac6dY2icVlQ6Bq3687TFfjIr/mZu9BHB5orWiQpnKXg2QQYYZ1u4g8HouHS2 vZH7bQn1fm7aY2LHOo0W2VutThMBQJXY9DQE7lVnPEDEZbuSf1v1bCZKJNE+QcupwWqp bojDswQ/ioSWGl4joHlQTDSn5NSoS2OUuILWg1X2k3cau9OtXVcX59YhYqF+fIRq4jAA kbPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SG53jx5hbACDasyAwOVcOuCZSp72pRLMI6HQk8fNWEs=; b=Gtx0RBhuBd+BiiX61n70OYBKFd/0NwPzgecB6SFjp+rG/Ie8fUg9UBZ16N2kw8qxN+ 1UQwlViIOQmiRbL5e1g24QEgmjMLgfzjJjxSMYJ9//YEKw2L7XjPu6NEwzP2IednblaZ yWsw8UO/P6AlnUxp1sEhXqVs7EH4dG1urg/vXteJg1T4I9QC3yKNZN0MIFMa6o/sKRdy 0fd95/6W8F81JEREZ9cUjFUwpwX2RorFqHIve9VdL231vRnWKSfesFV88XhtJXojnCtq iGzTxtiHW3ZZjxThg1c7GmS3t/+zd0P6T+7AOnm3Rs+coVPsuBxw1lBy1ca8Fewim8n5 DbTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dcw52qmW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v10-20020a1709028d8a00b00153b2d165f5si2730329plo.509.2022.04.15.19.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:27:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dcw52qmW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11C5C189987; Fri, 15 Apr 2022 18:39:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343884AbiDOKZP (ORCPT + 99 others); Fri, 15 Apr 2022 06:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343614AbiDOKZL (ORCPT ); Fri, 15 Apr 2022 06:25:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B283BBE04 for ; Fri, 15 Apr 2022 03:22:43 -0700 (PDT) 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 D4B44B82DD8 for ; Fri, 15 Apr 2022 10:22:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75248C385A6 for ; Fri, 15 Apr 2022 10:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650018160; bh=SG53jx5hbACDasyAwOVcOuCZSp72pRLMI6HQk8fNWEs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dcw52qmWSkF0C9prN3DgM/DAnY31QNvXcaAJuTozCYDGH7UhMNRKVSfiFAfO2Pr8T 8aFOi99RO5C92uA7ePh4Z+TzNs1nzwOmEBSgG1MhiCcJhrp3+FySk256HAZWgMXkLW VUsRymlGVg4MwQTK3BMjlNgPZkT9aLq3G14tfOUCmJCTsWtxmRVgnBdtJTy7sxJRrE XWJHNxeFwhN20uORbqeEnDe4/qH081DJM3jA+g6cqWpEFeAX2izl3LN8M3amVZtoYd n2KfZjKTaUAA9GWOb1T5gY1YgF2UlnKyUsCFZbNKstXEJMCv1SUfDjYDLmHxvWabJX 34CCovi16nqxA== Received: by mail-oi1-f178.google.com with SMTP id t15so371182oie.1 for ; Fri, 15 Apr 2022 03:22:40 -0700 (PDT) X-Gm-Message-State: AOAM531myr0MpaV0hSOch6Zg+Tc8/qWKJKmoJzHDO2CL+rzTUHzulnXJ 6hnm2f8TulZhneNsZWecNYli2w5xy4s+7JvDO6U= X-Received: by 2002:a05:6808:1596:b0:2f7:5d89:eec7 with SMTP id t22-20020a056808159600b002f75d89eec7mr1320830oiw.228.1650018159669; Fri, 15 Apr 2022 03:22:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 15 Apr 2022 12:22:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN To: Herbert Xu Cc: Catalin Marinas , 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" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Apr 2022 at 12:12, Herbert Xu wrote: > > On Fri, Apr 15, 2022 at 11:51:49AM +0200, Ard Biesheuvel wrote: > > > > That is the whole point, really: ARCH_DMA_MINALIGN==128 does not mean > > __ctx needs to be aligned to 128 bytes, it only means that it should > > not share a 128 byte cacheline with the preceding fields. So if > > kmalloc() returns buffers that are aligned to whatever alignment the > > platform requires (which will be 64 in most cases), the above > > arrangement ensures that, without requiring that CRYPTO_MINALIGN == > > ARCH_DMA_MINALIGN. > > What if they started sharing a cacheline with the subsequent object? > I guess you could add some more padding at the end though. > Subsequent objects are owned by the driver, and it is the responsibility of the driver not to modify the fields while it is also mapped for DMA (and we have had issues in the past where drivers violated this rule). So as long as ARCH_KMALLOC_ALIGN guarantees actual DMA minimum alignment for both the start and the end, we shouldn't need any explicit padding at the end. > I could accept this as a temporary solution, if you volunteer to > modify all the affected drivers so we can get rid of this bandaid. > I'l do a scan of drivers/crypto to figure out how much we are relying on this to begin with.