[RFC PATCH v1 36/42] KVM: plane: handle KVM_CHECK_EXTENSION on the plane fd

Sriram Nambakam <[email protected]>
Newsgroups org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
A plane file descriptor did not implement KVM_CHECK_EXTENSION and failed
with -ENOTTY, but userspace needs to be able to query capabilities on it.
Forward the query to the plane's parent VM, except for KVM_CAP_PLANES
which returns 0 because a plane cannot host planes of its own.
---
 virt/kvm/kvm_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 3a1a09f26340..6e4f3f3e6881 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4946,12 +4946,21 @@ static long kvm_vcpu_compat_ioctl(struct file *filp,
 }
 #endif
 
+static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg);
+
 static long __kvm_plane_ioctl(struct kvm_plane *plane, unsigned int ioctl, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
 	long r;
 
 	switch (ioctl) {
+	case KVM_CHECK_EXTENSION:
+		/* A plane cannot host planes of its own. */
+		if (arg == KVM_CAP_PLANES)
+			r = 0;
+		else
+			r = kvm_vm_ioctl_check_extension_generic(plane->kvm, arg);
+		break;
 	case KVM_CREATE_VCPU:
 		r = kvm_plane_ioctl_create_vcpu(plane, arg);
 		break;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.