mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev
@ 2025-04-22 11:29 Qinxin Xia
  2025-05-06 19:04 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Qinxin Xia @ 2025-04-22 11:29 UTC (permalink / raw)
  To: will, robin.murphy, yangyicong, wangzhou1
  Cc: linuxarm, linux-arm-kernel, linux-kernel, xiaqinxin

An error is introduced in commit '48e7b8e284e5'. When the smmu
does not match with domain,an error code is not returned.
An example of an error scenario: In vfio_iommu_type1_attach_group,
vfio will try to match an existing compatible domain. During this process,
iommu invokes the attach_dev interface.The mismatched dev and domain
does not return an error code as expected.
As a result, an exception occurs when the vfio operates the smmu.

Fixes: 48e7b8e284e5 ("iommu/arm-smmu-v3: Remove arm_smmu_domain_finalise() during attach")
Signed-off-by: Qinxin Xia <xiaqinxin@huawei.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 358072b4e293..cb2698325809 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2932,7 +2932,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
 	smmu = master->smmu;
 
 	if (smmu_domain->smmu != smmu)
-		return ret;
+		return -EINVAL;
 
 	if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
 		cdptr = arm_smmu_alloc_cd_ptr(master, IOMMU_NO_PASID);
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev
  2025-04-22 11:29 [PATCH] iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev Qinxin Xia
@ 2025-05-06 19:04 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2025-05-06 19:04 UTC (permalink / raw)
  To: robin.murphy, yangyicong, wangzhou1, Qinxin Xia
  Cc: catalin.marinas, kernel-team, Will Deacon, linuxarm,
	linux-arm-kernel, linux-kernel

On Tue, 22 Apr 2025 19:29:51 +0800, Qinxin Xia wrote:
> An error is introduced in commit '48e7b8e284e5'. When the smmu
> does not match with domain,an error code is not returned.
> An example of an error scenario: In vfio_iommu_type1_attach_group,
> vfio will try to match an existing compatible domain. During this process,
> iommu invokes the attach_dev interface.The mismatched dev and domain
> does not return an error code as expected.
> As a result, an exception occurs when the vfio operates the smmu.
> 
> [...]

Applied to iommu (arm/smmu/updates), thanks!

[1/1] iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev
      https://git.kernel.org/iommu/c/be5a2d3f8f97

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-06 19:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-22 11:29 [PATCH] iommu/arm-smmu-v3: Fix incorrect return in arm_smmu_attach_dev Qinxin Xia
2025-05-06 19:04 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®