aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2019-04-18 06:39:36 -0400
committerPaul Mackerras <paulus@ozlabs.org>2019-04-30 05:35:16 -0400
commita1cd3f0883f435e5f9ae6530d7e62b361c87a91a (patch)
tree1774043ecb1aee3e5b6029f4061130c9500d20c1 /virt/kvm
parente4945b9da52b36052b7c509ca31c5ead1d165b24 (diff)
KVM: Introduce a 'mmap' method for KVM devices
Some KVM devices will want to handle special mappings related to the underlying HW. For instance, the XIVE interrupt controller of the POWER9 processor has MMIO pages for thread interrupt management and for interrupt source control that need to be exposed to the guest when the OS has the required support. Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/kvm_main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 55fe8e20d8fd..ea2018ae1cd7 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2884,6 +2884,16 @@ out:
2884} 2884}
2885#endif 2885#endif
2886 2886
2887static int kvm_device_mmap(struct file *filp, struct vm_area_struct *vma)
2888{
2889 struct kvm_device *dev = filp->private_data;
2890
2891 if (dev->ops->mmap)
2892 return dev->ops->mmap(dev, vma);
2893
2894 return -ENODEV;
2895}
2896
2887static int kvm_device_ioctl_attr(struct kvm_device *dev, 2897static int kvm_device_ioctl_attr(struct kvm_device *dev,
2888 int (*accessor)(struct kvm_device *dev, 2898 int (*accessor)(struct kvm_device *dev,
2889 struct kvm_device_attr *attr), 2899 struct kvm_device_attr *attr),
@@ -2936,6 +2946,7 @@ static const struct file_operations kvm_device_fops = {
2936 .unlocked_ioctl = kvm_device_ioctl, 2946 .unlocked_ioctl = kvm_device_ioctl,
2937 .release = kvm_device_release, 2947 .release = kvm_device_release,
2938 KVM_COMPAT(kvm_device_ioctl), 2948 KVM_COMPAT(kvm_device_ioctl),
2949 .mmap = kvm_device_mmap,
2939}; 2950};
2940 2951
2941struct kvm_device *kvm_device_from_filp(struct file *filp) 2952struct kvm_device *kvm_device_from_filp(struct file *filp)