Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp10390396rwb; Fri, 25 Nov 2022 04:18:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf6f7REVRtTc0U3eQPSSqEp7qnajSoRPH6sFVGopfpTVzlVoQ0jtU6U/FJOxeSQe1BYNlkzu X-Received: by 2002:a17:903:300c:b0:186:aed3:3ab7 with SMTP id o12-20020a170903300c00b00186aed33ab7mr18527238pla.88.1669378726234; Fri, 25 Nov 2022 04:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669378726; cv=none; d=google.com; s=arc-20160816; b=Z/WmNmlCyI5J0/e6oWMFhxxilUe69T3VmzJOF2hSblZGwYSD2c9XcBekAxjSjt2Anh qNlmjSr+jjzw+fti+Ca6F/d2jR6Ovzp/UXzD9hnjwRD1ji2x0kBW0CaDrLUW7LNw5ZIx hCPnFSTaymDd8gavGAWcdhWeh1vq9gyzIXozuPXNMRwk2jQq3hbxH2+QwK4cK+OMONcI EPMqY5fp4Qp8JBK9dBmYSRdpW8zjJ1pJNpzgNjD8P3/qBU5s74ueZuh4Rctv4IwkmOpu BbshzPoxAGKzDPYGNNjWMRrJdELX1RHQ3iZ0cm+gyNXbfA5dQ+QwuPV6BVqdRQte0GrJ Xt0g== 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=2QQ3gkT8M4ne/f/6SMJfPCcoYNo2dNjFDj4PF9DSWIc=; b=ycbxmsuFiB7SKN1Bipqg/37L2W/Y0xvy1WFZnC6Ou/YMB5ZrqIYoaoq/QbgfKob02Y yZ3/1s6HByF4369U1iyKgritkddkcpDAabKIysKIb9t7LLn4J5GdkysKXVvn8W7tHgVg XkjwpI66cIkI0/fpOjC1fhpwCiZ9kbo1JK6GuAzLHuKqrY8HX4yY1LZoNpS3SgbUo38n yilm7jkfXi1w5Wa1SVvPqLXq9cQ8FgqQpt77MMjy4AWhYQMMXlBVHpjKkZBWa6gvKHSs Q/JftfDfl3Qpo9pXcyAbj44YuQ1VxPRhJpIpJvd4BLnKtG5LFM8tx/Y6Vij8iRCCBJ34 VJgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HurY4q/y"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a632019000000b004772bd7e38esi3956811pgg.868.2022.11.25.04.18.25; Fri, 25 Nov 2022 04:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HurY4q/y"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbiKYMSK (ORCPT + 99 others); Fri, 25 Nov 2022 07:18:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbiKYMSK (ORCPT ); Fri, 25 Nov 2022 07:18:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9660217419; Fri, 25 Nov 2022 04:18:09 -0800 (PST) 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 3262A623BC; Fri, 25 Nov 2022 12:18:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AB08C43470; Fri, 25 Nov 2022 12:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669378688; bh=2QQ3gkT8M4ne/f/6SMJfPCcoYNo2dNjFDj4PF9DSWIc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HurY4q/yF+peulV7cvOO7tegNpqJMAftwxJ/HfA90kCJRh5gKLHbacaMXDqq4TBBF UnZJqEzFBWuFNipA/KgLMK7QPG1SIOaKjAU1NW5bQ/rB87Hwbz0LDOXjl81jbkaOR7 xq4peTK2aiu/PiYMyds1P5XvlAZNzJhc4K7/xPDpdmU2e82pfQCBhYel2eSN0JfJLC 3Ue3BuPUJWq11QwyzHluDrzKqvVgYUFHJn3jgZLozJOQKSxWtkW37sh3rZj1zbYdrt sjSkueGKaQ5qeJYk1l7CC+09XMVJM2576vH2pHzGbL+NI+ySnJSEtHauEdXTG+HVr1 6PMqs4Dr3V1Og== Received: by mail-lj1-f175.google.com with SMTP id a15so4975647ljb.7; Fri, 25 Nov 2022 04:18:08 -0800 (PST) X-Gm-Message-State: ANoB5pmy8xs7+GWuk5H/kPP14SMilP3GYuE7XwzbbZcLoV3/SrkM5Xor 5toyO4KeoObPC3j3VsC80aFtqJy5jGhrP0HLuAM= X-Received: by 2002:a2e:95d2:0:b0:277:96a:5c32 with SMTP id y18-20020a2e95d2000000b00277096a5c32mr11115105ljh.415.1669378686498; Fri, 25 Nov 2022 04:18:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 25 Nov 2022 13:17:55 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [v2 PATCH 0/9] crypto: Add helpers for allocating with DMA alignment 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" , Linux Crypto Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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-crypto@vger.kernel.org On Fri, 25 Nov 2022 at 05:35, Herbert Xu wrote: > > This patch series adds helpers to allow drivers to explicitly > request ARCH_DMA_MINALIGN when allocating memory through the > Crypto API. > > Note that I've only converted one file in one driver as this > is only meant to show how it's done and find out what else we > may need. > > Other drivers will be added later. > Hi Herbert, This approach seems conceptually similar to what I proposed a while ago: https://lore.kernel.org/all/20220406142715.2270256-1-ardb@kernel.org/ If we agree that creating a distinction between ordinary allocations and ones that are rounded up to DMA alignment is ok, I wonder if we could minimize the churn by simply choosing between one or the other by taking the CRYPTO_ALG_ASYNC flag into account. On x86 and other arches that don't care about the distinction, none of this has any effect anyway. And on arm64, only hardware implementations use the CRYPTO_ALG_ASYNC flag, which makes its presence a reasonable heuristic to decide whether an algo implementation is backed by hardware that relies on DMA (the penalty for getting it wrong would be to use DMA ailgnment unnecessarily, which we already do today anyway) We'd still need changes in the generic crypto layer to distinguish the two cases, but we wouldn't need any changes to the drivers, which seems like a huge benefit to me