]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
kvm: Add support for arch compat vm ioctls
authorAlexander Graf <graf@amazon.com>
Mon, 17 Oct 2022 18:45:39 +0000 (20:45 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 24 Nov 2022 13:25:45 +0000 (14:25 +0100)
BugLink: https://bugs.launchpad.net/bugs/1997113
commit ed51862f2f57cbce6fed2d4278cfe70a490899fd upstream.

We will introduce the first architecture specific compat vm ioctl in the
next patch. Add all necessary boilerplate to allow architectures to
override compat vm ioctls when necessary.

Signed-off-by: Alexander Graf <graf@amazon.com>
Message-Id: <20221017184541.2658-2-graf@amazon.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index 725f8f13adb55cfa900951d72cf73761e84ac5ae..7e2423ffaf593a9262286d930a18bbb0582bea6b 100644 (file)
@@ -1124,6 +1124,8 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
                            struct kvm_enable_cap *cap);
 long kvm_arch_vm_ioctl(struct file *filp,
                       unsigned int ioctl, unsigned long arg);
+long kvm_arch_vm_compat_ioctl(struct file *filp, unsigned int ioctl,
+                             unsigned long arg);
 
 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
index 3ae5f6a3eae497d9dd53c1004eabf29fdc05a0dd..3ffed093d3ea24ce96d7fd0c7976c23cc399061b 100644 (file)
@@ -4609,6 +4609,12 @@ struct compat_kvm_clear_dirty_log {
        };
 };
 
+long __weak kvm_arch_vm_compat_ioctl(struct file *filp, unsigned int ioctl,
+                                    unsigned long arg)
+{
+       return -ENOTTY;
+}
+
 static long kvm_vm_compat_ioctl(struct file *filp,
                           unsigned int ioctl, unsigned long arg)
 {
@@ -4617,6 +4623,11 @@ static long kvm_vm_compat_ioctl(struct file *filp,
 
        if (kvm->mm != current->mm || kvm->vm_bugged)
                return -EIO;
+
+       r = kvm_arch_vm_compat_ioctl(filp, ioctl, arg);
+       if (r != -ENOTTY)
+               return r;
+
        switch (ioctl) {
 #ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
        case KVM_CLEAR_DIRTY_LOG: {