Skip to contentSkip to conversation

docs: kvm: vfio: Require call KVM_DEV_VFIO_GROUP_ADD before VFIO_GROUP_GET_DEVICE_FD

PATCH Superseded Yi Liu 2 participants 4 messages Feb 21, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yi Liu

author
#0 lore raw

PATCH 1/1 docs: kvm: vfio: Require call KVM_DEV_VFIO_GROUP_ADD before VFIO_GROUP_GET_DEVICE_FD

as some vfio_device's open_device op requires kvm pointer and kvm pointer set is part of GROUP_ADD.

---
 Documentation/virt/kvm/devices/vfio.rst | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +5 -0
index 2d20dc561069..5722e283f1b5 100644
@@ -39,3 +39,8 @@ KVM_DEV_VFIO_GROUP attributes:
 	- @groupfd is a file descriptor for a VFIO group;
 	- @tablefd is a file descriptor for a TCE table allocated via
 	  KVM_CREATE_SPAPR_TCE.
+
+::
+
+The GROUP_ADD operation above should be invoked before vfio_device's
+open_device op which is called in the ioctl VFIO_GROUP_GET_DEVICE_FD.
Signature · 1 line
2.34.1
#1 lore raw
Quoted 13 lines · On Mon, 20 Feb 2023 19:41:14 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device's open_device op requires kvm pointer and kvm pointer set is part of GROUP_ADD.

---
 Documentation/virt/kvm/devices/vfio.rst | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +0 -0
index 2d20dc561069..5722e283f1b5 100644

Documentation/virt/kvm/devices/vfio.rst KVM_DEV_VFIO_GROUP attributes: · line 46

Quoted 8 lines
Documentation/virt/kvm/devices/vfio.rst +5 -0
@@ -39,3 +39,8 @@ KVM_DEV_VFIO_GROUP attributes:
 	- @groupfd is a file descriptor for a VFIO group;
 	- @tablefd is a file descriptor for a TCE table allocated via
 	  KVM_CREATE_SPAPR_TCE.
+
+::
+
+The GROUP_ADD operation above should be invoked before vfio_device's
+open_device op which is called in the ioctl VFIO_GROUP_GET_DEVICE_FD.

Why only include the reasoning in the commit log and not the docs? Thanks,

Alex

author
#2 lore raw
Quoted 29 lines

From: Alex Williamson <[email protected]>
Sent: Tuesday, February 21, 2023 12:39 PM

Quoted 1 line · On Mon, 20 Feb 2023 19:41:14 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device's open_device op requires kvm pointer and kvm

pointer

Review

Quoted 8 lines

set is part of GROUP_ADD.

---
 Documentation/virt/kvm/devices/vfio.rst | 5 +++++
 1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/Documentation/virt/kvm/devices/vfio.rst

Documentation/virt/kvm/devices/vfio.rst KVM_DEV_VFIO_GROUP attributes: · line 45

Quoted 11 lines

index 2d20dc561069..5722e283f1b5 100644

Documentation/virt/kvm/devices/vfio.rst +4 -0
@@ -39,3 +39,8 @@ KVM_DEV_VFIO_GROUP attributes:
 	- @groupfd is a file descriptor for a VFIO group;
 	- @tablefd is a file descriptor for a TCE table allocated via
 	  KVM_CREATE_SPAPR_TCE.
+
+::
+
+The GROUP_ADD operation above should be invoked before

vfio_device's

Quoted 4 lines

Documentation/virt/kvm/devices/vfio.rst KVM_DEV_VFIO_GROUP attributes: · line 46

Quoted 1 line
Documentation/virt/kvm/devices/vfio.rst +1 -0
+open_device op which is called in the ioctl

VFIO_GROUP_GET_DEVICE_FD.

Why only include the reasoning in the commit log and not the docs?

Oops, sure. How about below?

KVM_DEV_VFIO_GROUP_ADD has a duty to set the kvm pointer to VFIO as some vfio_devices require kvm pointer to open_device. Like gvt-g, vfio-ap and etc. Meanwhile, open_device is part of VFIO_GROUP_GET_DEVICE_FD. Hence user should invoke KVM_DEV_VFIO_GROUP_ADD before VFIO_GROUP_GET_DEVICE_FD.

Regards,
Yi Liu

#3 lore raw
Quoted 32 lines · Yi L
Quoted 32 lines

From: Alex Williamson <[email protected]>
Sent: Tuesday, February 21, 2023 12:39 PM

Quoted 1 line · On Mon, 20 Feb 2023 19:41:14 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device's open_device op requires kvm pointer and kvm

pointer

Review

Quoted 8 lines

set is part of GROUP_ADD.

---
 Documentation/virt/kvm/devices/vfio.rst | 5 +++++
 1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/Documentation/virt/kvm/devices/vfio.rst

Documentation/virt/kvm/devices/vfio.rst KVM_DEV_VFIO_GROUP attributes: · line 45

Quoted 11 lines

index 2d20dc561069..5722e283f1b5 100644

Documentation/virt/kvm/devices/vfio.rst +4 -0
@@ -39,3 +39,8 @@ KVM_DEV_VFIO_GROUP attributes:
 	- @groupfd is a file descriptor for a VFIO group;
 	- @tablefd is a file descriptor for a TCE table allocated via
 	  KVM_CREATE_SPAPR_TCE.
+
+::
+
+The GROUP_ADD operation above should be invoked before  

vfio_device's

Documentation/virt/kvm/devices/vfio.rst KVM_DEV_VFIO_GROUP attributes: · line 46

Quoted 1 line
Documentation/virt/kvm/devices/vfio.rst +1 -0
+open_device op which is called in the ioctl  

VFIO_GROUP_GET_DEVICE_FD.

Quoted 8 lines
Quoted 1 line

Why only include the reasoning in the commit log and not the docs?

Oops, sure. How about below?

KVM_DEV_VFIO_GROUP_ADD has a duty to set the kvm pointer to VFIO as some vfio_devices require kvm pointer to open_device. Like gvt-g, vfio-ap and etc. Meanwhile, open_device is part of VFIO_GROUP_GET_DEVICE_FD. Hence user should invoke KVM_DEV_VFIO_GROUP_ADD before VFIO_GROUP_GET_DEVICE_FD.

How about:

The GROUP_ADD operation above should be invoked prior to accessing the device file descriptor via VFIO_GROUP_GET_DEVICE_FD in order to support drivers which require a kvm pointer to be set in their .open_device() callback.

Thanks,
Alex