public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>
Cc: "cohuck@redhat.com" <cohuck@redhat.com>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"nicolinc@nvidia.com" <nicolinc@nvidia.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"mjrosato@linux.ibm.com" <mjrosato@linux.ibm.com>,
	"chao.p.peng@linux.intel.com" <chao.p.peng@linux.intel.com>,
	"yi.y.sun@linux.intel.com" <yi.y.sun@linux.intel.com>,
	"peterx@redhat.com" <peterx@redhat.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"shameerali.kolothum.thodi@huawei.com"
	<shameerali.kolothum.thodi@huawei.com>,
	"lulu@redhat.com" <lulu@redhat.com>,
	"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
	"Martins, Joao" <joao.m.martins@oracle.com>
Subject: Re: [RFC 3/7] iommufd: Add iommufd_device_bind_pasid()
Date: Wed, 8 Nov 2023 17:03:55 +0800	[thread overview]
Message-ID: <8aa35b4e-6bf1-461b-8d7a-5331dfdc3934@intel.com> (raw)
In-Reply-To: <BN9PR11MB5276A47616E386F00AC50D728CA8A@BN9PR11MB5276.namprd11.prod.outlook.com>

On 2023/11/8 16:46, Tian, Kevin wrote:
>> From: Liu, Yi L <yi.l.liu@intel.com>
>> Sent: Wednesday, November 8, 2023 3:45 PM
>>
>> On 2023/10/10 16:19, Tian, Kevin wrote:
>>>> From: Liu, Yi L <yi.l.liu@intel.com>
>>>> Sent: Monday, October 9, 2023 4:51 PM
>>>>
>>>> +struct iommufd_device *iommufd_device_bind_pasid(struct
>> iommufd_ctx
>>>> *ictx,
>>>> +						 struct device *dev,
>>>> +						 u32 pasid, u32 *id)
>>>> +{
>>>> +	struct iommufd_device *idev;
>>>> +	int rc;
>>>> +
>>>> +	/*
>>>> +	 * iommufd always sets IOMMU_CACHE because we offer no way for
>>>> userspace
>>>> +	 * to restore cache coherency.
>>>> +	 */
>>>> +	if (!device_iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY))
>>>> +		return ERR_PTR(-EINVAL);
>>>> +
>>>> +	/*
>>>> +	 * No iommu supports pasid-granular msi message today. Here we
>>>> +	 * just check whether the parent device can do safe interrupts.
>>>> +	 * Isolation between virtual devices within the parent device
>>>> +	 * relies on the parent driver to enforce.
>>>> +	 */
>>>> +	if (!iommufd_selftest_is_mock_dev(dev) &&
>>>> +	    !msi_device_has_isolated_msi(dev)) {
>>>> +		rc = iommufd_allow_unsafe_interrupts(dev);
>>>> +		if (rc)
>>>> +			return ERR_PTR(rc);
>>>> +	}
>>>> +
>>>
>>> Only MemWr w/o pasid can be interpreted as an interrupt message
>>> then we need msi isolation to protect.
>>
>> yes.
>>
>>>
>>> But for SIOV all MemWr's are tagged with a pasid hence can never
>>> trigger an interrupt. From this angle looks this check is unnecessary.
>>
>> But the interrupts out from a SIOV virtual device do not have pasid (at
>> least today). Seems still need a check here if we consider this bind for
>> a SIOV virtual device just like binding a physical device.
>>
> 
> this check assumes the device is trusted. as long as there is no way
> for malicious guest to generate arbitrary interrupt messages then
> it's fine.
> 
> for physical device a MemWr can be interpreted as interrupt so
> we need msi isolation.
> 
> for SIOV all MemWr has pasid then we don't have such worry.
> IMS is under host's control so interrupt messages are already
> sanitized.

sure. this makes sense to me now.:)

-- 
Regards,
Yi Liu

  reply	other threads:[~2023-11-08  9:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09  8:51 [RFC 0/7] Add SIOV virtual device support Yi Liu
2023-10-09  8:51 ` [RFC 1/7] iommufd: Handle unsafe interrupts in a separate function Yi Liu
2023-10-09  8:51 ` [RFC 2/7] iommufd: Introduce iommufd_alloc_device() Yi Liu
2023-10-09  8:51 ` [RFC 3/7] iommufd: Add iommufd_device_bind_pasid() Yi Liu
2023-10-10  8:19   ` Tian, Kevin
2023-11-08  7:45     ` Yi Liu
2023-11-08  8:46       ` Tian, Kevin
2023-11-08  9:03         ` Yi Liu [this message]
2023-10-09  8:51 ` [RFC 4/7] iommufd: Support attach/replace for SIOV virtual device {dev, pasid} Yi Liu
2023-10-10  8:24   ` Tian, Kevin
2023-11-09  8:21     ` Yi Liu
2023-10-09  8:51 ` [RFC 5/7] iommufd/selftest: Extend IOMMU_TEST_OP_MOCK_DOMAIN to pass in pasid Yi Liu
2023-10-10  8:25   ` Tian, Kevin
2023-10-09  8:51 ` [RFC 6/7] iommufd/selftest: Add test coverage for SIOV virtual device Yi Liu
2023-10-10  8:30   ` Tian, Kevin
2023-11-09  7:48     ` Yi Liu
2023-10-09  8:51 ` [RFC 7/7] vfio: Add vfio_register_pasid_iommu_dev() Yi Liu
2023-10-10  8:33   ` Tian, Kevin
2023-11-09  8:20     ` Yi Liu
2023-11-16  5:35   ` Cao, Yahui
2023-11-17  6:31     ` Yi Liu
     [not found]   ` <99115148-d0e3-4920-aed6-669ae45aa2fe@intel.com>
2023-11-17  6:30     ` Yi Liu
2023-10-09 13:21 ` [RFC 0/7] Add SIOV virtual device support Jason Gunthorpe
2023-10-09 23:33   ` Tian, Kevin
2023-11-22  3:59   ` Cao, Yahui

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=8aa35b4e-6bf1-461b-8d7a-5331dfdc3934@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=cohuck@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=jasowang@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=joao.m.martins@oracle.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=nicolinc@nvidia.com \
    --cc=peterx@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=yi.y.sun@linux.intel.com \
    --cc=zhenzhong.duan@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