Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp33151lfe; Fri, 15 Apr 2022 18:05:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc6Tp/gMl46Gc31qQzAbUB3DLZ8DNbtcNO1rS4PVRBU+2BH26pqrqYJcuhtcKd57+kW6Yk X-Received: by 2002:a17:90a:4bc2:b0:1b8:cdd3:53e2 with SMTP id u2-20020a17090a4bc200b001b8cdd353e2mr6795303pjl.219.1650071134345; Fri, 15 Apr 2022 18:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650071134; cv=none; d=google.com; s=arc-20160816; b=L/gzKgkoUjtVOUoEiSR6SvFwO1Q7POJW3NU476cWDOaoX54fM2iDR5w1vB0ZUFgA1W o/VQBr2LPr+I2vUR6YQYgEuwvgzs6J2DQ6NHswbflOklY+A+X0k8KfOZFmggfg7U94Ue BLXUYc1MklcJxS3BBYAEFxyCjSSqbMZa8/lMzUO4y5oHj560d6oyjUFJHV1WZuQbHB7r JI5TEE06wa6ZYi66P1iJQt0xddhe73UIs9EHjWUNh/ggSMhYk+N2hjSSHUlwXnl+lZ9q wqYYNYGw+TNccgc3lbitBAuRu+c2cqqTa562hvH+OgGAEpk4rGYN/V7ezpw0NQlv5B3P gIiA== 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=8WxzEpLK+1G6eZkBCpwD7Sl+gKwBSRJI/QUnohx0bW4=; b=aoZc9r+ENiLjOGHzC46oqJp0auohbFzn/9LA5FyIT11+mD45hdVBoYKPJQFDUGzge8 Pc/3t8fNSobJ6qGFxGxwrg7BD59Ive3nLqUHIIEDr1aJzB8v5GjQrZJIwviPDcxtQoKu kVL4wqQC0aJ1VG6CrXuf3nTiXt3lJZpuRANIeLB5b3Af+TYc2JgcvUgDnLC8GoIGsW/y VUG7cbN0bP274bJNOVzxx3QA+QSMjPPlEJGxusam8Of2fE+wW1RuEoauoJSL3gHQwND4 PAaR+pOgDokWUtgqCaUzsYltsZ5cRxm0lXrkX5MuwouVn1JLanolpq78P8esLGqxk3b6 3AwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="h0EaX/X5"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l19-20020a637013000000b003822f3c78cfsi2757959pgc.683.2022.04.15.18.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:05:34 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="h0EaX/X5"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DD919F9546; Fri, 15 Apr 2022 17:46:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351879AbiDOJyi (ORCPT + 99 others); Fri, 15 Apr 2022 05:54:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbiDOJyd (ORCPT ); Fri, 15 Apr 2022 05:54:33 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D29BB8202 for ; Fri, 15 Apr 2022 02:52:04 -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 sin.source.kernel.org (Postfix) with ESMTPS id 3E186CE2E3C for ; Fri, 15 Apr 2022 09:52:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 884C7C385A8 for ; Fri, 15 Apr 2022 09:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650016321; bh=EBREfv/xjXAG8CJUnZO7ZCNWHvcAy+bC2kvoVDVVtYc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=h0EaX/X5k7WmSIVOemIt7peeO6RSIhFLQqWNZUOaDwvJb/WWrn0u3GuhPJ2gBIhkb l89NprYd1bGn/OC7aMVxcQz1P5XR9c5XKQWBVOnfCGXTfv/jeaRzKuP9FpVVFXA6sU OigkrC9skcBc+F2iAgANxsyeMpr03WGe4v8g+KWsrfoam5eTJNA5g/m1sjdCXCayrZ lS/oqM0Or4YjXNwIWJ+0Kq1Nlm4xxH3g191uotr05Mcbve2EMH5kl6G9955mH/nXSs XxIJqQIRfQAniAaeHuDQXwwawJOPMZ9ZlkqptYsJAipUyppe7Roq7fZeAns4qvxIsQ wGHWSyu2AlS/A== Received: by mail-oi1-f179.google.com with SMTP id r8so7981588oib.5 for ; Fri, 15 Apr 2022 02:52:01 -0700 (PDT) X-Gm-Message-State: AOAM5314jI3ywHrdGS0stHru5AE5Hfbv70YzE59em3aqviCaBaMF1JWn hkZaYy11cJGWd2e8UEs8rzIPtnaMeKNrO4msl38= X-Received: by 2002:a05:6808:1596:b0:2f7:5d89:eec7 with SMTP id t22-20020a056808159600b002f75d89eec7mr1279737oiw.228.1650016320681; Fri, 15 Apr 2022 02:52:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 15 Apr 2022 11:51:49 +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-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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, 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. So if kmalloc() returns buffers that are aligned to whatever alignment the platform requires (which will be 64 in most cases), the above arrangement ensures that, without requiring that CRYPTO_MINALIGN == ARCH_DMA_MINALIGN.