public inbox for iommu@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Ankit Soni <Ankit.Soni@amd.com>
Cc: iommu@lists.linux.dev, vasant.hegde@amd.com,
	suravee.suthikulpanit@amd.com, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/amd: Adhere to IVINFO[VASIZE] for address limits
Date: Tue, 3 Mar 2026 08:05:54 -0400	[thread overview]
Message-ID: <20260303120554.GC964116@ziepe.ca> (raw)
In-Reply-To: <mqobyculj4g3mv2ipf2rbacbw62ew2utq2kini5hql5r22khhc@btukh6fex6zb>

On Tue, Mar 03, 2026 at 11:47:21AM +0000, Ankit Soni wrote:

> > > +	/*
> > > +	 * IVINFO[VASIZE] encodes the log2 of the maximum virtual address
> > > +	 * processed by the IOMMU.
> > > +	 */
> > > +	switch (vasize) {
> > > +	case 32:
> > > +	case 40:
> > > +	case 48:
> > > +	case 64:
> > > +		return vasize;
> > > +	default:
> > > +		pr_warn_once("IVRS: IVINFO[VASIZE]=0x%x is invalid, defaulting to 64‑bit VA\n",
> > > +			     vasize);
> > > +		return 64;
> > 
> > Why check and limit it like this? 
> > 
> 
> I’ll replace this with a macro and send that in v3. If you have other suggestions,
> I’m happy to incorporate.
> 
> > > -	cfg.common.hw_max_vasz_lg2 =
> > > -		min(64, (amd_iommu_hpt_level - 1) * 9 + 21);
> > > +	cfg.common.hw_max_vasz_lg2 = amd_iommu_hpt_vasize;
> > 
> > This has no restriction, you can send it whatever size you want.
> > 
> 
> The intent is for the kernel to respect what the VM advertises in IVINFO.
> If we ignore IVINFO[VASIZE] and use a larger limit (i.e. from EFR only),
> driver can exceed vasize what the VM allows and break the guest.

I mean if FIELD_GET(IOMMU_IVINFO_VASIZE, amd_iommu_ivinfo) is 35 why
not just pass it to hw_max_vasz_lg2 and be done with it? What is the
point of limiting to only a few values?

Jason

  reply	other threads:[~2026-03-03 12:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 16:58 [PATCH] iommu/amd: Adhere to IVINFO[VASIZE] for address limits Ankit Soni
2026-02-28 10:56 ` kernel test robot
2026-03-02 23:57 ` Jason Gunthorpe
2026-03-03 11:47   ` Ankit Soni
2026-03-03 12:05     ` Jason Gunthorpe [this message]
2026-03-03 17:11       ` Ankit Soni
2026-03-03 18:17         ` Jason Gunthorpe
2026-03-05 13:51           ` Ankit Soni

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=20260303120554.GC964116@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=Ankit.Soni@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.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