All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"marcan@marcan.st" <marcan@marcan.st>,
	"sven@svenpeter.dev" <sven@svenpeter.dev>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"agross@kernel.org" <agross@kernel.org>,
	"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"orsonzhai@gmail.com" <orsonzhai@gmail.com>,
	"baolin.wang7@gmail.com" <baolin.wang7@gmail.com>,
	"zhang.lyra@gmail.com" <zhang.lyra@gmail.com>,
	"wens@csie.org" <wens@csie.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"samuel@sholland.org" <samuel@sholland.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>
Cc: "virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>,
	"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"gerald.schaefer@linux.ibm.com" <gerald.schaefer@linux.ibm.com>,
	"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>
Subject: RE: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group
Date: Wed, 8 Jun 2022 07:49:10 +0000	[thread overview]
Message-ID: <BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220606061927.26049-2-nicolinc@nvidia.com>

> From: Nicolin Chen
> Sent: Monday, June 6, 2022 2:19 PM
> 
> Cases like VFIO wish to attach a device to an existing domain that was
> not allocated specifically from the device. This raises a condition
> where the IOMMU driver can fail the domain attach because the domain and
> device are incompatible with each other.
> 
> This is a soft failure that can be resolved by using a different domain.
> 
> Provide a dedicated errno from the IOMMU driver during attach that the
> reason attached failed is because of domain incompatability. EMEDIUMTYPE
> is chosen because it is never used within the iommu subsystem today and
> evokes a sense that the 'medium' aka the domain is incompatible.
> 
> VFIO can use this to know attach is a soft failure and it should continue
> searching. Otherwise the attach will be a hard failure and VFIO will
> return the code to userspace.
> 
> Update all drivers to return EMEDIUMTYPE in their failure paths that are
> related to domain incompatability.

Seems not all drivers are converted, e.g.:

mtk_iommu_v1_attach_device():
	/* Only allow the domain created internally. */
	mtk_mapping = data->mapping;
	if (mtk_mapping->domain != domain)
		return 0;
** the current code sounds incorrect which should return an error


s390_iommu_attach_device():
	/* Allow only devices with identical DMA range limits */
	} else if (domain->geometry.aperture_start != zdev->start_dma ||
		domain->geometry.aperture_end != zdev->end_dma) {
		rc = -EINVAL;


sprd_iommu_attach_device():
	if (dom->sdev) {
		pr_err("There's already a device attached to this domain.\n");
		return -EINVAL;
	}


gart_iommu_attach_dev():
	if (gart->active_domain && gart->active_domain != domain) {
		ret = -EBUSY;


arm_smmu_attach_dev():
	if (!fwspec || fwspec->ops != &arm_smmu_ops) {
		dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
		return -ENXIO;
	}
**probably this check can be covered by next patch which moves bus ops
check into iommu core?

Thanks
Kevin

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"marcan@marcan.st" <marcan@marcan.st>,
	"sven@svenpeter.dev" <sven@svenpeter.dev>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"agross@kernel.org" <agross@kernel.org>,
	"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"orsonzhai@gmail.com" <orsonzhai@gmail.com>,
	"baolin.wang7@gmail.com" <baolin.wang7@gmail.com>,
	"zhang.lyra@gmail.com" <zhang.lyra@gmail.com>,
	"wens@csie.org" <wens@csie.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"samuel@sholland.org" <samuel@sholland.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	 "alex.williamson@redhat.com" <alex.williamson@redhat.com>
Cc: "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"gerald.schaefer@linux.ibm.com" <gerald.schaefer@linux.ibm.com>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
	"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>
Subject: RE: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group
Date: Wed, 8 Jun 2022 07:49:10 +0000	[thread overview]
Message-ID: <BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220606061927.26049-2-nicolinc@nvidia.com>

> From: Nicolin Chen
> Sent: Monday, June 6, 2022 2:19 PM
> 
> Cases like VFIO wish to attach a device to an existing domain that was
> not allocated specifically from the device. This raises a condition
> where the IOMMU driver can fail the domain attach because the domain and
> device are incompatible with each other.
> 
> This is a soft failure that can be resolved by using a different domain.
> 
> Provide a dedicated errno from the IOMMU driver during attach that the
> reason attached failed is because of domain incompatability. EMEDIUMTYPE
> is chosen because it is never used within the iommu subsystem today and
> evokes a sense that the 'medium' aka the domain is incompatible.
> 
> VFIO can use this to know attach is a soft failure and it should continue
> searching. Otherwise the attach will be a hard failure and VFIO will
> return the code to userspace.
> 
> Update all drivers to return EMEDIUMTYPE in their failure paths that are
> related to domain incompatability.

Seems not all drivers are converted, e.g.:

mtk_iommu_v1_attach_device():
	/* Only allow the domain created internally. */
	mtk_mapping = data->mapping;
	if (mtk_mapping->domain != domain)
		return 0;
** the current code sounds incorrect which should return an error


s390_iommu_attach_device():
	/* Allow only devices with identical DMA range limits */
	} else if (domain->geometry.aperture_start != zdev->start_dma ||
		domain->geometry.aperture_end != zdev->end_dma) {
		rc = -EINVAL;


sprd_iommu_attach_device():
	if (dom->sdev) {
		pr_err("There's already a device attached to this domain.\n");
		return -EINVAL;
	}


gart_iommu_attach_dev():
	if (gart->active_domain && gart->active_domain != domain) {
		ret = -EBUSY;


arm_smmu_attach_dev():
	if (!fwspec || fwspec->ops != &arm_smmu_ops) {
		dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
		return -ENXIO;
	}
**probably this check can be covered by next patch which moves bus ops
check into iommu core?

Thanks
Kevin
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"marcan@marcan.st" <marcan@marcan.st>,
	"sven@svenpeter.dev" <sven@svenpeter.dev>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"agross@kernel.org" <agross@kernel.org>,
	"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"orsonzhai@gmail.com" <orsonzhai@gmail.com>,
	"baolin.wang7@gmail.com" <baolin.wang7@gmail.com>,
	"zhang.lyra@gmail.com" <zhang.lyra@gmail.com>,
	"wens@csie.org" <wens@csie.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"samuel@sholland.org" <samuel@sholland.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	 "alex.williamson@redhat.com" <alex.williamson@redhat.com>
Cc: "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"gerald.schaefer@linux.ibm.com" <gerald.schaefer@linux.ibm.com>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
	"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>
Subject: RE: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group
Date: Wed, 8 Jun 2022 07:49:10 +0000	[thread overview]
Message-ID: <BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220606061927.26049-2-nicolinc@nvidia.com>

> From: Nicolin Chen
> Sent: Monday, June 6, 2022 2:19 PM
> 
> Cases like VFIO wish to attach a device to an existing domain that was
> not allocated specifically from the device. This raises a condition
> where the IOMMU driver can fail the domain attach because the domain and
> device are incompatible with each other.
> 
> This is a soft failure that can be resolved by using a different domain.
> 
> Provide a dedicated errno from the IOMMU driver during attach that the
> reason attached failed is because of domain incompatability. EMEDIUMTYPE
> is chosen because it is never used within the iommu subsystem today and
> evokes a sense that the 'medium' aka the domain is incompatible.
> 
> VFIO can use this to know attach is a soft failure and it should continue
> searching. Otherwise the attach will be a hard failure and VFIO will
> return the code to userspace.
> 
> Update all drivers to return EMEDIUMTYPE in their failure paths that are
> related to domain incompatability.

Seems not all drivers are converted, e.g.:

mtk_iommu_v1_attach_device():
	/* Only allow the domain created internally. */
	mtk_mapping = data->mapping;
	if (mtk_mapping->domain != domain)
		return 0;
** the current code sounds incorrect which should return an error


s390_iommu_attach_device():
	/* Allow only devices with identical DMA range limits */
	} else if (domain->geometry.aperture_start != zdev->start_dma ||
		domain->geometry.aperture_end != zdev->end_dma) {
		rc = -EINVAL;


sprd_iommu_attach_device():
	if (dom->sdev) {
		pr_err("There's already a device attached to this domain.\n");
		return -EINVAL;
	}


gart_iommu_attach_dev():
	if (gart->active_domain && gart->active_domain != domain) {
		ret = -EBUSY;


arm_smmu_attach_dev():
	if (!fwspec || fwspec->ops != &arm_smmu_ops) {
		dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
		return -ENXIO;
	}
**probably this check can be covered by next patch which moves bus ops
check into iommu core?

Thanks
Kevin
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"marcan@marcan.st" <marcan@marcan.st>,
	"sven@svenpeter.dev" <sven@svenpeter.dev>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"agross@kernel.org" <agross@kernel.org>,
	"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"orsonzhai@gmail.com" <orsonzhai@gmail.com>,
	"baolin.wang7@gmail.com" <baolin.wang7@gmail.com>,
	"zhang.lyra@gmail.com" <zhang.lyra@gmail.com>,
	"wens@csie.org" <wens@csie.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"samuel@sholland.org" <samuel@sholland.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>
Cc: "virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>,
	"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"gerald.schaefer@linux.ibm.com" <gerald.schaefer@linux.ibm.com>,
	"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>
Subject: RE: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group
Date: Wed, 8 Jun 2022 07:49:10 +0000	[thread overview]
Message-ID: <BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220606061927.26049-2-nicolinc@nvidia.com>

> From: Nicolin Chen
> Sent: Monday, June 6, 2022 2:19 PM
> 
> Cases like VFIO wish to attach a device to an existing domain that was
> not allocated specifically from the device. This raises a condition
> where the IOMMU driver can fail the domain attach because the domain and
> device are incompatible with each other.
> 
> This is a soft failure that can be resolved by using a different domain.
> 
> Provide a dedicated errno from the IOMMU driver during attach that the
> reason attached failed is because of domain incompatability. EMEDIUMTYPE
> is chosen because it is never used within the iommu subsystem today and
> evokes a sense that the 'medium' aka the domain is incompatible.
> 
> VFIO can use this to know attach is a soft failure and it should continue
> searching. Otherwise the attach will be a hard failure and VFIO will
> return the code to userspace.
> 
> Update all drivers to return EMEDIUMTYPE in their failure paths that are
> related to domain incompatability.

Seems not all drivers are converted, e.g.:

mtk_iommu_v1_attach_device():
	/* Only allow the domain created internally. */
	mtk_mapping = data->mapping;
	if (mtk_mapping->domain != domain)
		return 0;
** the current code sounds incorrect which should return an error


s390_iommu_attach_device():
	/* Allow only devices with identical DMA range limits */
	} else if (domain->geometry.aperture_start != zdev->start_dma ||
		domain->geometry.aperture_end != zdev->end_dma) {
		rc = -EINVAL;


sprd_iommu_attach_device():
	if (dom->sdev) {
		pr_err("There's already a device attached to this domain.\n");
		return -EINVAL;
	}


gart_iommu_attach_dev():
	if (gart->active_domain && gart->active_domain != domain) {
		ret = -EBUSY;


arm_smmu_attach_dev():
	if (!fwspec || fwspec->ops != &arm_smmu_ops) {
		dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
		return -ENXIO;
	}
**probably this check can be covered by next patch which moves bus ops
check into iommu core?

Thanks
Kevin

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"marcan@marcan.st" <marcan@marcan.st>,
	"sven@svenpeter.dev" <sven@svenpeter.dev>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"agross@kernel.org" <agross@kernel.org>,
	"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"orsonzhai@gmail.com" <orsonzhai@gmail.com>,
	"baolin.wang7@gmail.com" <baolin.wang7@gmail.com>,
	"zhang.lyra@gmail.com" <zhang.lyra@gmail.com>,
	"wens@csie.org" <wens@csie.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"samuel@sholland.org" <samuel@sholland.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>
Cc: "virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>,
	"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"gerald.schaefer@linux.ibm.com" <gerald.schaefer@linux.ibm.com>,
	"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>
Subject: RE: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group
Date: Wed, 8 Jun 2022 07:49:10 +0000	[thread overview]
Message-ID: <BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220606061927.26049-2-nicolinc@nvidia.com>

> From: Nicolin Chen
> Sent: Monday, June 6, 2022 2:19 PM
> 
> Cases like VFIO wish to attach a device to an existing domain that was
> not allocated specifically from the device. This raises a condition
> where the IOMMU driver can fail the domain attach because the domain and
> device are incompatible with each other.
> 
> This is a soft failure that can be resolved by using a different domain.
> 
> Provide a dedicated errno from the IOMMU driver during attach that the
> reason attached failed is because of domain incompatability. EMEDIUMTYPE
> is chosen because it is never used within the iommu subsystem today and
> evokes a sense that the 'medium' aka the domain is incompatible.
> 
> VFIO can use this to know attach is a soft failure and it should continue
> searching. Otherwise the attach will be a hard failure and VFIO will
> return the code to userspace.
> 
> Update all drivers to return EMEDIUMTYPE in their failure paths that are
> related to domain incompatability.

Seems not all drivers are converted, e.g.:

mtk_iommu_v1_attach_device():
	/* Only allow the domain created internally. */
	mtk_mapping = data->mapping;
	if (mtk_mapping->domain != domain)
		return 0;
** the current code sounds incorrect which should return an error


s390_iommu_attach_device():
	/* Allow only devices with identical DMA range limits */
	} else if (domain->geometry.aperture_start != zdev->start_dma ||
		domain->geometry.aperture_end != zdev->end_dma) {
		rc = -EINVAL;


sprd_iommu_attach_device():
	if (dom->sdev) {
		pr_err("There's already a device attached to this domain.\n");
		return -EINVAL;
	}


gart_iommu_attach_dev():
	if (gart->active_domain && gart->active_domain != domain) {
		ret = -EBUSY;


arm_smmu_attach_dev():
	if (!fwspec || fwspec->ops != &arm_smmu_ops) {
		dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
		return -ENXIO;
	}
**probably this check can be covered by next patch which moves bus ops
check into iommu core?

Thanks
Kevin

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"will@kernel.org" <will@kernel.org>,
	"marcan@marcan.st" <marcan@marcan.st>,
	"sven@svenpeter.dev" <sven@svenpeter.dev>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"robdclark@gmail.com" <robdclark@gmail.com>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"agross@kernel.org" <agross@kernel.org>,
	"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"heiko@sntech.de" <heiko@sntech.de>,
	"orsonzhai@gmail.com" <orsonzhai@gmail.com>,
	"baolin.wang7@gmail.com" <baolin.wang7@gmail.com>,
	"zhang.lyra@gmail.com" <zhang.lyra@gmail.com>,
	"wens@csie.org" <wens@csie.org>,
	"jernej.skrabec@gmail.com" <jernej.skrabec@gmail.com>,
	"samuel@sholland.org" <samuel@sholland.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>
Cc: "virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"alyssa@rosenzweig.io" <alyssa@rosenzweig.io>,
	"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"jonathanh@nvidia.com" <jonathanh@nvidia.com>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"gerald.schaefer@linux.ibm.com" <gerald.schaefer@linux.ibm.com>,
	"linux-sunxi@lists.linux.dev" <linux-sunxi@lists.linux.dev>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>
Subject: RE: [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group
Date: Wed, 8 Jun 2022 07:49:10 +0000	[thread overview]
Message-ID: <BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220606061927.26049-2-nicolinc@nvidia.com>

> From: Nicolin Chen
> Sent: Monday, June 6, 2022 2:19 PM
> 
> Cases like VFIO wish to attach a device to an existing domain that was
> not allocated specifically from the device. This raises a condition
> where the IOMMU driver can fail the domain attach because the domain and
> device are incompatible with each other.
> 
> This is a soft failure that can be resolved by using a different domain.
> 
> Provide a dedicated errno from the IOMMU driver during attach that the
> reason attached failed is because of domain incompatability. EMEDIUMTYPE
> is chosen because it is never used within the iommu subsystem today and
> evokes a sense that the 'medium' aka the domain is incompatible.
> 
> VFIO can use this to know attach is a soft failure and it should continue
> searching. Otherwise the attach will be a hard failure and VFIO will
> return the code to userspace.
> 
> Update all drivers to return EMEDIUMTYPE in their failure paths that are
> related to domain incompatability.

Seems not all drivers are converted, e.g.:

mtk_iommu_v1_attach_device():
	/* Only allow the domain created internally. */
	mtk_mapping = data->mapping;
	if (mtk_mapping->domain != domain)
		return 0;
** the current code sounds incorrect which should return an error


s390_iommu_attach_device():
	/* Allow only devices with identical DMA range limits */
	} else if (domain->geometry.aperture_start != zdev->start_dma ||
		domain->geometry.aperture_end != zdev->end_dma) {
		rc = -EINVAL;


sprd_iommu_attach_device():
	if (dom->sdev) {
		pr_err("There's already a device attached to this domain.\n");
		return -EINVAL;
	}


gart_iommu_attach_dev():
	if (gart->active_domain && gart->active_domain != domain) {
		ret = -EBUSY;


arm_smmu_attach_dev():
	if (!fwspec || fwspec->ops != &arm_smmu_ops) {
		dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
		return -ENXIO;
	}
**probably this check can be covered by next patch which moves bus ops
check into iommu core?

Thanks
Kevin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-06-08  7:49 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06  6:19 [PATCH 0/5] Simplify vfio_iommu_type1 attach/detach routine Nicolin Chen
2022-06-06  6:19 ` Nicolin Chen
2022-06-06  6:19 ` Nicolin Chen
2022-06-06  6:19 ` Nicolin Chen via iommu
2022-06-06  6:19 ` Nicolin Chen
2022-06-06  6:19 ` [PATCH 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen via iommu
2022-06-06  6:19   ` Nicolin Chen
2022-06-07  3:23   ` Baolu Lu
2022-06-07  3:23     ` Baolu Lu
2022-06-07  3:23     ` Baolu Lu
2022-06-07  3:23     ` Baolu Lu
2022-06-07  3:23     ` Baolu Lu
2022-06-07  4:03     ` Nicolin Chen
2022-06-07  4:03       ` Nicolin Chen
2022-06-07  4:03       ` Nicolin Chen
2022-06-07  4:03       ` Nicolin Chen via iommu
2022-06-07  4:03       ` Nicolin Chen
2022-06-08  7:49   ` Tian, Kevin [this message]
2022-06-08  7:49     ` Tian, Kevin
2022-06-08  7:49     ` Tian, Kevin
2022-06-08  7:49     ` Tian, Kevin
2022-06-08  7:49     ` Tian, Kevin
2022-06-08  7:49     ` Tian, Kevin
2022-06-08 17:38     ` Nicolin Chen
2022-06-08 17:38       ` Nicolin Chen
2022-06-08 17:38       ` Nicolin Chen
2022-06-08 17:38       ` Nicolin Chen
2022-06-08 17:38       ` Nicolin Chen via iommu
2022-06-06  6:19 ` [PATCH 2/5] iommu: Ensure device has the same iommu_ops as the domain Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen via iommu
2022-06-06 14:33   ` Robin Murphy
2022-06-06 14:33     ` Robin Murphy
2022-06-06 14:33     ` Robin Murphy
2022-06-06 14:33     ` Robin Murphy
2022-06-06 14:33     ` Robin Murphy
2022-06-06 14:33     ` Robin Murphy
2022-06-06 16:51     ` Nicolin Chen
2022-06-06 16:51       ` Nicolin Chen
2022-06-06 16:51       ` Nicolin Chen
2022-06-06 16:51       ` Nicolin Chen
2022-06-06 16:51       ` Nicolin Chen via iommu
2022-06-06 17:50       ` Robin Murphy
2022-06-06 17:50         ` Robin Murphy
2022-06-06 17:50         ` Robin Murphy
2022-06-06 17:50         ` Robin Murphy
2022-06-06 17:50         ` Robin Murphy
2022-06-06 17:50         ` Robin Murphy
2022-06-06 18:28         ` Nicolin Chen
2022-06-06 18:28           ` Nicolin Chen
2022-06-06 18:28           ` Nicolin Chen
2022-06-06 18:28           ` Nicolin Chen via iommu
2022-06-06 18:28           ` Nicolin Chen
2022-06-06 18:52           ` Jason Gunthorpe
2022-06-06 18:52             ` Jason Gunthorpe
2022-06-06 18:52             ` Jason Gunthorpe
2022-06-06 18:52             ` Jason Gunthorpe
2022-06-06 18:52             ` Jason Gunthorpe via iommu
2022-06-06  6:19 ` [PATCH 3/5] vfio/iommu_type1: Prefer to reuse domains vs match enforced cache coherency Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen via iommu
2022-06-08  8:28   ` Tian, Kevin
2022-06-08  8:28     ` Tian, Kevin
2022-06-08  8:28     ` Tian, Kevin
2022-06-08  8:28     ` Tian, Kevin
2022-06-08  8:28     ` Tian, Kevin
2022-06-08  8:28     ` Tian, Kevin
2022-06-08 11:17     ` Jason Gunthorpe
2022-06-08 11:17       ` Jason Gunthorpe
2022-06-08 11:17       ` Jason Gunthorpe
2022-06-08 11:17       ` Jason Gunthorpe via iommu
2022-06-08 11:17       ` Jason Gunthorpe
2022-06-08 23:48       ` Tian, Kevin
2022-06-08 23:48         ` Tian, Kevin
2022-06-08 23:48         ` Tian, Kevin
2022-06-08 23:48         ` Tian, Kevin
2022-06-08 23:48         ` Tian, Kevin
2022-06-08 23:48         ` Tian, Kevin
2022-06-14 20:45         ` Nicolin Chen
2022-06-14 20:45           ` Nicolin Chen
2022-06-14 20:45           ` Nicolin Chen
2022-06-14 20:45           ` Nicolin Chen via iommu
2022-06-14 20:45           ` Nicolin Chen
2022-06-15  7:35           ` Tian, Kevin
2022-06-15  7:35             ` Tian, Kevin
2022-06-15  7:35             ` Tian, Kevin
2022-06-15  7:35             ` Tian, Kevin
2022-06-15  7:35             ` Tian, Kevin
2022-06-15  7:35             ` Tian, Kevin
2022-06-15 23:12             ` Nicolin Chen
2022-06-15 23:12               ` Nicolin Chen
2022-06-15 23:12               ` Nicolin Chen via iommu
2022-06-15 23:12               ` Nicolin Chen
2022-06-06  6:19 ` [PATCH 4/5] vfio/iommu_type1: Clean up update_dirty_scope in detach_group() Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen via iommu
2022-06-08  8:35   ` Tian, Kevin
2022-06-08  8:35     ` Tian, Kevin
2022-06-08  8:35     ` Tian, Kevin
2022-06-08  8:35     ` Tian, Kevin
2022-06-08  8:35     ` Tian, Kevin
2022-06-08  8:35     ` Tian, Kevin
2022-06-08 17:46     ` Nicolin Chen
2022-06-08 17:46       ` Nicolin Chen
2022-06-08 17:46       ` Nicolin Chen
2022-06-08 17:46       ` Nicolin Chen
2022-06-08 17:46       ` Nicolin Chen via iommu
2022-06-06  6:19 ` [PATCH 5/5] vfio/iommu_type1: Simplify group attachment Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen
2022-06-06  6:19   ` Nicolin Chen via iommu
2022-06-07  7:44 ` [PATCH 0/5] Simplify vfio_iommu_type1 attach/detach routine Baolu Lu
2022-06-07  7:44   ` Baolu Lu
2022-06-07  7:44   ` Baolu Lu
2022-06-07  7:44   ` Baolu Lu
2022-06-07  7:44   ` Baolu Lu
2022-06-07 11:58   ` Jason Gunthorpe
2022-06-07 11:58     ` Jason Gunthorpe
2022-06-07 11:58     ` Jason Gunthorpe
2022-06-07 11:58     ` Jason Gunthorpe
2022-06-07 11:58     ` Jason Gunthorpe via iommu
2022-06-07 12:42     ` Baolu Lu
2022-06-07 12:42       ` Baolu Lu
2022-06-07 12:42       ` Baolu Lu
2022-06-07 12:42       ` Baolu Lu
2022-06-07 12:42       ` Baolu Lu
2022-06-10 16:39 [PATCH 5/5] vfio/iommu_type1: Simplify group attachment kernel test robot
2022-06-13 13:42 ` Dan Carpenter

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=BN9PR11MB52763602BBEEEF580C3B360E8CA49@BN9PR11MB5276.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=agross@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=alim.akhtar@samsung.com \
    --cc=alyssa@rosenzweig.io \
    --cc=baolin.wang7@gmail.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=cohuck@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=heiko@sntech.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jean-philippe@linaro.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=marcan@marcan.st \
    --cc=matthias.bgg@gmail.com \
    --cc=nicolinc@nvidia.com \
    --cc=orsonzhai@gmail.com \
    --cc=robdclark@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=samuel@sholland.org \
    --cc=sven@svenpeter.dev \
    --cc=thierry.reding@gmail.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wens@csie.org \
    --cc=will@kernel.org \
    --cc=zhang.lyra@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.