Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp428020pxb; Fri, 15 Apr 2022 03:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKQBf8BcBmdPKkGbJXqbBmi4XIQQQQTzrBXp9+fpf3nDJXjWZyK2H0sWc2EucQa7Y/UO5P X-Received: by 2002:a17:906:19c6:b0:6ce:98a4:5ee6 with SMTP id h6-20020a17090619c600b006ce98a45ee6mr5579682ejd.567.1650016812758; Fri, 15 Apr 2022 03:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650016812; cv=none; d=google.com; s=arc-20160816; b=M6xWMIOQfT9PPPo0A2yaOa9tfW7KphVhrD9Z1amYuLCwEOrtVwdJRVMv8gCzCyQmLC 5+g/0HLrjUogd3tejhsFUt2HnoRF6iCPSVPWCkowkzMzpyDiPU6YgHlLYYyu8rOVpjUB +Ld3I0TsbkcJPXUOmElibVI2kno/hjiO8BRIWlawJcvwt3L79YDgzzjabCfEjO/ogxvS nlpXZD/P7N4dC65NZkOfKsEWiuZ6zCL8lQM+/MkLIgAJz13YQi32YEecmBC+a4OqruwP FmTmD3VP8VMxu0yJ2Cc38J77RRYWGbiRp59DpIpmp+aLA8dHCCShIYTQTxZ29LUalN4+ LcYw== 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=Jc8MIBPAZ3DvtfrPwxiXzTcwcHh6EYZIlJe6KYkgSKk=; b=EHP7SV2sLqiAbHJWiDWtZ2QF8umC8gBjTpMsEr9Gbqo0YsCJy4kWQh4XlKDANh9p9I 0Z0yhg3X2m22KbG5vfzuq2gBwBuIotw1P2RqT5BFLtjedM5D17LIv1lR2rxJO4U7pOAX ZqTTruLC9wDiBZKXzqp8eEy157uasuZlzkeSpC9Ihk+e05eF5mYjzjgFcy6ryAB3+jDh jmDZif5gUjkrlInmzgOkR648h7+/Mg+ui1V2E+gRKaYDcGya2eV0nnSwAp8PVLh7Eyr2 5YLMqPxjxiuXmg1OdJTvLokTiZnSLxE4yExk2AZtTKglCGB5zG6OKZ/p6W4d42WwOXJd Ceyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CcENbH42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a17090682da00b006e8b1219735si699488ejy.8.2022.04.15.02.59.45; Fri, 15 Apr 2022 03:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=CcENbH42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S1352176AbiDNPkp (ORCPT + 99 others); Thu, 14 Apr 2022 11:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353649AbiDNOkp (ORCPT ); Thu, 14 Apr 2022 10:40:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65BE1B1AA3 for ; Thu, 14 Apr 2022 07:31:09 -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 1AC4AB829D8 for ; Thu, 14 Apr 2022 14:31:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1C5AC385AC for ; Thu, 14 Apr 2022 14:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649946666; bh=sYuRIOKotPt+JjyagaULCK/sP+wsew5Z8mm0QqMhM8U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CcENbH42U2QOdZU6S5pxfFHY6fuFidAEmlWORZn+hRWfPmnkWM0khYKDmhmWy6nKE HcPJiYN36zT7FPyRqI0V7826IYn5fGdcB7FjOWRNIiZMsZ9NKVOz/Xb+18yc9jlnst XPIZRI5MU8cY+8TVgowcOOCe0R40qmduwyuSmhygD6MMJD0zhSDGUeWlvPg3K7PDdD joCzBvjrWmCk4tWQHRNgWUoTTqIXbJyUZYrMOqDAUB2YkBVCoN0Hp6UjATx0OPevoa Rne1FmfRBU/dGNko5Na1Q47migtPTwlGzi/qTui+cfR93RIXZL5oCA7dIMc/73MwHs eVqhUvvdEarLA== Received: by mail-oi1-f169.google.com with SMTP id k13so5592095oiw.1 for ; Thu, 14 Apr 2022 07:31:06 -0700 (PDT) X-Gm-Message-State: AOAM533Yzb8K4hzTiiOIHcFuL3r946GJ4xl6q65XKiDi5GSr8LHyS5R6 gtgBkO+ThVrtdraSHPVsbsO+KTlFUrhIwSpqzKA= X-Received: by 2002:a05:6808:1596:b0:2f7:5d89:eec7 with SMTP id t22-20020a056808159600b002f75d89eec7mr1816562oiw.228.1649946665844; Thu, 14 Apr 2022 07:31:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Thu, 14 Apr 2022 16:30:54 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN To: Catalin Marinas Cc: Herbert Xu , 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=-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,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Wed, 13 Apr 2022 at 10:47, Catalin Marinas wrote: .. > > Let's go back to restating the crypto code alignment requirements, as I > understand them (please correct): > > 1. Bus master accesses (DMA, CPUs that can't do efficient unaligned > accesses). That's what cra_alignmask is for. If there's a driver that > relies on an implicit kmalloc() alignment higher than cra_alignmask, > it is already broken on x86 and a few other architectures that don't > define ARCH_DMA_MINALIGN. But it won't be any worse with this series > since it only brings the arm64 kmalloc() alignment down from 128 to > 64. > > 2. Non-coherent DMA and cache invalidation. With my series, kmalloc'ed > buffers are DMA-safe for the CPU/SoC the kernel is running on. > > 3. DMA into buffers embedded in TFM structures. Since the offset of > those buffers is decided at compile-time, we need a > CRYPTO_MINALIGN_ATTR that covers both bus master alignment > requirements and the highest cache line size (CWG) for a non-coherent > DMA SoC. Ard's series would simplify the latter but, before then, > CRYPTO_MINALIGN needs to stay as the larger ARCH_DMA_MINALIGN. > > With my series, there is no change to the value of CRYPTO_MINALIGN for > arm64 or any other architecture, so point 3 is unaffected. The series > does change the kmalloc() alignment and that may be smaller than > CRYPTO_MINALIGN but neither of points 1 or 2 above are affected since > (a) we still have a sufficiently large ARCH_KMALLOC_MINALIGN of 64 and > (b) the kmalloc'ed buffers are safe for non-coherent DMA. > > Herbert, Ard, if I missed anything please let me know but based on my > understanding, this series is safe for the crypto code. > Agreed.