From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
"De Marchi, Lucas" <lucas.demarchi@intel.com>,
"Kurmi, Suresh Kumar" <suresh.kumar.kurmi@intel.com>,
"Saarinen, Jani" <jani.saarinen@intel.com>,
"Auld, Matthew" <matthew.auld@intel.com>,
"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: REGRESSION on linux-next (next-20251106)
Date: Wed, 19 Nov 2025 22:18:31 -0400 [thread overview]
Message-ID: <20251120021831.GT120075@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB52764557ECAEF2200054070D8CD7A@BN9PR11MB5276.namprd11.prod.outlook.com>
On Wed, Nov 19, 2025 at 11:56:16PM +0000, Tian, Kevin wrote:
> > So we should be using dmar->width to constrain the first stage and
> > expect that mgaw is less than dmar->width ?
> >
>
> dmar->width is the host address width, i.e. for OA. so it's irrelevant
> to the input iova here.
Oh that makes sense!
In that case we should probably pedantically have:
cfg.common.hw_max_oasz_lg2 = dmar->width;
?
However we get dmar into that function?
> "
> 3.6 First-Stage Translation
>
> First-stage translation restricts the input-address to a canonical address
> (i.e., address bits 63:N have the same value as address bit [N-1], where
> N is 48 bits with 4-level paging and 57 bits with 5-level paging). Requests
> subject to first-stage translation by remapping hardware are subject to
> canonical address checking as a pre-condition for first-stage translation,
> and a violation is treated as a translation-fault.
>
> Software using first-stage translation structures to translate an IO Virtual
> Address (IOVA) must use canonical addresses. Additionally, software
> must limit addresses to less than the minimum of MGAW and the lower
> canonical address width implied by FSPM (i.e., 47-bit when FSPM is 4-level
> and 56-bit when FSPM is 5-level)
> "
That seems very clear, indeed. OK! Easy to fix then! Balou can you
take it? I think something like this?
@@ -2800,6 +2800,7 @@ intel_iommu_domain_alloc_first_stage(struct device *dev,
{
+ unsigned int mgaw = cap_mgaw(iommu->cap);
struct pt_iommu_x86_64_cfg cfg = {};
struct dmar_domain *dmar_domain;
int ret;
if (flags & ~IOMMU_HWPT_ALLOC_PASID)
@@ -2817,7 +2818,12 @@ intel_iommu_domain_alloc_first_stage(struct device *dev,
cfg.common.hw_max_vasz_lg2 = 57;
else
cfg.common.hw_max_vasz_lg2 = 48;
+
+ /*
+ * See "3.6 First-Stage Translation", mgaw is used to limit the first
+ * stage as well.
+ */
+ cfg.common.hw_max_vasz_lg2 = min(mgaw, cfg.common.hw_max_vasz_lg2);
cfg.common.hw_max_oasz_lg2 = 52;
cfg.common.features = BIT(PT_FEAT_FLUSH_RANGE);
/* First stage always uses scalable mode */
@@ -3004,6 +3010,11 @@ static int paging_domain_compatible_first_stage(struct dmar_domain *dmar_domain,
dmar_domain->fspt.x86_64_pt.common.max_vasz_lg2 > 48)
return -EINVAL;
+ /* Address bits have to be identical to HW because of the sign extension */
+ if (dmar_domain->fspt.x86_64_pt.common.max_vasz_lg2 !=
+ cap_mgaw(iommu->cap))
+ return -EINVAL;
+
/* Same page size support */
if (!cap_fl1gp_support(iommu->cap) &&
(dmar_domain->domain.pgsize_bitmap & SZ_1G))
Jason
next prev parent reply other threads:[~2025-11-20 2:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 6:36 REGRESSION on linux-next (next-20251106) Borah, Chaitanya Kumar
2025-11-12 22:32 ` Jason Gunthorpe
2025-11-13 2:00 ` Tian, Kevin
2025-11-17 15:24 ` Jason Gunthorpe
2025-11-17 12:54 ` Baolu Lu
2025-11-17 15:22 ` Jason Gunthorpe
2025-11-18 1:29 ` Jason Gunthorpe
2025-11-18 4:04 ` Tian, Kevin
2025-11-18 6:19 ` Baolu Lu
2025-11-18 6:23 ` Baolu Lu
2025-11-18 7:47 ` Tian, Kevin
2025-11-18 11:29 ` Baolu Lu
2025-11-18 12:35 ` Jason Gunthorpe
2025-11-19 7:25 ` Baolu Lu
2025-11-18 10:30 ` Baolu Lu
2025-11-18 15:16 ` Borah, Chaitanya Kumar
2025-11-18 16:13 ` Jason Gunthorpe
2025-11-19 7:40 ` Borah, Chaitanya Kumar
2025-11-19 9:31 ` Tian, Kevin
2025-11-19 18:51 ` Jason Gunthorpe
2025-11-19 23:56 ` Tian, Kevin
2025-11-20 2:18 ` Jason Gunthorpe [this message]
2025-11-20 2:24 ` Baolu Lu
2025-11-20 7:27 ` Baolu Lu
2025-11-20 0:19 ` Tian, Kevin
2025-11-19 9:29 ` Baolu Lu
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=20251120021831.GT120075@nvidia.com \
--to=jgg@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=iommu@lists.linux.dev \
--cc=jani.saarinen@intel.com \
--cc=kevin.tian@intel.com \
--cc=lucas.demarchi@intel.com \
--cc=matthew.auld@intel.com \
--cc=suresh.kumar.kurmi@intel.com \
/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