Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp969038lql; Tue, 12 Mar 2024 03:44:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUd8HpZXBtEqVyo1w+SBcnuDUksrGQTLYarB/NZ3koIdL1uneZg3+IdP8uMMIWMue2tLS+dJpZV9RhbOydfEKi+6I9/+0bpLmBSmPpNYw== X-Google-Smtp-Source: AGHT+IHeGUa1hqDyQEl4GsbDBbcBN8VfoRJI7Bu3Mr03vsybQs+I9egtRLKsg2LT9TLTSKyRGpOH X-Received: by 2002:a17:907:76f1:b0:a44:e5ed:3d5d with SMTP id kg17-20020a17090776f100b00a44e5ed3d5dmr6937376ejc.9.1710240260821; Tue, 12 Mar 2024 03:44:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710240260; cv=pass; d=google.com; s=arc-20160816; b=CWLK+MJKx5JsTgtpKsDeHbQPoBi4piGiMGMGVyofSip46Vv3P8gC743UP2twDMTBrl r7ck2sPTZQap1rMiY+IbrQ7+H3YjSfSNIFbBvdjVqCx7A5CMJ1X2E0c7l7PEZICvYwtN KlLZqvnTOAznm8U8G6HYlIP8XUin8ICHrJfEDbGxvHHx7tteY9A3fVN0hw+4nolVamX1 G5bnuev1I9EfVArW7ZRCtheqAlxHHkF4bnw8oREFoayrKEqNMZzWNCPhs2wbdxfD+lGZ aDpCAMleCcFUluwonfNaTfbD3YNyDZIDOFdKXil6f2mJp8tTTqdGM/DcVFWAxnI/q4dN r9TQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=ITLwhGMEZ24CbUrHEJA7iFp8qXIC6P69efW9R3b30Xk=; fh=NzdifV+CI2PcQbfHiAoB7HQ6wL3arqx1cqnZ9ILb1zA=; b=U8l3kbvAOPmtG+lR6fo49sok4rx122IJYG1gz1vnDm4jLycePnEODgMgqXJE7smF3r uw/K/0gyRecRBHKAeKpK/HTaEFwegR/jWoOmDVdBO51PG5DuhXN1IbnoDz0uVGhBbDkL mbRobnYkAEKBbardVB+473usm100QyhFdC0NQpCiEW39ANrUYsRp6frj52VeLx1BJZaU Iy+ma0bMtyPfPgUzcJaFRd9HCgdHbVlYjPQPBc7Dhq8PAqhLPlncRbsbkJwoSBIA6H5M M+9Fbt0dS+ClesAGH5wdK0pV8mEnVrAmyVqOyYYXCBGv/WUmbwUX4ihDMN4vTBRl3QJ1 +giw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=kQh2ipPA; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-100134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hr11-20020a1709073f8b00b00a4628d4d95asi1788602ejc.318.2024.03.12.03.44.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=kQh2ipPA; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-100134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C3C01F229EC for ; Tue, 12 Mar 2024 10:44:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02DEC69D0B; Tue, 12 Mar 2024 10:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b="kQh2ipPA" Received: from bee.tesarici.cz (bee.tesarici.cz [37.205.15.56]) (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 EFB0958ADB for ; Tue, 12 Mar 2024 10:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.205.15.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710240252; cv=none; b=e7Y7x1aJNyqR3nM0PBj6HxeKBkeAkb6AWOQW746lZtW/I0pc4pd5YFztJHtrYiEQfvp1XxdpBcGuNkIwXJvZlgXSBBdgj5NkeyB4YvVKkHWFdMUcUiogj/Zql+hoOy6el0V3j6EQgFgneHd+A3j2xvlKZLxJoTwXWFNUy1pf4kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710240252; c=relaxed/simple; bh=IvsQlHr33C+BlhA4MSbkk54Qsryx8yzEIHkCOnKNFjg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RZTbrcJdxo32g4usUvitgkbt9rSJuPY1HJSMsBlAXNKDWgIgTgGvDL6+/yzFQKiQcIlzdJcLrBM3xAcdbd1qizlOL9kHlynagxv5k+80tSfayNJeCclhAUzsgAWAoWs+G+IF9UvMlBD21VhWDkdSbArq0Ap/eNgK/GSrjS3TCR4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz; spf=pass smtp.mailfrom=tesarici.cz; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b=kQh2ipPA; arc=none smtp.client-ip=37.205.15.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tesarici.cz Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id D7F06192F81; Tue, 12 Mar 2024 11:44:06 +0100 (CET) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=quarantine dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesarici.cz; s=mail; t=1710240247; bh=ITLwhGMEZ24CbUrHEJA7iFp8qXIC6P69efW9R3b30Xk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kQh2ipPAvoEV0qxucFcQ465bMg8jOaopCLq4e2wmGWwB4QWYe9e+DMbqBMVDHiLoM dW3HTWBxWK2vjD+qkaKnEm7ahmnFbErOQ+39VIc15U3oENnQ0l60gBwbfXUE9JW9D9 47yrNmEuu8Ww0eaQPPQmy/IWk5hNFlpNeDjluB4gkRVmnVVZA0YQt0P6MHojKVo3oz 8kdQ+0Y31hObogc7F+n3dqGFzsvM40dCIROeG8nuLyYT6plQB1kZ9UJYIVH38SJKr0 evPv1kw4jbXccgLItIq3YSC8wZksR1Ww2D/MU+XfdOmUKJ4uy/ahp17MSmYc6KFzCO kEBY88ej4Rtdw== Date: Tue, 12 Mar 2024 11:44:06 +0100 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Nicolin Chen Cc: Michael Kelley , Will Deacon , "linux-kernel@vger.kernel.org" , "kernel-team@android.com" , "iommu@lists.linux.dev" , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Dexuan Cui Subject: Re: [PATCH v6 4/6] swiotlb: Fix alignment checks when both allocation and DMA masks are present Message-ID: <20240312114406.792cc8f9@meshulam.tesarici.cz> In-Reply-To: References: <20240308152829.25754-1-will@kernel.org> <20240308152829.25754-5-will@kernel.org> <20240311210507.217daf8b@meshulam.tesarici.cz> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-suse-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 11 Mar 2024 17:52:31 -0700 Nicolin Chen wrote: > On Mon, Mar 11, 2024 at 09:36:10PM +0000, Michael Kelley wrote: > > From: Petr Tesa=C5=99=C3=ADk =20 > > > I find it somewhat surprising that NVMe does not > > > in fact require that the NVME_CTRL_PAGE_SHIFT low bits are preserved, > > > as suggested by Nicolin's successful testing. > > > > > > Why is that? =20 > >=20 > > I saw only one stack trace from Nicolin, and it was file system buffer > > flushing code that initiated the I/O. In such cases, it's very likely = that the > > original address is at least 4K aligned. Hence the offset is zero and > > the low bits will typically be correct. =20 >=20 > Though I didn't dig any deeper here, I do see some unaligned > original addresses passed in at the top level: > fsck.ext4-286 [004] ..... 2.594190: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be750600 > fsck.ext4-286 [004] ..... 2.613032: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be780400 > fsck.ext4-286 [004] ..... 2.614096: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be7c0600 > fsck.ext4-286 [004] ..... 2.614103: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be7e0400 > mount-288 [005] ..... 2.615157: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be800400 > multipathd-405 [003] ..... 3.062878: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: bda40218 > multipathd-502 [002] ..... 3.231721: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: bd3107b8 > mount-525 [002] ..... 3.250281: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: bd340200 > multipathd-529 [004] ..... 3.259053: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be620478 > multipathd-571 [005] ..... 3.292893: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be900328 > multipathd-580 [005] ..... 3.318832: iommu_dma_map_page: ca= lling swiotlb_tbl_map_single with phys: be9207c8 Thank you. Indeed, bit 11 of the physical address was zero in all the above calls, and that's why it works. Petr T