mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Calvin Owens <calvin@wbinvd.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH next] iommu/vt-d: Use shallowest supported table depth in sagaw
Date: Thu, 27 Nov 2025 12:39:39 -0800	[thread overview]
Message-ID: <aSi3C5ws5mS-6NFx@mozart.vkv.me> (raw)
In-Reply-To: <20251127183210.GC738503@ziepe.ca>

On Thursday 11/27 at 14:32 -0400, Jason Gunthorpe wrote:
> On Thu, Nov 27, 2025 at 09:06:35AM -0800, Calvin Owens wrote:
> > The failing condition in paging_domain_compatible_second_stage() is:
> > 
> >     /* Page table level is supported. */
> >     if (!(cap_sagaw(iommu->cap) & BIT(pt_info.aw)))
> >         return -EINVAL;
> > 
> > This happens because, for many domains on this machine, MGAW=39 but
> > SAGAW=0x04: that claims a 39-bit maximum address width, but also claims
> > to only support 48-bit/4-level paging, which seems odd.
> 
> This logic was intended to deal with this:
> 
> static int compute_vasz_lg2_ss(struct intel_iommu *iommu)
> {
> 	unsigned int sagaw = cap_sagaw(iommu->cap);
> 	unsigned int mgaw = cap_mgaw(iommu->cap);
> 
> 	/*
> 	 * Find the largest table size that both the mgaw and sagaw support.
> 	 * This sets both the number of table levels and the valid range of
> 	 * IOVA.
> 	 */
> 	if (mgaw >= 48 && (sagaw & BIT(3)))
> 		return min(57, mgaw);
> 	else if (mgaw >= 39 && (sagaw & BIT(2)))
> 		return min(48, mgaw);
> 	else if (mgaw >= 30 && (sagaw & BIT(1)))
> 		return min(39, mgaw);
> 
> Though it is not right..
> 
> I didn't consider that this would come up, the only way to solve it is
> to pass in more information so the tree can be higher than the vasz
> requires..
> 
> Can you try these two commits?
> 
> https://github.com/jgunthorpe/linux/commits/iommu_pt_vtd/

That works on the Skylake machine. If you want it:

Tested-by: Calvin Owens <calvin@wbinvd.org>

Thanks,
Calvin

> Thanks,
> Jason

  reply	other threads:[~2025-11-27 20:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 17:06 Calvin Owens
2025-11-27 18:32 ` Jason Gunthorpe
2025-11-27 20:39   ` Calvin Owens [this message]
2025-11-28  0:04     ` Jason Gunthorpe

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=aSi3C5ws5mS-6NFx@mozart.vkv.me \
    --to=calvin@wbinvd.org \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --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

all inboxes | Powered by JetHome®