Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp41593pxh; Thu, 7 Apr 2022 13:22:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd14a864QDB1/gGR+is+uVBM+VNig58wL1Zxbp8zZlyLbSmmmRkEJXQRC89Jdq72x8LQ/j X-Received: by 2002:a63:b55d:0:b0:398:5eeb:e637 with SMTP id u29-20020a63b55d000000b003985eebe637mr12278353pgo.314.1649362975812; Thu, 07 Apr 2022 13:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649362975; cv=none; d=google.com; s=arc-20160816; b=H4K3f7/eyesKqeWZDT9KC4aDrKhEIymINVfiQydc1kxVj7ogf+xReTCAupok/fIfS1 wf5fwMLcZrvH/dOnbS54s2ogvEenYdeXgtGXbqwE+b+1QVWmcZiqNiW0FJYoQyUebiDw kTLRdpml5LjBqutxgr9Jzc4gEH1WmNvco9+/3XysOLenSxWHebvOHRO6NOZzUBc9mbIX Eu0s7oWhs3uXNeBzQ6l1yURASbti9uKaWGco5ugYnU63SjgOAw0FUPZQMnIqh22r733c P1JAD4u7mIG8q0w8hf3gE0WA/uQf02/Fu9oqq1Pg/ZJ3SNrDxuwDJwDYH90msUJbWkvG 6lPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=79E22cLfdrA6f17w8mfncEDeQhqMJxLcejXgU9jAOkY=; b=VhGpD/ayz4XmMr1kizSSbhcJgPGWJfPEXEcTfHe79ApUmVVSQp4MmduD0M3QAYWwdR +B3TL16HI3GjATnW6VHgDljHQH2JDK6SMPf/I78bqN9HmuytOZUj5D+ZByXaeKlnf4JL +XpyO+seL2zwSv+Ij9r0nTKYjg8EEdbLbcX1jFNql9NLO8Nu/l8qh2Ka17NOOPy9mv5L BFdsqQayXwyG2cld0JGi1ex9TfoQOJ+kmww350FBz7d/2x80P87b8nAJncUv7kpxL1RE 4jrZjMgK8S6TcyKttXZe9iVjD3+6YHn6gQ7WZYeosj8LDfAT5k/e9BAkfyIbeXFqlFEy UGmA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 37-20020a630c65000000b0038203e0be84si19563490pgm.605.2022.04.07.13.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:22:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B9EFB3568D2; Thu, 7 Apr 2022 12:41:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345681AbiDGQav (ORCPT + 99 others); Thu, 7 Apr 2022 12:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbiDGQas (ORCPT ); Thu, 7 Apr 2022 12:30:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F55824951 for ; Thu, 7 Apr 2022 09:28:48 -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 BF68B60B4D for ; Thu, 7 Apr 2022 16:28:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5421C385A0; Thu, 7 Apr 2022 16:28:14 +0000 (UTC) Date: Thu, 7 Apr 2022 17:28:10 +0100 From: Catalin Marinas To: Herbert Xu Cc: Ard Biesheuvel , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "David S. Miller" Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-8-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Apr 07, 2022 at 07:40:59PM +0800, Herbert Xu wrote: > On Thu, Apr 07, 2022 at 12:01:02PM +0100, Catalin Marinas wrote: > > The only issue is whether the compiler gets confused by a pointer to a > > structure with a smaller alignment than alignof(struct ...). I don't see > > a performance or correctness issue on arm64 here. It would be a problem > > if instead of 16 we went down to 8 or 4 due to unaligned accesses but > > from 128 to 64 (or even 16), I don't think it matters. > > The issue is that there's code in the Crypto API which assumes > that all pointers returned by kmalloc are aligned to CRYPTO_MINALIGN, > if you break that then all that code would need to be modified. I'm not familiar with the crypto API, trying to make sense of it now ;). I can see in many cases that the kmalloc() caller aligns the requested size to something like crypto_tfm_ctx_alignment(). So this would guarantee a kmalloc() object aligned to CRYPTO_MINALIGN. > However, I think it's better to change the code that assumes > CRYPTO_MINALIGN guarantees DMA alignment. I saw Ard already started to refactor some of these. But in the meantime are there cases where the crypto code does a kmalloc() of less than CRYPTO_MINALIGN and expects it to be CRYPTO_MINALIGN aligned? -- Catalin