public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jon Pan-Doh <pandoh@google.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Kevin Tian <kevin.tian@intel.com>
Cc: baolu.lu@linux.intel.com, Joerg Roedel <joro@8bytes.org>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	"H. Peter Anvin" <hpa@linux.intel.com>, Tejun Heo <tj@kernel.org>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	Sudheer Dantuluri <dantuluris@google.com>,
	Gary Zibrat <gzibrat@google.com>
Subject: Re: [PATCH] iommu/vt-d: Fix identity map bounds in si_domain_init()
Date: Wed, 10 Jul 2024 10:43:00 +0800	[thread overview]
Message-ID: <b3401333-76d3-415a-b2e4-b148c44b13f3@linux.intel.com> (raw)
In-Reply-To: <20240709234913.2749386-1-pandoh@google.com>

On 7/10/24 7:49 AM, Jon Pan-Doh wrote:
> Intel IOMMU operates on inclusive bounds (both generally aas well as
> iommu_domain_identity_map()). Meanwhile, for_each_mem_pfn_range() uses
> exclusive bounds for end_pfn. This creates an off-by-one error when
> switching between the two.
> 
> Fixes: 5dfe8660a3d7 ("bootmem: Replace work_with_active_regions() with for_each_mem_pfn_range()")
> Signed-off-by: Jon Pan-Doh<pandoh@google.com>
> Tested-by: Sudheer Dantuluri<dantuluris@google.com>

Do you mind telling me on which platform did you test this fix? My
understanding is that modern VT-d hardware supports hardware pass
through mode, hence this piece of code won't be executed anymore.

> Suggested-by: Gary Zibrat<gzibrat@google.com>
> ---
>   drivers/iommu/intel/iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index fd11a080380c..f55ec1fd7942 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2071,7 +2071,7 @@ static int __init si_domain_init(int hw)
>   		for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {
>   			ret = iommu_domain_identity_map(si_domain,
>   					mm_to_dma_pfn_start(start_pfn),
> -					mm_to_dma_pfn_end(end_pfn));
> +					mm_to_dma_pfn_end(end_pfn-1));
>   			if (ret)
>   				return ret;
>   		}

Thanks,
baolu

  parent reply	other threads:[~2024-07-10  2:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 23:49 [PATCH] iommu/vt-d: Fix identity map bounds in si_domain_init() Jon Pan-Doh
2024-07-10  0:49 ` Tian, Kevin
2024-07-12  7:05   ` Jon Pan-Doh
2024-07-10  2:43 ` Baolu Lu [this message]
2024-07-12  7:05   ` Jon Pan-Doh
2024-07-12  7:39     ` Baolu Lu
2024-07-12 15:44 ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b3401333-76d3-415a-b2e4-b148c44b13f3@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=dantuluris@google.com \
    --cc=dwmw2@infradead.org \
    --cc=gzibrat@google.com \
    --cc=hpa@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pandoh@google.com \
    --cc=robin.murphy@arm.com \
    --cc=tj@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox