Thread (77 messages) 77 messages, 4 authors, 2025-01-23

Re: [PATCH v5 13/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

From: Nicolin Chen <hidden>
Date: 2025-01-13 19:53:14
Also in: linux-doc, linux-iommu, linux-kselftest, linux-patches, lkml

On Mon, Jan 13, 2025 at 03:29:27PM -0400, Jason Gunthorpe wrote:
On Tue, Jan 07, 2025 at 09:10:16AM -0800, Nicolin Chen wrote:
quoted
+int arm_smmu_attach_prepare_vmaster(struct arm_smmu_attach_state *state,
+				    struct iommu_domain *domain)
+{
+	struct arm_smmu_nested_domain *nested_domain;
+	struct arm_smmu_vmaster *vmaster;
+	unsigned long vsid;
+	unsigned int cfg;
+
+	iommu_group_mutex_assert(state->master->dev);
+
+	if (domain->type != IOMMU_DOMAIN_NESTED)
+		return 0;
+	nested_domain = to_smmu_nested_domain(domain);
+
+	/* Skip ABORT/BYPASS or invalid vSTE */
+	cfg = FIELD_GET(STRTAB_STE_0_CFG, le64_to_cpu(nested_domain->ste[0]));
+	if (cfg == STRTAB_STE_0_CFG_ABORT || cfg == STRTAB_STE_0_CFG_BYPASS)
+		return 0;
Why? If the VM sets an ABORT vSTE then I would expect that any
protection violation events the VM triggers are captured and forwarded
as well?

Basically any time a vSTE is in place we should capture events that
are affiliated with the SID?
I see. I will drop this.
 
quoted
+	if (!(nested_domain->ste[0] & cpu_to_le64(STRTAB_STE_0_V)))
+		return 0;
+
+	vsid = iommufd_viommu_get_vdev_id(&nested_domain->vsmmu->core,
+					  state->master->dev);
+	/* Fail the attach if vSID is not correct set by the user space */
+	if (!vsid)
+		return -ENOENT;
Is it really OK that 0 is being used as invalid here?
Hmm, perhaps better to do an int function for -ENOENT. Will fix
this.

Thanks
Nicolin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help