Skip to content

Commit ed51862

Browse files
agrafbonzini
authored andcommitted
kvm: Add support for arch compat vm ioctls
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 <[email protected]> Message-Id: <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 21e6075 commit ed51862

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/linux/kvm_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,8 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
13901390
struct kvm_enable_cap *cap);
13911391
long kvm_arch_vm_ioctl(struct file *filp,
13921392
unsigned int ioctl, unsigned long arg);
1393+
long kvm_arch_vm_compat_ioctl(struct file *filp, unsigned int ioctl,
1394+
unsigned long arg);
13931395

13941396
int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
13951397
int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);

virt/kvm/kvm_main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4839,6 +4839,12 @@ struct compat_kvm_clear_dirty_log {
48394839
};
48404840
};
48414841

4842+
long __weak kvm_arch_vm_compat_ioctl(struct file *filp, unsigned int ioctl,
4843+
unsigned long arg)
4844+
{
4845+
return -ENOTTY;
4846+
}
4847+
48424848
static long kvm_vm_compat_ioctl(struct file *filp,
48434849
unsigned int ioctl, unsigned long arg)
48444850
{
@@ -4847,6 +4853,11 @@ static long kvm_vm_compat_ioctl(struct file *filp,
48474853

48484854
if (kvm->mm != current->mm || kvm->vm_dead)
48494855
return -EIO;
4856+
4857+
r = kvm_arch_vm_compat_ioctl(filp, ioctl, arg);
4858+
if (r != -ENOTTY)
4859+
return r;
4860+
48504861
switch (ioctl) {
48514862
#ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
48524863
case KVM_CLEAR_DIRTY_LOG: {

0 commit comments

Comments
 (0)