Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp44399lfe; Fri, 15 Apr 2022 18:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznhpoXlG5MxjPbJvAp86rrLUA4J4RpGHe0M+A9SVt2ot+7pcTOyMt6exPz9ZQ+isuXYxNF X-Received: by 2002:a17:90a:2e03:b0:1ce:1453:c76b with SMTP id q3-20020a17090a2e0300b001ce1453c76bmr1665488pjd.90.1650073051890; Fri, 15 Apr 2022 18:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650073051; cv=none; d=google.com; s=arc-20160816; b=SN2SN0GA0+0yp0gxie2+eiFI4vYIG/ViLmkBEaAx1PbbV1qJzwcJc7AsKTlsHFRy7O p8mxID6EkXRJSe6oJ417gKYiMXpVSUCaLOvLj/nWnCZuWO2rqSSrn8j2eZewjEuS8nfS kDEuNi6gV4bfyxuvltIe31+rUXI/jKKaH6Ugl3pxftiZJoDo5SF3Q6ujpYQUDMomiMEl BbbPY3Q/fAw199nOc3HXUXzJCTnm4OyelETurEF9iz//TOM3BApYeA6E8qwo1Ich0br3 b2eimr97lFXDlQPjxJttElC11Ht3+NYjTf99poyHeky659Icgvf3J0r1HhTdb8FpMLt9 6LtQ== 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=8nwtF9o9D9f4UeXjKu0kPNoQvEOVCQYcdRCZq25x7qI=; b=WV6LHcg/7FgmgjLCUYArS+YnJLBVvHenBGNh9VL7Ua/LK6I2eVPahGEMqlHkOO4taM SCHfDNRyiKW5/QyZ0xf38h8INmeSBtKMXzKYHPOelGR/FJChKYbZvnB5285FzZjGIT6t tZcdW6Z+qf4nd+yRZK3+axM/t+N4uqQlQ4Oe0Hv+LFYLN+n81pLcGbPf3j140CJG2qYr uCXLIXXjEkGezndPGBev2HD1vT9ko/amsSFXBA0JOlhrOmnl4xTY1dXvuE3B+0p0m8Uw jn45QHpeHOIP5W/jqucBZJKvATv463/0ITeD6j+b0XB2MBKWrNNg3rKQKFhPINbIziZo kRYA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z2-20020a170903018200b00158eb7e5faasi112631plg.253.2022.04.15.18.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:37:31 -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; 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=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 4E7D8E9961; Fri, 15 Apr 2022 18:03:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351873AbiDOJyQ (ORCPT + 99 others); Fri, 15 Apr 2022 05:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbiDOJyO (ORCPT ); Fri, 15 Apr 2022 05:54:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE24B6E6B for ; Fri, 15 Apr 2022 02:51:47 -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 B52876219F for ; Fri, 15 Apr 2022 09:51:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D5D7C385A6; Fri, 15 Apr 2022 09:51:43 +0000 (UTC) Date: Fri, 15 Apr 2022 10:51:40 +0100 From: Catalin Marinas To: Herbert Xu Cc: Ard Biesheuvel , 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" Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: 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 Fri, Apr 15, 2022 at 03:51:54PM +0800, Herbert Xu wrote: > On Fri, Apr 15, 2022 at 09:49:12AM +0200, Ard Biesheuvel wrote: > > I'm not sure I understand what would go wrong if that assumption no > > longer holds. > > It's very simple, we don't do anything to the pointer returned > by kmalloc before returning it as a tfm or other object with > an alignment of CRYPTO_MINALIGN. IOW if kmalloc starts returning > pointers that are not aligned to CRYPTO_MINALIGN then we'd be > lying to the compiler. I agree that it would be lying to the compiler, but I don't think this matters for arm64 where the CPU can do unaligned accesses just fine. We don't even end up with unaligned accesses here. Let's say we have: struct x { ... } __attribute__ ((__aligned__ (128))); and the kmalloc(sizeof(struct x)) returns a 64-byte aligned pointer. The compiler-generated code won't have any problem on arm64 accessing the struct x members. As I said a few times, it's not affecting any other architecture and not breaking arm64 either. Anyway, let's agree to disagree. I'll look into keeping CRYPTO_MINALIGN as ARCH_KMALLOC_MINALIGN and introduce a CRYPTO_DMA_MINALIGN (or just use ARCH_DMA_MINALIGN directly) together with something like Linus' dma_kmalloc() in places where an object aligned to ARCH_DMA_MINALIGN is needed in the crypto code. -- Catalin