lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z7zrHn3tPBD5chv1@Asurada-Nvidia>
Date: Mon, 24 Feb 2025 13:56:46 -0800
From: Nicolin Chen <nicolinc@...dia.com>
To: Pranjal Shrivastava <praan@...gle.com>
CC: <jgg@...dia.com>, <kevin.tian@...el.com>, <corbet@....net>,
	<will@...nel.org>, <joro@...tes.org>, <suravee.suthikulpanit@....com>,
	<robin.murphy@....com>, <dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>,
	<shuah@...nel.org>, <linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>,
	<linux-doc@...r.kernel.org>, <eric.auger@...hat.com>,
	<jean-philippe@...aro.org>, <mdf@...nel.org>, <mshavit@...gle.com>,
	<shameerali.kolothum.thodi@...wei.com>, <smostafa@...gle.com>,
	<ddutile@...hat.com>, <yi.l.liu@...el.com>, <patches@...ts.linux.dev>
Subject: Re: [PATCH v7 13/14] iommu/arm-smmu-v3: Report events that belong to
 devices attached to vIOMMU

On Mon, Feb 24, 2025 at 09:35:14PM +0000, Pranjal Shrivastava wrote:
> On Sat, Feb 22, 2025 at 07:54:10AM -0800, Nicolin Chen wrote:
> > +int arm_vmaster_report_event(struct arm_smmu_vmaster *vmaster, u64 *evt)
> > +{
> > +	struct iommu_vevent_arm_smmuv3 vevt;
> > +	int i;
> > +
> > +	lockdep_assert_held(&vmaster->vsmmu->smmu->streams_mutex);
> > +
> > +	vevt.evt[0] = cpu_to_le64((evt[0] & ~EVTQ_0_SID) |
> > +				  FIELD_PREP(EVTQ_0_SID, vmaster->vsid));
> > +	for (i = 1; i < EVTQ_ENT_DWORDS; i++)
> > +		vevt.evt[i] = cpu_to_le64(evt[i]);
> 
> Just thinking out loud here:
> I understand the goal here is to "emulate" an IOMMU. But I'm just
> wondering if we could report struct events instead of the raw event?
> 
> For example, can't we have something like arm_smmu_event here with the
> sid changed to vsid? 
> 
> Are we taking the raw event since we want to keep the `u64 event_data[]`
> field within `struct iommufd_vevent` generic to all architectures?

The ABIs for vSMMU are defined in the HW languange, e.g. cmd, ste.
Thus, here evt in raw too.

> > -	ret = iommu_report_device_fault(master->dev, &fault_evt);
> > +	if (event->stall) {
> > +		ret = iommu_report_device_fault(master->dev, &fault_evt);
> > +	} else {
> > +		if (master->vmaster && !event->s2)
> > +			ret = arm_vmaster_report_event(master->vmaster, evt);
> > +		else
> > +			ret = -EFAULT; /* Unhandled events should be pinned */
> > +	}
> 
> Nit:
> I don't see the `arm_smmu_handle_event` being called elsewhere, is there
> a reason to return -EFAULT instead of -EOPNOTSUPP here?
> 
> I think the current behavior here is to return -EOPNOTSUPP if (!event->stall).
> Whereas, what we're doing here is:
> 	if (event->stall) {
> 	...
> 	/* do legacy stuff */
> 	...
> 	}
> 
> 	else {
> 		if (master->vmaster && !event->s2)
> 			arm_vmaster_report_event(vmaster, evt);
> 		else
> 			ret = -EFAULT
> 	}
> 
> 	mutex_unlock(&smmu->streams_mutex);
> 	return ret;
> 
> Thus, we end up returning -EFAULT instead of -EOPNOTSUPP in case
> event->stall == false. I agree that we aren't really checking the return
> value in the evtq_thread handler, but I'm wondering if we should ensure
> that we end up retaining the same behaviour as we have right now?

Oh, it looks like -EOPNOTSUPP should be returned here. Will fix.

Thanks
Nicolin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ