Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1963096rdf; Sun, 5 Nov 2023 23:43:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/ODMVI+5lryYqLFhNfApb/fevMcN7cux1VpnQlQZ0mD+dnjgHLV3qHSkugfALTwWPOtAN X-Received: by 2002:a05:6871:5c4d:b0:1e9:9aa6:eeca with SMTP id os13-20020a0568715c4d00b001e99aa6eecamr37665356oac.1.1699256582113; Sun, 05 Nov 2023 23:43:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699256582; cv=none; d=google.com; s=arc-20160816; b=d4GLkTKFkr29gXlJBEET8y4kyL7sLSe7kUMjycnQxImY1kiB4KHQlpdpvPGdLGEcce uRGxMmUs+MfnlNbyi5yUAxJXvZIFEet+PeCusfHiN3PK/7p7tG03yfpPa/SuDn/1n94d 06Smz5/pp2NpI4Sr90GQqnaVgLCQ9T0HRf17/Vq+aOrqW6JgvEjQ8d6xQkgybKkzBRoA Lm7azrbVN39xE2JGzOnNUurCkK+IvU433D43VNS0zCE0ceO8L9zlwlHH2bSBeHJqTUz8 du5eBp/FMZm2ldO1yQsRIRopZl73IbQ6iGxO2ap/wnNLUPvOyLyB6ENMLfOSLE79L0Yo L+VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=m6+pnCOXbIeD88yfaovoVwuHimbn1bF/Ii8nX8KMKaQ=; fh=hiTA/gRnBh6BTvxvzw0ZSB5PTY8Am+/MXhCB6tCv690=; b=hpBR4oRB1P6BGN+xg0OSnMl3eCmB0fUFbAEMbWqCtLaVXl0tA6DEPPjBjBBugpZpMj dSwbF2Otpp6RAnP9futDApAn4vNjTGaiFJmQVlJhh+H9brOae+MCuhixN0mSn1Ol9Faz qMRZETSluDpOdquB27fiz6uyE2klzPvxR4B09xeqC5Fk3SUK5MQLryFSV85YkJlVQoI7 8WLRh9G+SL3krzqJcIjHMM0QxouVucK1E7NvSNfCBUNUNAfexlVhOBImUzmmvP96/YjZ QUG/kpJ1RRJvI642vGni566hJNKg5258OkNUvVYu8FQhdetZTZfl/qOmKFBXzg5QgclR +rQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 200-20020a6301d1000000b005b881b8aecasi7315904pgb.440.2023.11.05.23.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 23:43:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 86F4680785D2; Sun, 5 Nov 2023 23:42:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230499AbjKFHmw (ORCPT + 99 others); Mon, 6 Nov 2023 02:42:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjKFHmu (ORCPT ); Mon, 6 Nov 2023 02:42:50 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C0E593; Sun, 5 Nov 2023 23:42:47 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id B3F0D6732D; Mon, 6 Nov 2023 08:42:43 +0100 (CET) Date: Mon, 6 Nov 2023 08:42:43 +0100 From: Christoph Hellwig To: Petr =?utf-8?B?VGVzYcWZw61r?= Cc: Halil Pasic , Niklas Schnelle , Christoph Hellwig , Bjorn Helgaas , Marek Szyprowski , Robin Murphy , Petr Tesarik , Ross Lagerwall , linux-pci , linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Matthew Rosato Subject: Re: Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y Message-ID: <20231106074243.GA17777@lst.de> References: <104a8c8fedffd1ff8a2890983e2ec1c26bff6810.camel@linux.ibm.com> <20231103171447.02759771.pasic@linux.ibm.com> <20231103214831.26d29f4d@meshulam.tesarici.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231103214831.26d29f4d@meshulam.tesarici.cz> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 05 Nov 2023 23:42:59 -0800 (PST) On Fri, Nov 03, 2023 at 09:50:53PM +0100, Petr Tesařík wrote: > Seconded. I have also been struggling with the various alignment > constraints. I have even written (but not yet submitted) a patch to > calculate the combined alignment mask in swiotlb_tbl_map_single() and > pass it down to all other functions, just to make it clear what > alignment mask is used. That does sound like a good idea. > My understanding is that buffer alignment may be required by: > > 1. hardware which cannot handle an unaligned base address (presumably > because the chip performs a simple OR operation to get the addresses > of individual fields); There's all kinds of weird encodings that discard the low bits. For NVMe it's the PRPs (that is actually documented in the NVMe spec, so it might be easiest to grasp), but except for a Mellox vendor extension this is also how all RDMA memory registrations work.