From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C967BD278 for ; Wed, 8 Nov 2023 07:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: by verein.lst.de (Postfix, from userid 2407) id 61CA16732D; Wed, 8 Nov 2023 08:30:49 +0100 (CET) Date: Wed, 8 Nov 2023 08:30:48 +0100 From: Christoph Hellwig To: Halil Pasic Cc: Christoph Hellwig , Petr =?utf-8?B?VGVzYcWZw61r?= , Niklas Schnelle , Bjorn Helgaas , Marek Szyprowski , Robin Murphy , Petr Tesarik , Ross Lagerwall , linux-pci , linux-kernel@vger.kernel.org, iommu@lists.linux.dev, Matthew Rosato , Jianxiong Gao Subject: Re: Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y Message-ID: <20231108073048.GA5277@lst.de> References: <104a8c8fedffd1ff8a2890983e2ec1c26bff6810.camel@linux.ibm.com> <20231103171447.02759771.pasic@linux.ibm.com> <20231103214831.26d29f4d@meshulam.tesarici.cz> <20231106074243.GA17777@lst.de> <20231107182437.06632f6e.pasic@linux.ibm.com> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231107182437.06632f6e.pasic@linux.ibm.com> User-Agent: Mutt/1.5.17 (2007-11-01) On Tue, Nov 07, 2023 at 06:24:37PM +0100, Halil Pasic wrote: > Thanks Christoph! So for NVMe in certain contexts the low > bits of addresses get discarded, but in other contexts the high bits > of addresses get discarded and the low bits need to remain the same > after the bounce (and that's why we need commits 36950f2da1ea ("driver > core: add a min_align_mask) and 1f221a0d0dbf ("swiotlb: respect > min_align_mask"). Nothing really gets discarded. NVMe basicaly requires all pages (where the page is a device page, currently hard coded to 4k in Linux) except for the first to not have an offset. This is what the driver sets the virt boundary to in Linux. When bounce buffering thus all segments (except possibly the first) need to keep their alignment.