2 * Kernel-based Virtual Machine - device assignment support
4 * Copyright (C) 2010 Red Hat, Inc. and/or its affiliates.
6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory.
11 #include <linux/kvm_host.h>
12 #include <linux/kvm.h>
13 #include <linux/uaccess.h>
14 #include <linux/vmalloc.h>
15 #include <linux/errno.h>
16 #include <linux/spinlock.h>
17 #include <linux/pci.h>
18 #include <linux/interrupt.h>
19 #include <linux/slab.h>
20 #include <linux/namei.h>
24 static struct kvm_assigned_dev_kernel
*kvm_find_assigned_dev(struct list_head
*head
,
27 struct list_head
*ptr
;
28 struct kvm_assigned_dev_kernel
*match
;
30 list_for_each(ptr
, head
) {
31 match
= list_entry(ptr
, struct kvm_assigned_dev_kernel
, list
);
32 if (match
->assigned_dev_id
== assigned_dev_id
)
38 static int find_index_from_host_irq(struct kvm_assigned_dev_kernel
39 *assigned_dev
, int irq
)
42 struct msix_entry
*host_msix_entries
;
44 host_msix_entries
= assigned_dev
->host_msix_entries
;
47 for (i
= 0; i
< assigned_dev
->entries_nr
; i
++)
48 if (irq
== host_msix_entries
[i
].vector
) {
53 printk(KERN_WARNING
"Fail to find correlated MSI-X entry!\n");
60 static irqreturn_t
kvm_assigned_dev_thread(int irq
, void *dev_id
)
62 struct kvm_assigned_dev_kernel
*assigned_dev
= dev_id
;
64 if (assigned_dev
->irq_requested_type
& KVM_DEV_IRQ_HOST_INTX
) {
65 spin_lock(&assigned_dev
->intx_lock
);
66 disable_irq_nosync(irq
);
67 assigned_dev
->host_irq_disabled
= true;
68 spin_unlock(&assigned_dev
->intx_lock
);
71 kvm_set_irq(assigned_dev
->kvm
, assigned_dev
->irq_source_id
,
72 assigned_dev
->guest_irq
, 1);
77 #ifdef __KVM_HAVE_MSIX
78 static irqreturn_t
kvm_assigned_dev_thread_msix(int irq
, void *dev_id
)
80 struct kvm_assigned_dev_kernel
*assigned_dev
= dev_id
;
81 int index
= find_index_from_host_irq(assigned_dev
, irq
);
85 vector
= assigned_dev
->guest_msix_entries
[index
].vector
;
86 kvm_set_irq(assigned_dev
->kvm
, assigned_dev
->irq_source_id
,
94 /* Ack the irq line for an assigned device */
95 static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier
*kian
)
97 struct kvm_assigned_dev_kernel
*dev
=
98 container_of(kian
, struct kvm_assigned_dev_kernel
,
101 kvm_set_irq(dev
->kvm
, dev
->irq_source_id
, dev
->guest_irq
, 0);
103 /* The guest irq may be shared so this ack may be
104 * from another device.
106 spin_lock(&dev
->intx_lock
);
107 if (dev
->host_irq_disabled
) {
108 enable_irq(dev
->host_irq
);
109 dev
->host_irq_disabled
= false;
111 spin_unlock(&dev
->intx_lock
);
114 static void deassign_guest_irq(struct kvm
*kvm
,
115 struct kvm_assigned_dev_kernel
*assigned_dev
)
117 if (assigned_dev
->ack_notifier
.gsi
!= -1)
118 kvm_unregister_irq_ack_notifier(kvm
,
119 &assigned_dev
->ack_notifier
);
121 kvm_set_irq(assigned_dev
->kvm
, assigned_dev
->irq_source_id
,
122 assigned_dev
->guest_irq
, 0);
124 if (assigned_dev
->irq_source_id
!= -1)
125 kvm_free_irq_source_id(kvm
, assigned_dev
->irq_source_id
);
126 assigned_dev
->irq_source_id
= -1;
127 assigned_dev
->irq_requested_type
&= ~(KVM_DEV_IRQ_GUEST_MASK
);
130 /* The function implicit hold kvm->lock mutex due to cancel_work_sync() */
131 static void deassign_host_irq(struct kvm
*kvm
,
132 struct kvm_assigned_dev_kernel
*assigned_dev
)
135 * We disable irq here to prevent further events.
137 * Notice this maybe result in nested disable if the interrupt type is
138 * INTx, but it's OK for we are going to free it.
140 * If this function is a part of VM destroy, please ensure that till
141 * now, the kvm state is still legal for probably we also have to wait
142 * on a currently running IRQ handler.
144 if (assigned_dev
->irq_requested_type
& KVM_DEV_IRQ_HOST_MSIX
) {
146 for (i
= 0; i
< assigned_dev
->entries_nr
; i
++)
147 disable_irq(assigned_dev
->host_msix_entries
[i
].vector
);
149 for (i
= 0; i
< assigned_dev
->entries_nr
; i
++)
150 free_irq(assigned_dev
->host_msix_entries
[i
].vector
,
153 assigned_dev
->entries_nr
= 0;
154 kfree(assigned_dev
->host_msix_entries
);
155 kfree(assigned_dev
->guest_msix_entries
);
156 pci_disable_msix(assigned_dev
->dev
);
158 /* Deal with MSI and INTx */
159 disable_irq(assigned_dev
->host_irq
);
161 free_irq(assigned_dev
->host_irq
, assigned_dev
);
163 if (assigned_dev
->irq_requested_type
& KVM_DEV_IRQ_HOST_MSI
)
164 pci_disable_msi(assigned_dev
->dev
);
167 assigned_dev
->irq_requested_type
&= ~(KVM_DEV_IRQ_HOST_MASK
);
170 static int kvm_deassign_irq(struct kvm
*kvm
,
171 struct kvm_assigned_dev_kernel
*assigned_dev
,
172 unsigned long irq_requested_type
)
174 unsigned long guest_irq_type
, host_irq_type
;
176 if (!irqchip_in_kernel(kvm
))
178 /* no irq assignment to deassign */
179 if (!assigned_dev
->irq_requested_type
)
182 host_irq_type
= irq_requested_type
& KVM_DEV_IRQ_HOST_MASK
;
183 guest_irq_type
= irq_requested_type
& KVM_DEV_IRQ_GUEST_MASK
;
186 deassign_host_irq(kvm
, assigned_dev
);
188 deassign_guest_irq(kvm
, assigned_dev
);
193 static void kvm_free_assigned_irq(struct kvm
*kvm
,
194 struct kvm_assigned_dev_kernel
*assigned_dev
)
196 kvm_deassign_irq(kvm
, assigned_dev
, assigned_dev
->irq_requested_type
);
199 static void kvm_free_assigned_device(struct kvm
*kvm
,
200 struct kvm_assigned_dev_kernel
203 kvm_free_assigned_irq(kvm
, assigned_dev
);
205 pci_reset_function(assigned_dev
->dev
);
206 if (pci_load_and_free_saved_state(assigned_dev
->dev
,
207 &assigned_dev
->pci_saved_state
))
208 printk(KERN_INFO
"%s: Couldn't reload %s saved state\n",
209 __func__
, dev_name(&assigned_dev
->dev
->dev
));
211 pci_restore_state(assigned_dev
->dev
);
213 assigned_dev
->dev
->dev_flags
&= ~PCI_DEV_FLAGS_ASSIGNED
;
215 pci_release_regions(assigned_dev
->dev
);
216 pci_disable_device(assigned_dev
->dev
);
217 pci_dev_put(assigned_dev
->dev
);
219 list_del(&assigned_dev
->list
);
223 void kvm_free_all_assigned_devices(struct kvm
*kvm
)
225 struct list_head
*ptr
, *ptr2
;
226 struct kvm_assigned_dev_kernel
*assigned_dev
;
228 list_for_each_safe(ptr
, ptr2
, &kvm
->arch
.assigned_dev_head
) {
229 assigned_dev
= list_entry(ptr
,
230 struct kvm_assigned_dev_kernel
,
233 kvm_free_assigned_device(kvm
, assigned_dev
);
237 static int assigned_device_enable_host_intx(struct kvm
*kvm
,
238 struct kvm_assigned_dev_kernel
*dev
)
240 dev
->host_irq
= dev
->dev
->irq
;
241 /* Even though this is PCI, we don't want to use shared
242 * interrupts. Sharing host devices with guest-assigned devices
243 * on the same interrupt line is not a happy situation: there
244 * are going to be long delays in accepting, acking, etc.
246 if (request_threaded_irq(dev
->host_irq
, NULL
, kvm_assigned_dev_thread
,
247 IRQF_ONESHOT
, dev
->irq_name
, dev
))
252 #ifdef __KVM_HAVE_MSI
253 static int assigned_device_enable_host_msi(struct kvm
*kvm
,
254 struct kvm_assigned_dev_kernel
*dev
)
258 if (!dev
->dev
->msi_enabled
) {
259 r
= pci_enable_msi(dev
->dev
);
264 dev
->host_irq
= dev
->dev
->irq
;
265 if (request_threaded_irq(dev
->host_irq
, NULL
, kvm_assigned_dev_thread
,
266 0, dev
->irq_name
, dev
)) {
267 pci_disable_msi(dev
->dev
);
275 #ifdef __KVM_HAVE_MSIX
276 static int assigned_device_enable_host_msix(struct kvm
*kvm
,
277 struct kvm_assigned_dev_kernel
*dev
)
281 /* host_msix_entries and guest_msix_entries should have been
283 if (dev
->entries_nr
== 0)
286 r
= pci_enable_msix(dev
->dev
, dev
->host_msix_entries
, dev
->entries_nr
);
290 for (i
= 0; i
< dev
->entries_nr
; i
++) {
291 r
= request_threaded_irq(dev
->host_msix_entries
[i
].vector
,
292 NULL
, kvm_assigned_dev_thread_msix
,
293 0, dev
->irq_name
, dev
);
300 for (i
-= 1; i
>= 0; i
--)
301 free_irq(dev
->host_msix_entries
[i
].vector
, dev
);
302 pci_disable_msix(dev
->dev
);
308 static int assigned_device_enable_guest_intx(struct kvm
*kvm
,
309 struct kvm_assigned_dev_kernel
*dev
,
310 struct kvm_assigned_irq
*irq
)
312 dev
->guest_irq
= irq
->guest_irq
;
313 dev
->ack_notifier
.gsi
= irq
->guest_irq
;
317 #ifdef __KVM_HAVE_MSI
318 static int assigned_device_enable_guest_msi(struct kvm
*kvm
,
319 struct kvm_assigned_dev_kernel
*dev
,
320 struct kvm_assigned_irq
*irq
)
322 dev
->guest_irq
= irq
->guest_irq
;
323 dev
->ack_notifier
.gsi
= -1;
324 dev
->host_irq_disabled
= false;
329 #ifdef __KVM_HAVE_MSIX
330 static int assigned_device_enable_guest_msix(struct kvm
*kvm
,
331 struct kvm_assigned_dev_kernel
*dev
,
332 struct kvm_assigned_irq
*irq
)
334 dev
->guest_irq
= irq
->guest_irq
;
335 dev
->ack_notifier
.gsi
= -1;
336 dev
->host_irq_disabled
= false;
341 static int assign_host_irq(struct kvm
*kvm
,
342 struct kvm_assigned_dev_kernel
*dev
,
347 if (dev
->irq_requested_type
& KVM_DEV_IRQ_HOST_MASK
)
350 snprintf(dev
->irq_name
, sizeof(dev
->irq_name
), "kvm:%s",
353 switch (host_irq_type
) {
354 case KVM_DEV_IRQ_HOST_INTX
:
355 r
= assigned_device_enable_host_intx(kvm
, dev
);
357 #ifdef __KVM_HAVE_MSI
358 case KVM_DEV_IRQ_HOST_MSI
:
359 r
= assigned_device_enable_host_msi(kvm
, dev
);
362 #ifdef __KVM_HAVE_MSIX
363 case KVM_DEV_IRQ_HOST_MSIX
:
364 r
= assigned_device_enable_host_msix(kvm
, dev
);
372 dev
->irq_requested_type
|= host_irq_type
;
377 static int assign_guest_irq(struct kvm
*kvm
,
378 struct kvm_assigned_dev_kernel
*dev
,
379 struct kvm_assigned_irq
*irq
,
380 unsigned long guest_irq_type
)
385 if (dev
->irq_requested_type
& KVM_DEV_IRQ_GUEST_MASK
)
388 id
= kvm_request_irq_source_id(kvm
);
392 dev
->irq_source_id
= id
;
394 switch (guest_irq_type
) {
395 case KVM_DEV_IRQ_GUEST_INTX
:
396 r
= assigned_device_enable_guest_intx(kvm
, dev
, irq
);
398 #ifdef __KVM_HAVE_MSI
399 case KVM_DEV_IRQ_GUEST_MSI
:
400 r
= assigned_device_enable_guest_msi(kvm
, dev
, irq
);
403 #ifdef __KVM_HAVE_MSIX
404 case KVM_DEV_IRQ_GUEST_MSIX
:
405 r
= assigned_device_enable_guest_msix(kvm
, dev
, irq
);
413 dev
->irq_requested_type
|= guest_irq_type
;
414 if (dev
->ack_notifier
.gsi
!= -1)
415 kvm_register_irq_ack_notifier(kvm
, &dev
->ack_notifier
);
417 kvm_free_irq_source_id(kvm
, dev
->irq_source_id
);
422 /* TODO Deal with KVM_DEV_IRQ_ASSIGNED_MASK_MSIX */
423 static int kvm_vm_ioctl_assign_irq(struct kvm
*kvm
,
424 struct kvm_assigned_irq
*assigned_irq
)
427 struct kvm_assigned_dev_kernel
*match
;
428 unsigned long host_irq_type
, guest_irq_type
;
430 if (!irqchip_in_kernel(kvm
))
433 mutex_lock(&kvm
->lock
);
435 match
= kvm_find_assigned_dev(&kvm
->arch
.assigned_dev_head
,
436 assigned_irq
->assigned_dev_id
);
440 host_irq_type
= (assigned_irq
->flags
& KVM_DEV_IRQ_HOST_MASK
);
441 guest_irq_type
= (assigned_irq
->flags
& KVM_DEV_IRQ_GUEST_MASK
);
444 /* can only assign one type at a time */
445 if (hweight_long(host_irq_type
) > 1)
447 if (hweight_long(guest_irq_type
) > 1)
449 if (host_irq_type
== 0 && guest_irq_type
== 0)
454 r
= assign_host_irq(kvm
, match
, host_irq_type
);
459 r
= assign_guest_irq(kvm
, match
, assigned_irq
, guest_irq_type
);
461 mutex_unlock(&kvm
->lock
);
465 static int kvm_vm_ioctl_deassign_dev_irq(struct kvm
*kvm
,
466 struct kvm_assigned_irq
470 struct kvm_assigned_dev_kernel
*match
;
472 mutex_lock(&kvm
->lock
);
474 match
= kvm_find_assigned_dev(&kvm
->arch
.assigned_dev_head
,
475 assigned_irq
->assigned_dev_id
);
479 r
= kvm_deassign_irq(kvm
, match
, assigned_irq
->flags
);
481 mutex_unlock(&kvm
->lock
);
486 * We want to test whether the caller has been granted permissions to
487 * use this device. To be able to configure and control the device,
488 * the user needs access to PCI configuration space and BAR resources.
489 * These are accessed through PCI sysfs. PCI config space is often
490 * passed to the process calling this ioctl via file descriptor, so we
491 * can't rely on access to that file. We can check for permissions
492 * on each of the BAR resource files, which is a pretty clear
493 * indicator that the user has been granted access to the device.
495 static int probe_sysfs_permissions(struct pci_dev
*dev
)
499 bool bar_found
= false;
501 for (i
= PCI_STD_RESOURCES
; i
<= PCI_STD_RESOURCE_END
; i
++) {
502 char *kpath
, *syspath
;
507 if (!pci_resource_len(dev
, i
))
510 kpath
= kobject_get_path(&dev
->dev
.kobj
, GFP_KERNEL
);
514 /* Per sysfs-rules, sysfs is always at /sys */
515 syspath
= kasprintf(GFP_KERNEL
, "/sys%s/resource%d", kpath
, i
);
520 r
= kern_path(syspath
, LOOKUP_FOLLOW
, &path
);
525 inode
= path
.dentry
->d_inode
;
527 r
= inode_permission(inode
, MAY_READ
| MAY_WRITE
| MAY_ACCESS
);
535 /* If no resources, probably something special */
541 return -EINVAL
; /* No way to control the device without sysfs */
545 static int kvm_vm_ioctl_assign_device(struct kvm
*kvm
,
546 struct kvm_assigned_pci_dev
*assigned_dev
)
549 struct kvm_assigned_dev_kernel
*match
;
553 if (!(assigned_dev
->flags
& KVM_DEV_ASSIGN_ENABLE_IOMMU
))
556 mutex_lock(&kvm
->lock
);
557 idx
= srcu_read_lock(&kvm
->srcu
);
559 match
= kvm_find_assigned_dev(&kvm
->arch
.assigned_dev_head
,
560 assigned_dev
->assigned_dev_id
);
562 /* device already assigned */
567 match
= kzalloc(sizeof(struct kvm_assigned_dev_kernel
), GFP_KERNEL
);
569 printk(KERN_INFO
"%s: Couldn't allocate memory\n",
574 dev
= pci_get_domain_bus_and_slot(assigned_dev
->segnr
,
576 assigned_dev
->devfn
);
578 printk(KERN_INFO
"%s: host device not found\n", __func__
);
583 /* Don't allow bridges to be assigned */
584 pci_read_config_byte(dev
, PCI_HEADER_TYPE
, &header_type
);
585 if ((header_type
& PCI_HEADER_TYPE
) != PCI_HEADER_TYPE_NORMAL
) {
590 r
= probe_sysfs_permissions(dev
);
594 if (pci_enable_device(dev
)) {
595 printk(KERN_INFO
"%s: Could not enable PCI device\n", __func__
);
599 r
= pci_request_regions(dev
, "kvm_assigned_device");
601 printk(KERN_INFO
"%s: Could not get access to device regions\n",
606 pci_reset_function(dev
);
608 match
->pci_saved_state
= pci_store_saved_state(dev
);
609 if (!match
->pci_saved_state
)
610 printk(KERN_DEBUG
"%s: Couldn't store %s saved state\n",
611 __func__
, dev_name(&dev
->dev
));
612 match
->assigned_dev_id
= assigned_dev
->assigned_dev_id
;
613 match
->host_segnr
= assigned_dev
->segnr
;
614 match
->host_busnr
= assigned_dev
->busnr
;
615 match
->host_devfn
= assigned_dev
->devfn
;
616 match
->flags
= assigned_dev
->flags
;
618 spin_lock_init(&match
->intx_lock
);
619 match
->irq_source_id
= -1;
621 match
->ack_notifier
.irq_acked
= kvm_assigned_dev_ack_irq
;
623 list_add(&match
->list
, &kvm
->arch
.assigned_dev_head
);
625 if (!kvm
->arch
.iommu_domain
) {
626 r
= kvm_iommu_map_guest(kvm
);
630 r
= kvm_assign_device(kvm
, match
);
635 srcu_read_unlock(&kvm
->srcu
, idx
);
636 mutex_unlock(&kvm
->lock
);
639 if (pci_load_and_free_saved_state(dev
, &match
->pci_saved_state
))
640 printk(KERN_INFO
"%s: Couldn't reload %s saved state\n",
641 __func__
, dev_name(&dev
->dev
));
642 list_del(&match
->list
);
643 pci_release_regions(dev
);
645 pci_disable_device(dev
);
650 srcu_read_unlock(&kvm
->srcu
, idx
);
651 mutex_unlock(&kvm
->lock
);
655 static int kvm_vm_ioctl_deassign_device(struct kvm
*kvm
,
656 struct kvm_assigned_pci_dev
*assigned_dev
)
659 struct kvm_assigned_dev_kernel
*match
;
661 mutex_lock(&kvm
->lock
);
663 match
= kvm_find_assigned_dev(&kvm
->arch
.assigned_dev_head
,
664 assigned_dev
->assigned_dev_id
);
666 printk(KERN_INFO
"%s: device hasn't been assigned before, "
667 "so cannot be deassigned\n", __func__
);
672 kvm_deassign_device(kvm
, match
);
674 kvm_free_assigned_device(kvm
, match
);
677 mutex_unlock(&kvm
->lock
);
682 #ifdef __KVM_HAVE_MSIX
683 static int kvm_vm_ioctl_set_msix_nr(struct kvm
*kvm
,
684 struct kvm_assigned_msix_nr
*entry_nr
)
687 struct kvm_assigned_dev_kernel
*adev
;
689 mutex_lock(&kvm
->lock
);
691 adev
= kvm_find_assigned_dev(&kvm
->arch
.assigned_dev_head
,
692 entry_nr
->assigned_dev_id
);
698 if (adev
->entries_nr
== 0) {
699 adev
->entries_nr
= entry_nr
->entry_nr
;
700 if (adev
->entries_nr
== 0 ||
701 adev
->entries_nr
> KVM_MAX_MSIX_PER_DEV
) {
706 adev
->host_msix_entries
= kzalloc(sizeof(struct msix_entry
) *
709 if (!adev
->host_msix_entries
) {
713 adev
->guest_msix_entries
=
714 kzalloc(sizeof(struct msix_entry
) * entry_nr
->entry_nr
,
716 if (!adev
->guest_msix_entries
) {
717 kfree(adev
->host_msix_entries
);
721 } else /* Not allowed set MSI-X number twice */
724 mutex_unlock(&kvm
->lock
);
728 static int kvm_vm_ioctl_set_msix_entry(struct kvm
*kvm
,
729 struct kvm_assigned_msix_entry
*entry
)
732 struct kvm_assigned_dev_kernel
*adev
;
734 mutex_lock(&kvm
->lock
);
736 adev
= kvm_find_assigned_dev(&kvm
->arch
.assigned_dev_head
,
737 entry
->assigned_dev_id
);
744 for (i
= 0; i
< adev
->entries_nr
; i
++)
745 if (adev
->guest_msix_entries
[i
].vector
== 0 ||
746 adev
->guest_msix_entries
[i
].entry
== entry
->entry
) {
747 adev
->guest_msix_entries
[i
].entry
= entry
->entry
;
748 adev
->guest_msix_entries
[i
].vector
= entry
->gsi
;
749 adev
->host_msix_entries
[i
].entry
= entry
->entry
;
752 if (i
== adev
->entries_nr
) {
758 mutex_unlock(&kvm
->lock
);
764 long kvm_vm_ioctl_assigned_device(struct kvm
*kvm
, unsigned ioctl
,
767 void __user
*argp
= (void __user
*)arg
;
771 case KVM_ASSIGN_PCI_DEVICE
: {
772 struct kvm_assigned_pci_dev assigned_dev
;
775 if (copy_from_user(&assigned_dev
, argp
, sizeof assigned_dev
))
777 r
= kvm_vm_ioctl_assign_device(kvm
, &assigned_dev
);
782 case KVM_ASSIGN_IRQ
: {
786 case KVM_ASSIGN_DEV_IRQ
: {
787 struct kvm_assigned_irq assigned_irq
;
790 if (copy_from_user(&assigned_irq
, argp
, sizeof assigned_irq
))
792 r
= kvm_vm_ioctl_assign_irq(kvm
, &assigned_irq
);
797 case KVM_DEASSIGN_DEV_IRQ
: {
798 struct kvm_assigned_irq assigned_irq
;
801 if (copy_from_user(&assigned_irq
, argp
, sizeof assigned_irq
))
803 r
= kvm_vm_ioctl_deassign_dev_irq(kvm
, &assigned_irq
);
808 case KVM_DEASSIGN_PCI_DEVICE
: {
809 struct kvm_assigned_pci_dev assigned_dev
;
812 if (copy_from_user(&assigned_dev
, argp
, sizeof assigned_dev
))
814 r
= kvm_vm_ioctl_deassign_device(kvm
, &assigned_dev
);
819 #ifdef KVM_CAP_IRQ_ROUTING
820 case KVM_SET_GSI_ROUTING
: {
821 struct kvm_irq_routing routing
;
822 struct kvm_irq_routing __user
*urouting
;
823 struct kvm_irq_routing_entry
*entries
;
826 if (copy_from_user(&routing
, argp
, sizeof(routing
)))
829 if (routing
.nr
>= KVM_MAX_IRQ_ROUTES
)
834 entries
= vmalloc(routing
.nr
* sizeof(*entries
));
839 if (copy_from_user(entries
, urouting
->entries
,
840 routing
.nr
* sizeof(*entries
)))
841 goto out_free_irq_routing
;
842 r
= kvm_set_irq_routing(kvm
, entries
, routing
.nr
,
844 out_free_irq_routing
:
848 #endif /* KVM_CAP_IRQ_ROUTING */
849 #ifdef __KVM_HAVE_MSIX
850 case KVM_ASSIGN_SET_MSIX_NR
: {
851 struct kvm_assigned_msix_nr entry_nr
;
853 if (copy_from_user(&entry_nr
, argp
, sizeof entry_nr
))
855 r
= kvm_vm_ioctl_set_msix_nr(kvm
, &entry_nr
);
860 case KVM_ASSIGN_SET_MSIX_ENTRY
: {
861 struct kvm_assigned_msix_entry entry
;
863 if (copy_from_user(&entry
, argp
, sizeof entry
))
865 r
= kvm_vm_ioctl_set_msix_entry(kvm
, &entry
);