Skip to contentSkip to conversation

docs: kvm: vfio: Require call KVM_DEV_VFIO_GROUP_ADD before VFIO_GROUP_GET_DEVICE_FD

PATCH In review Yi Liu 3 participants 9 messages Feb 22, 2023 – Apr 17, 2023

Subsystems (2)
lore
Share & tools
lore

Yi Liu

author
#0 lore raw

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

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +7 -0
index 2d20dc561069..79b6811bb4f3 100644
@@ -39,3 +39,10 @@ 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 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.
Signature · 1 line
2.34.1
#2 lore raw
In reply to Yi Liu

Paolo's mail address is wrong. Added the right one.

Quoted 34 lines

From: Liu, Yi L <[email protected]>
Sent: Wednesday, February 22, 2023 10:23 AM

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/20230221034114.135386-1-
[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +7 -1
index 2d20dc561069..79b6811bb4f3 100644
@@ -39,3 +39,10 @@ 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 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.
--

2.34.1

author
#3 lore raw
Quoted 4 lines

From: Tian, Kevin <[email protected]>
Sent: Wednesday, February 22, 2023 10:33 AM

Paolo's mail address is wrong. Added the right one.

Thanks. @Alex, do you want a new version or this one is ok?

Regards,
Yi Liu

Quoted 36 lines
Quoted 22 lines

From: Liu, Yi L <[email protected]>
Sent: Wednesday, February 22, 2023 10:23 AM

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/20230221034114.135386-1-
[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +0 -0
index 2d20dc561069..79b6811bb4f3 100644

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

Quoted 7 lines
Documentation/virt/kvm/devices/vfio.rst +4 -0
@@ -39,3 +39,10 @@ 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 prior to accessing

the

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

Quoted 1 line
Documentation/virt/kvm/devices/vfio.rst +1 -0
+device file descriptor via VFIO_GROUP_GET_DEVICE_FD in order to

support

Quoted 4 lines
Documentation/virt/kvm/devices/vfio.rst +2 -1
+drivers which require a kvm pointer to be set in their .open_device()
+callback.
--

2.34.1

#4 lore raw
Quoted 6 lines · Yi L
Quoted 4 lines

From: Tian, Kevin <[email protected]>
Sent: Wednesday, February 22, 2023 10:33 AM

Paolo's mail address is wrong. Added the right one.

Thanks. @Alex, do you want a new version or this one is ok?

This one is fine. Thanks,

Alex

Quoted 37 lines
Quoted 36 lines
Quoted 22 lines

From: Liu, Yi L <[email protected]>
Sent: Wednesday, February 22, 2023 10:23 AM

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/20230221034114.135386-1-
[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +0 -0
index 2d20dc561069..79b6811bb4f3 100644

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

Quoted 7 lines
Documentation/virt/kvm/devices/vfio.rst +4 -0
@@ -39,3 +39,10 @@ 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 prior to accessing  

the

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

Quoted 1 line
Documentation/virt/kvm/devices/vfio.rst +1 -0
+device file descriptor via VFIO_GROUP_GET_DEVICE_FD in order to  

support

Quoted 4 lines
Documentation/virt/kvm/devices/vfio.rst +2 -1
+drivers which require a kvm pointer to be set in their .open_device()
+callback.
--

2.34.1

#5 lore raw
In reply to Yi Liu
Quoted 17 lines · On Tue, 21 Feb 2023 18:22:31 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +0 -0
index 2d20dc561069..79b6811bb4f3 100644

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

Quoted 10 lines
Documentation/virt/kvm/devices/vfio.rst +7 -0
@@ -39,3 +39,10 @@ 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 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.

I updated the title and commit log so as not to further construe that documentation can impose a requirement, otherwise applied to vfio next branch for v6.4. Thanks,

Alex

#6 lore raw
Quoted 26 lines · On Tue, 11 Apr 2023 13:28:03 -0600 Alex Williamson…
Quoted 23 lines · On Tue, 21 Feb 2023 18:22:31 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +3 -0
index 2d20dc561069..79b6811bb4f3 100644
@@ -39,3 +39,10 @@ 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.
+
+::
+
Quoted 8 lines

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

Quoted 4 lines
Documentation/virt/kvm/devices/vfio.rst +4 -0
+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.  

I updated the title and commit log so as not to further construe that documentation can impose a requirement, otherwise applied to vfio next branch for v6.4. Thanks,

Dropped

https://lore.kernel.org/all/[email protected]/

Please resubmit, resolving the warning and change the title since a requirement of some drivers does not equate to a requirement of the API. Thanks,

Alex

author
#7 lore raw
Quoted 41 lines

From: Alex Williamson <[email protected]>
Sent: Saturday, April 15, 2023 4:08 AM

Quoted 15 lines · On Tue, 11 Apr 2023 13:28:03 -0600 Alex Williamson…
Quoted 12 lines · On Tue, 21 Feb 2023 18:22:31 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

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

Quoted 10 lines
Quoted 10 lines

index 2d20dc561069..79b6811bb4f3 100644

Documentation/virt/kvm/devices/vfio.rst +3 -0
@@ -39,3 +39,10 @@ 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.
+
+::
+
Quoted 8 lines

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

Quoted 4 lines
Documentation/virt/kvm/devices/vfio.rst +4 -0
+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.

I updated the title and commit log so as not to further construe that documentation can impose a requirement, otherwise applied to vfio next branch for v6.4. Thanks,

Quoted 7 lines

Dropped

https://lore.kernel.org/all/[email protected]/

Please resubmit, resolving the warning and change the title since a requirement of some drivers does not equate to a requirement of the API. Thanks,

Sorry for it. May just remove the "::". So a version as below. Please let me know it is ok, then I'll submit it.

From abfc87425aa2977c08511b648a194bcfb072dcb8 Mon Sep 17 00:00:00 2001
From: Yi Liu <[email protected]>
Date: Thu, 16 Feb 2023 02:37:28 -0800
Subject: [PATCH] docs: kvm: vfio: Suggest KVM_DEV_VFIO_GROUP_ADD vs VFIO_GROUP_GET_DEVICE_FD ordering

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 | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +5 -0
index 2d20dc561069..79b6811bb4f3 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 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.
Signature · 1 line
2.34.1
#8 lore raw
Quoted 43 lines · Yi L
Quoted 43 lines

From: Alex Williamson <[email protected]>
Sent: Saturday, April 15, 2023 4:08 AM

Quoted 15 lines · On Tue, 11 Apr 2023 13:28:03 -0600 Alex Williamson…
Quoted 12 lines · On Tue, 21 Feb 2023 18:22:31 -0800 Yi Liu <[email protected]> wrote:

as some vfio_device drivers require a kvm pointer to be set in their open_device and kvm pointer is set to VFIO in GROUP_ADD path.

---
v2:
- Adopt Alex's suggestion
v1: https://lore.kernel.org/kvm/[email protected]/

---
 Documentation/virt/kvm/devices/vfio.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

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

Quoted 10 lines
Quoted 10 lines

index 2d20dc561069..79b6811bb4f3 100644

Documentation/virt/kvm/devices/vfio.rst +3 -0
@@ -39,3 +39,10 @@ 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.
+
+::
+
Quoted 8 lines

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

Quoted 4 lines
Documentation/virt/kvm/devices/vfio.rst +4 -0
+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.  

I updated the title and commit log so as not to further construe that documentation can impose a requirement, otherwise applied to vfio next branch for v6.4. Thanks,

Dropped

Quoted 8 lines
Quoted 5 lines

https://lore.kernel.org/all/[email protected]/

Please resubmit, resolving the warning and change the title since a requirement of some drivers does not equate to a requirement of the API. Thanks,

Sorry for it. May just remove the "::". So a version as below. Please let me know it is ok, then I'll submit it.

Sure, so long as the docs build warning is gone. I'll wait for a separate v3 posting. Thanks,

Alex

Quoted 26 lines

From abfc87425aa2977c08511b648a194bcfb072dcb8 Mon Sep 17 00:00:00 2001
From: Yi Liu <[email protected]>
Date: Thu, 16 Feb 2023 02:37:28 -0800
Subject: [PATCH] docs: kvm: vfio: Suggest KVM_DEV_VFIO_GROUP_ADD vs VFIO_GROUP_GET_DEVICE_FD ordering

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 | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/virt/kvm/devices/vfio.rst +5 -0
index 2d20dc561069..79b6811bb4f3 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 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.