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 9246FC433F5 for ; Fri, 15 Apr 2022 10:04:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF2D86B0071; Fri, 15 Apr 2022 06:04:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA24D6B0073; Fri, 15 Apr 2022 06:04:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D42556B0074; Fri, 15 Apr 2022 06:04:26 -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 C3BC56B0071 for ; Fri, 15 Apr 2022 06:04:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 87CC560FAF for ; Fri, 15 Apr 2022 10:04:26 +0000 (UTC) X-FDA: 79358678532.05.6378774 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id BE0F24000D for ; Fri, 15 Apr 2022 10:04:25 +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 CF35162209 for ; Fri, 15 Apr 2022 10:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 373FFC385AF 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-f44.google.com with SMTP id c11-20020a9d684b000000b00603307cef05so1512637oto.3 for ; Fri, 15 Apr 2022 03:04:24 -0700 (PDT) X-Gm-Message-State: AOAM532WLMZ3EnMcafBXeRfEU6pXEAPSvreBcLnWaFR8jlwmCBGHD+FO rWyScDkrQnLpvIMl6Q+I0mI2YY+meu6l+USecRk= X-Google-Smtp-Source: ABdhPJwU70pH3XY/94+KsBUHK1RylEVUJE34qOIC68RiNARuOX/QRwjDCFRpG1e7QtV7WGvz2X6ufQrKLfnI3dRh9ng= 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-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BE0F24000D X-Stat-Signature: 9weyrkscx1ew4y8pwxksumeujmjic9fg Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FrQNqMYQ; spf=pass (imf07.hostedemail.com: domain of ardb@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=ardb@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-HE-Tag: 1650017065-840586 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, 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'