public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Tushar Dave <tdave@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Vasant Hegde <vasant.hegde@amd.com>,
	Baolu Lu <baolu.lu@linux.intel.com>,
	joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
	kevin.tian@intel.com, yi.l.liu@intel.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH rc] iommu: Skip PASID validation for devices without PASID capability
Date: Sun, 27 Apr 2025 18:47:09 -0700	[thread overview]
Message-ID: <6c2193a3-02f7-4374-bc64-e9dde471da44@nvidia.com> (raw)
In-Reply-To: <20250425120035.GA1804142@nvidia.com>



On 4/25/25 05:00, Jason Gunthorpe wrote:
> On Thu, Apr 24, 2025 at 05:49:20PM -0700, Tushar Dave wrote:
> 
>> In the above topology, we setup ACS flags on DSP 0008:02:03.0 and
>> 0008:02:00.0 to achieve desired p2p configuration for GPU and DMA-PF.
>> Apparently, this creates multi-device group with GPU being only device with
>> PASID support in that group. In this case, set_dev_pasid() ops invoked for
>> each device within the group with pasid=1 and doesn't fail.
> 
> Hurm, it doesn't fail, but it corrupts memory in the driver :\
> 
> int arm_smmu_set_pasid(struct arm_smmu_master *master,
> 		       struct arm_smmu_domain *smmu_domain, ioasid_t pasid,
> 		       struct arm_smmu_cd *cd, struct iommu_domain *old)
> {
> 	struct iommu_domain *sid_domain = iommu_get_domain_for_dev(master->dev);
> 	struct arm_smmu_attach_state state = {
> 		.master = master,
> 		.ssid = pasid,
> 		.old_domain = old,
> 	};
> 	struct arm_smmu_cd *cdptr;
> 	int ret;
> 
> 	/* The core code validates pasid */
>                  ^^^^^^^^^^
> 
> Which is not true after this patch.
> 
> The core code may not call the driver's set_pasid() function with a PASID
> larger than that specific device's device->dev->iommu->max_pasids

Yup. And I should be adding similar check (i.e. max_pasid > 0 ) before invoking 
set_dev_pasid and remove_dev_pasid (as Kevin already asked earlier).
I can do that in v2.

-Tushar

> 
> Jason

      reply	other threads:[~2025-04-28  1:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24  2:06 [PATCH rc] iommu: Skip PASID validation for devices without PASID capability Tushar Dave
2025-04-24  3:27 ` Baolu Lu
2025-04-24  4:33   ` Tian, Kevin
2025-04-24  6:38   ` Vasant Hegde
2025-04-24 12:31     ` Jason Gunthorpe
2025-04-24 15:49       ` Vasant Hegde
2025-04-25  0:49       ` Tushar Dave
2025-04-25 12:00         ` Jason Gunthorpe
2025-04-28  1:47           ` Tushar Dave [this message]

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=6c2193a3-02f7-4374-bc64-e9dde471da44@nvidia.com \
    --to=tdave@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    --cc=yi.l.liu@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