Thread (9 messages) 9 messages, 3 authors, 2018-06-26

Re: [PATCH v2 3/5] iommu/virtio: Add probe request

From: Jean-Philippe Brucker <hidden>
Date: 2018-06-26 17:59:26
Also in: kvm, kvmarm, linux-iommu

On 21/06/18 20:06, Jean-Philippe Brucker wrote:
+static int viommu_add_resv_mem(struct viommu_endpoint *vdev,
+			       struct virtio_iommu_probe_resv_mem *mem,
+			       size_t len)
+{
+	struct iommu_resv_region *region = NULL;
+	unsigned long prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO;
+
+	u64 start = le64_to_cpu(mem->start);
+	u64 end = le64_to_cpu(mem->end);
+	size_t size = end - start + 1;
+
+	if (len < sizeof(*mem))
+		return -EINVAL;
+
+	switch (mem->subtype) {
+	default:
+		if (mem->subtype != VIRTIO_IOMMU_RESV_MEM_T_RESERVED &&
+		    mem->subtype != VIRTIO_IOMMU_RESV_MEM_T_MSI)
Hm, I messed it up while rebasing. I'll remove this condition.

Thanks,
Jean
+			dev_warn(vdev->dev, "unknown resv mem subtype 0x%x\n",
+				 mem->subtype);
+		/* Fall-through */
+	case VIRTIO_IOMMU_RESV_MEM_T_RESERVED:
+		region = iommu_alloc_resv_region(start, size, 0,
+						 IOMMU_RESV_RESERVED);
+		break;
+	case VIRTIO_IOMMU_RESV_MEM_T_MSI:
+		region = iommu_alloc_resv_region(start, size, prot,
+						 IOMMU_RESV_MSI);
+		break;
+	}
+
+	list_add(&vdev->resv_regions, &region->list);
+	return 0;
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help