Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1015623pxb; Fri, 15 Apr 2022 18:26:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyY9qXHkPPE0hOwb08kjs1/YgjZIBJXsPYhkAF2cDOt8xMDMT4+padBlqcBh/wDNX2TR+r X-Received: by 2002:a05:6a00:1687:b0:4e1:45d:3ded with SMTP id k7-20020a056a00168700b004e1045d3dedmr1560402pfc.0.1650072365784; Fri, 15 Apr 2022 18:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650072365; cv=none; d=google.com; s=arc-20160816; b=tN0+VpmI5tUIcNssV86dIw6R2E3KqOWyir47+u5GLq5BW09c4KPdESu8WTgTTZDehj RNjRWmPyL1iwuoKyz7Inr1VWF+xBzYdy3vlgYSUmAbe15GUCwGbGjcgzDMHd3rTx+d61 2rWgv8bZQ1dEuoBTfMYdr/nGToXtIiRJFomJ7+et0AzWWAmxnGVs5WLxLIEuwP28cR8X ZdekNjaEhf5Lj4BNdaFun75dsch4Q5/ARcfaIo0hW7Zh3OIgDxL+2v3/N+5ctajJ5mRP vpJTZcglWlfkImJXgpb73lFXP5ICtQLft0hSFoFJZ3U8BJMIzeWS78zZhdaaAKaMfQBd C6yQ== 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=ulID0mFp0o/slLJmHXEWFBkj8xgm3Jh9DaRw8ISITSs=; b=waMWGKhWbxRt0Vdvf8NMTFgh+EVXEuLW4I9nrVEIyN4X7pMpEYJBrl6gehCn8Ul2gL EH8ICaeXx8OW+OjrVtW/T8GrnGQ5SXz8cJhwJvbSsGHGuaNVvvHisvwWL7vPhOWCu8I8 PjIZo4c3MDEj4AUiqyAdnj/LfTvu79NET0frYz/gXqxhR11nr4MTrNQEiWteEqTSRQ/p GDXQo+F3Tr2DH3QK87rNLJ96JAAuNgAN6lcNe3ay+30uVZVt4+UCpQQzSUxY2C2A5a5P lZv6VHV1fKLV3aBc0+xK0fhPiihW2qzSPLY6qPb8baUdR2dZ6jOBA1j3v0q1D/Q7ek8H wwBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FrQNqMYQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z10-20020a17090abd8a00b001c68e9e0e68si5650381pjr.36.2022.04.15.18.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FrQNqMYQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 9E5002C650; Fri, 15 Apr 2022 17:57:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352110AbiDOKGz (ORCPT + 99 others); Fri, 15 Apr 2022 06:06:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235926AbiDOKGx (ORCPT ); Fri, 15 Apr 2022 06:06:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8C4306 for ; Fri, 15 Apr 2022 03:04:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CC7D862201 for ; Fri, 15 Apr 2022 10:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3128BC385AC for ; Fri, 15 Apr 2022 10:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650017064; bh=fufug+gcC7ZO4O5R0DBgcSd0Eygy++xXyqo7O+o4vUw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FrQNqMYQG2MSiKwACMPKXrfcXEz35ecDQaAe8ZYwbJsQdainmqHvBG6PlUEw9YnHW cNufHNHXTi/2AQcabJlwOC6PUBIwM3lkvp5Ep6kGa7KaQS8wlMHdlVMyUoGO+K4I3j W1+9jKz4oH+9P9y6g7Iy4QADzFRiH0t/czGOCi+bO3GWEgwdtNfnt1oAgEBG+uNqKS mb3abvGL40VHXu+efI676EUP0Zie8lfZifTzYitcvlzX6cT7yaoJUe7Yt5LEZNOLzP ZMDvVuqh1VlLklfqo6BzfUuYy5OtU3ERfv/0qqW/+FADdUOcK206zMDCNstrl3UAYx Xl3lbg8dZkolQ== Received: by mail-ot1-f52.google.com with SMTP id e25-20020a0568301e5900b005b236d5d74fso5140262otj.0 for ; Fri, 15 Apr 2022 03:04:24 -0700 (PDT) X-Gm-Message-State: AOAM532Mni7iaEmJpMPL7kY11DaMfZzPPXFXTYUZhJGVZoc0tI6kMQVQ wNFd7zvm9mRYJ6SHpsE2bQqfJ2UdMp7hI53rDuA= X-Received: by 2002:a05:6830:2e7:b0:5b2:68c1:182a with SMTP id r7-20020a05683002e700b005b268c1182amr2389611ote.71.1650017063343; Fri, 15 Apr 2022 03:04:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 15 Apr 2022 12:04:11 +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 11:51, Ard Biesheuvel wrote: > > On Fri, 15 Apr 2022 at 10:12, Herbert Xu wrote: > > > > On Fri, Apr 15, 2022 at 10:05:21AM +0200, Ard Biesheuvel wrote: > > > > > > I guess that should be fixable. GIven that this is about padding > > > rather than alignment, we could do something like > > > > > > struct crypto_request { > > > union { > > > struct { > > > ... fields ... > > > }; > > > u8 __padding[ARCH_DMA_MINALIGN]; > > > }; > > > void __ctx[] __align(CRYPTO_MINALIGN); > > > }; > > > > > > And then hopefully, we can get rid of the padding once we fix drivers > > > doing non-cache coherent inbound DMA into those structures. > > > > Sorry, I don't think this works. kmalloc can still return something > > that's not ARCH_DMA_MINALIGN-aligned, and therefore __ctx won't be > > aligned correctly. > > > > 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. Let's rephrase that as 'must not share a cacheline with the preceding fields, and the worst case we expect to have to deal with is a cacheline size of 128 bytes'