All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd
@ 2025-05-25  7:49 Aneesh Kumar K.V (Arm)
  2025-05-25  7:49 ` [RFC PATCH kvmtool 02/10] vfio: Rename some functions Aneesh Kumar K.V (Arm)
                   ` (9 more replies)
  0 siblings, 10 replies; 38+ messages in thread
From: Aneesh Kumar K.V (Arm) @ 2025-05-25  7:49 UTC (permalink / raw)
  To: kvm
  Cc: Suzuki K Poulose, Steven Price, Will Deacon, Julien Thierry,
	Aneesh Kumar K.V (Arm)

This is needed for followup patches

Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
 vfio/core.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/vfio/core.c b/vfio/core.c
index 3ff2c0b075df..c6b305c30cf7 100644
--- a/vfio/core.c
+++ b/vfio/core.c
@@ -9,6 +9,7 @@
 #define IOMMU_GROUP_DIR		"/sys/kernel/iommu_groups"
 
 static int vfio_container;
+static int kvm_vfio_device;
 static LIST_HEAD(vfio_groups);
 static struct vfio_device *vfio_devices;
 
@@ -437,8 +438,19 @@ static int vfio_configure_groups(struct kvm *kvm)
 		ret = vfio_configure_reserved_regions(kvm, group);
 		if (ret)
 			return ret;
-	}
 
+		struct kvm_device_attr attr = {
+			.group = KVM_DEV_VFIO_FILE,
+			.attr = KVM_DEV_VFIO_FILE_ADD,
+			.addr = (__u64)&group->fd,
+		};
+
+		if (ioctl(kvm_vfio_device, KVM_SET_DEVICE_ATTR, &attr)) {
+			pr_err("Failed KVM_SET_DEVICE_ATTR for KVM_DEV_VFIO_FILE");
+			return -ENODEV;
+		}
+
+	}
 	return 0;
 }
 
@@ -656,6 +668,16 @@ static int vfio__init(struct kvm *kvm)
 	if (!vfio_devices)
 		return -ENOMEM;
 
+	struct kvm_create_device device = {
+		.type = KVM_DEV_TYPE_VFIO,
+	};
+
+	if (ioctl(kvm->vm_fd, KVM_CREATE_DEVICE, &device)) {
+		pr_err("Failed KVM_CREATE_DEVICE ioctl");
+		return -ENODEV;
+	}
+	kvm_vfio_device = device.fd;
+
 	ret = vfio_container_init(kvm);
 	if (ret)
 		return ret;
-- 
2.43.0


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

end of thread, other threads:[~2025-08-11  6:16 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25  7:49 [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd Aneesh Kumar K.V (Arm)
2025-05-25  7:49 ` [RFC PATCH kvmtool 02/10] vfio: Rename some functions Aneesh Kumar K.V (Arm)
2025-07-27 18:20   ` Mostafa Saleh
2025-07-29  4:53     ` Aneesh Kumar K.V
2025-05-25  7:49 ` [RFC PATCH kvmtool 03/10] vfio: Create new file legacy.c Aneesh Kumar K.V (Arm)
2025-07-27 18:23   ` Mostafa Saleh
2025-07-29  4:59     ` Aneesh Kumar K.V
2025-05-25  7:49 ` [RFC PATCH kvmtool 04/10] vfio: Update vfio header from linux kernel Aneesh Kumar K.V (Arm)
2025-07-27 18:23   ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 05/10] vfio: Add dma map/unmap handlers Aneesh Kumar K.V (Arm)
2025-07-27 18:25   ` Mostafa Saleh
2025-07-29  5:03     ` Aneesh Kumar K.V
2025-05-25  7:49 ` [RFC PATCH kvmtool 06/10] vfio/iommufd: Import iommufd header from kernel Aneesh Kumar K.V (Arm)
2025-07-27 18:25   ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 07/10] vfio/iommufd: Add basic iommufd support Aneesh Kumar K.V (Arm)
2025-07-27 18:31   ` Mostafa Saleh
2025-07-29  5:12     ` Aneesh Kumar K.V
2025-07-29  9:38       ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 08/10] vfio/iommufd: Move the hwpt allocation to helper Aneesh Kumar K.V (Arm)
2025-07-27 18:32   ` Mostafa Saleh
2025-07-29  5:14     ` Aneesh Kumar K.V
2025-07-29  9:43       ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 09/10] vfio/iommufd: Add viommu and vdevice objects Aneesh Kumar K.V (Arm)
2025-07-21 12:27   ` Will Deacon
2025-07-24 14:09     ` Aneesh Kumar K.V
2025-08-04 22:33       ` Suzuki K Poulose
2025-08-08 13:00         ` Will Deacon
2025-08-11  6:16           ` Aneesh Kumar K.V
2025-07-27 18:35   ` Mostafa Saleh
2025-07-29  5:19     ` Aneesh Kumar K.V
2025-07-29  9:41       ` Mostafa Saleh
2025-07-30  8:13         ` Aneesh Kumar K.V
2025-07-30 14:15           ` Mostafa Saleh
2025-07-31  4:39             ` Aneesh Kumar K.V
2025-08-04 15:07               ` Mostafa Saleh
2025-05-25  7:49 ` [RFC PATCH kvmtool 10/10] util/update_headers: Add vfio related header files to update list Aneesh Kumar K.V (Arm)
2025-07-27 18:35   ` Mostafa Saleh
2025-07-27 18:19 ` [RFC PATCH kvmtool 01/10] vfio: Associate vm instance with vfio fd Mostafa Saleh

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.