diff options
| author | Alex Williamson <alex.williamson@redhat.com> | 2013-04-16 15:49:18 -0400 |
|---|---|---|
| committer | Gleb Natapov <gleb@redhat.com> | 2013-04-28 05:58:56 -0400 |
| commit | 2a5bab1004729f3302c776e53ee7c895b98bb1ce (patch) | |
| tree | 281519b89e9f766a3d83c6978850e9eb72b3e0df /include | |
| parent | 064d1afaa5a60fc391d0b4b77599fc8f63f99cd3 (diff) | |
kvm: Allow build-time configuration of KVM device assignment
We hope to at some point deprecate KVM legacy device assignment in
favor of VFIO-based assignment. Towards that end, allow legacy
device assignment to be deconfigured.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/kvm_host.h | 30 | ||||
| -rw-r--r-- | include/uapi/linux/kvm.h | 4 |
2 files changed, 8 insertions, 26 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 309774715897..996661eb8e99 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
| @@ -667,7 +667,6 @@ static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu) | |||
| 667 | 667 | ||
| 668 | int kvm_arch_init_vm(struct kvm *kvm, unsigned long type); | 668 | int kvm_arch_init_vm(struct kvm *kvm, unsigned long type); |
| 669 | void kvm_arch_destroy_vm(struct kvm *kvm); | 669 | void kvm_arch_destroy_vm(struct kvm *kvm); |
| 670 | void kvm_free_all_assigned_devices(struct kvm *kvm); | ||
| 671 | void kvm_arch_sync_events(struct kvm *kvm); | 670 | void kvm_arch_sync_events(struct kvm *kvm); |
| 672 | 671 | ||
| 673 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); | 672 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); |
| @@ -736,7 +735,7 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); | |||
| 736 | /* For vcpu->arch.iommu_flags */ | 735 | /* For vcpu->arch.iommu_flags */ |
| 737 | #define KVM_IOMMU_CACHE_COHERENCY 0x1 | 736 | #define KVM_IOMMU_CACHE_COHERENCY 0x1 |
| 738 | 737 | ||
| 739 | #ifdef CONFIG_IOMMU_API | 738 | #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT |
| 740 | int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); | 739 | int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); |
| 741 | void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot); | 740 | void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot); |
| 742 | int kvm_iommu_map_guest(struct kvm *kvm); | 741 | int kvm_iommu_map_guest(struct kvm *kvm); |
| @@ -745,7 +744,7 @@ int kvm_assign_device(struct kvm *kvm, | |||
| 745 | struct kvm_assigned_dev_kernel *assigned_dev); | 744 | struct kvm_assigned_dev_kernel *assigned_dev); |
| 746 | int kvm_deassign_device(struct kvm *kvm, | 745 | int kvm_deassign_device(struct kvm *kvm, |
| 747 | struct kvm_assigned_dev_kernel *assigned_dev); | 746 | struct kvm_assigned_dev_kernel *assigned_dev); |
| 748 | #else /* CONFIG_IOMMU_API */ | 747 | #else |
| 749 | static inline int kvm_iommu_map_pages(struct kvm *kvm, | 748 | static inline int kvm_iommu_map_pages(struct kvm *kvm, |
| 750 | struct kvm_memory_slot *slot) | 749 | struct kvm_memory_slot *slot) |
| 751 | { | 750 | { |
| @@ -757,28 +756,11 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm, | |||
| 757 | { | 756 | { |
| 758 | } | 757 | } |
| 759 | 758 | ||
| 760 | static inline int kvm_iommu_map_guest(struct kvm *kvm) | ||
| 761 | { | ||
| 762 | return -ENODEV; | ||
| 763 | } | ||
| 764 | |||
| 765 | static inline int kvm_iommu_unmap_guest(struct kvm *kvm) | 759 | static inline int kvm_iommu_unmap_guest(struct kvm *kvm) |
| 766 | { | 760 | { |
| 767 | return 0; | 761 | return 0; |
| 768 | } | 762 | } |
| 769 | 763 | #endif | |
| 770 | static inline int kvm_assign_device(struct kvm *kvm, | ||
| 771 | struct kvm_assigned_dev_kernel *assigned_dev) | ||
| 772 | { | ||
| 773 | return 0; | ||
| 774 | } | ||
| 775 | |||
| 776 | static inline int kvm_deassign_device(struct kvm *kvm, | ||
| 777 | struct kvm_assigned_dev_kernel *assigned_dev) | ||
| 778 | { | ||
| 779 | return 0; | ||
| 780 | } | ||
| 781 | #endif /* CONFIG_IOMMU_API */ | ||
| 782 | 764 | ||
| 783 | static inline void __guest_enter(void) | 765 | static inline void __guest_enter(void) |
| 784 | { | 766 | { |
| @@ -1032,11 +1014,13 @@ static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; } | |||
| 1032 | 1014 | ||
| 1033 | #endif | 1015 | #endif |
| 1034 | 1016 | ||
| 1035 | #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT | 1017 | #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT |
| 1036 | 1018 | ||
| 1037 | long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, | 1019 | long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, |
| 1038 | unsigned long arg); | 1020 | unsigned long arg); |
| 1039 | 1021 | ||
| 1022 | void kvm_free_all_assigned_devices(struct kvm *kvm); | ||
| 1023 | |||
| 1040 | #else | 1024 | #else |
| 1041 | 1025 | ||
| 1042 | static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, | 1026 | static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, |
| @@ -1045,6 +1029,8 @@ static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, | |||
| 1045 | return -ENOTTY; | 1029 | return -ENOTTY; |
| 1046 | } | 1030 | } |
| 1047 | 1031 | ||
| 1032 | static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} | ||
| 1033 | |||
| 1048 | #endif | 1034 | #endif |
| 1049 | 1035 | ||
| 1050 | static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu) | 1036 | static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu) |
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index d4005192ad6e..965e5b52dee0 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h | |||
| @@ -561,9 +561,7 @@ struct kvm_ppc_smmu_info { | |||
| 561 | #define KVM_CAP_MP_STATE 14 | 561 | #define KVM_CAP_MP_STATE 14 |
| 562 | #define KVM_CAP_COALESCED_MMIO 15 | 562 | #define KVM_CAP_COALESCED_MMIO 15 |
| 563 | #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ | 563 | #define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */ |
| 564 | #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT | ||
| 565 | #define KVM_CAP_DEVICE_ASSIGNMENT 17 | 564 | #define KVM_CAP_DEVICE_ASSIGNMENT 17 |
| 566 | #endif | ||
| 567 | #define KVM_CAP_IOMMU 18 | 565 | #define KVM_CAP_IOMMU 18 |
| 568 | #ifdef __KVM_HAVE_MSI | 566 | #ifdef __KVM_HAVE_MSI |
| 569 | #define KVM_CAP_DEVICE_MSI 20 | 567 | #define KVM_CAP_DEVICE_MSI 20 |
| @@ -581,9 +579,7 @@ struct kvm_ppc_smmu_info { | |||
| 581 | #endif | 579 | #endif |
| 582 | #define KVM_CAP_IRQ_ROUTING 25 | 580 | #define KVM_CAP_IRQ_ROUTING 25 |
| 583 | #define KVM_CAP_IRQ_INJECT_STATUS 26 | 581 | #define KVM_CAP_IRQ_INJECT_STATUS 26 |
| 584 | #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT | ||
| 585 | #define KVM_CAP_DEVICE_DEASSIGNMENT 27 | 582 | #define KVM_CAP_DEVICE_DEASSIGNMENT 27 |
| 586 | #endif | ||
| 587 | #ifdef __KVM_HAVE_MSIX | 583 | #ifdef __KVM_HAVE_MSIX |
| 588 | #define KVM_CAP_DEVICE_MSIX 28 | 584 | #define KVM_CAP_DEVICE_MSIX 28 |
| 589 | #endif | 585 | #endif |
