Re: [PATCH] kvm: x86: move assigned-dev.c and iommu.c to arch/x86/
2014-11-22 17:22+0100, Paolo Bonzini: > On 21/11/2014 22:21, Radim Krčmář wrote: > > - struct kvm_assigned_dev_kernel depends on struct kvm_irq_ack_notifier > > kvm_assign_device and kvm_deassign_device can also be moved to arch/x86, > in a new assigned-dev.h header. The header could include struct > kvm_assigned_dev_kernel too but, if you change the argument of > kvm_assign_device and kvm_deassign_device to struct pci_dev, the struct > can move directly to assigned-dev.c and remain hidden there. Thanks! > It's fine to do this as a follow up. With assigned-dev.h, we could remove everything from x86/kvm_host.h too, which would be better as a replacement to the original ---8<--- kvm: x86: move assigned-dev.c and iommu.c to arch/x86/ Now that ia64 is gone, we can hide deprecated device assignment in x86. kvm_vm_ioctl_assigned_device() is newly called from kvm_arch_vm_ioctl(). Definitions and declarations have been consolidated into assigned-dev.h. Remaining kvm_iommu_(un)map_pages() would require new code to be moved. Signed-off-by: Radim Krčmář --- arch/x86/kvm/Makefile | 2 +- {virt => arch/x86}/kvm/assigned-dev.c | 1 + arch/x86/kvm/assigned-dev.h | 59 +++ {virt => arch/x86}/kvm/iommu.c| 1 + arch/x86/kvm/x86.c| 3 +- include/linux/kvm_host.h | 55 virt/kvm/kvm_main.c | 2 -- 7 files changed, 64 insertions(+), 59 deletions(-) rename {virt => arch/x86}/kvm/assigned-dev.c (99%) create mode 100644 arch/x86/kvm/assigned-dev.h rename {virt => arch/x86}/kvm/iommu.c (99%) diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index ee1cd92..08f790d 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -9,11 +9,11 @@ KVM := ../../../virt/kvm kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o -kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= $(KVM)/assigned-dev.o $(KVM)/iommu.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o +kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= assigned-dev.o iommu.o kvm-intel-y+= vmx.o kvm-amd-y += svm.o diff --git a/virt/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c similarity index 99% rename from virt/kvm/assigned-dev.c rename to arch/x86/kvm/assigned-dev.c index e05000e..0cfd54f5f 100644 --- a/virt/kvm/assigned-dev.c +++ b/arch/x86/kvm/assigned-dev.c @@ -20,6 +20,7 @@ #include #include #include "irq.h" +#include "assigned-dev.h" static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head, int assigned_dev_id) diff --git a/arch/x86/kvm/assigned-dev.h b/arch/x86/kvm/assigned-dev.h new file mode 100644 index 000..4caabc5 --- /dev/null +++ b/arch/x86/kvm/assigned-dev.h @@ -0,0 +1,59 @@ +#ifndef ARCH_X86_KVM_ASSIGNED_DEV_H +#define ARCH_X86_KVM_ASSIGNED_DEV_H + +#include + +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT +struct kvm_assigned_dev_kernel { + struct kvm_irq_ack_notifier ack_notifier; + struct list_head list; + int assigned_dev_id; + int host_segnr; + int host_busnr; + int host_devfn; + unsigned int entries_nr; + int host_irq; + bool host_irq_disabled; + bool pci_2_3; + struct msix_entry *host_msix_entries; + int guest_irq; + struct msix_entry *guest_msix_entries; + unsigned long irq_requested_type; + int irq_source_id; + int flags; + struct pci_dev *dev; + struct kvm *kvm; + spinlock_t intx_lock; + spinlock_t intx_mask_lock; + char irq_name[32]; + struct pci_saved_state *pci_saved_state; +}; + +int kvm_assign_device(struct kvm *kvm, + struct kvm_assigned_dev_kernel *assigned_dev); +int kvm_deassign_device(struct kvm *kvm, + struct kvm_assigned_dev_kernel *assigned_dev); + +int kvm_iommu_map_guest(struct kvm *kvm); +int kvm_iommu_unmap_guest(struct kvm *kvm); + +long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg); + +void kvm_free_all_assigned_devices(struct kvm *kvm); +#else +static inline int kvm_iommu_unmap_guest(struct kvm *kvm) +{ + return 0; +} + +static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg) +{ + return -ENOTTY; +} + +static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} +#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */ + +#endif /* ARCH_X86_KVM_ASSIGNED_DEV_H */ diff --git a/virt/kvm/iommu.c b/arch/x86/kvm/iommu.c similarity index 99% rename from virt/kvm/iommu.c rename to
Re: [PATCH] kvm: x86: move assigned-dev.c and iommu.c to arch/x86/
2014-11-22 17:22+0100, Paolo Bonzini: On 21/11/2014 22:21, Radim Krčmář wrote: - struct kvm_assigned_dev_kernel depends on struct kvm_irq_ack_notifier kvm_assign_device and kvm_deassign_device can also be moved to arch/x86, in a new assigned-dev.h header. The header could include struct kvm_assigned_dev_kernel too but, if you change the argument of kvm_assign_device and kvm_deassign_device to struct pci_dev, the struct can move directly to assigned-dev.c and remain hidden there. Thanks! It's fine to do this as a follow up. With assigned-dev.h, we could remove everything from x86/kvm_host.h too, which would be better as a replacement to the original ---8--- kvm: x86: move assigned-dev.c and iommu.c to arch/x86/ Now that ia64 is gone, we can hide deprecated device assignment in x86. kvm_vm_ioctl_assigned_device() is newly called from kvm_arch_vm_ioctl(). Definitions and declarations have been consolidated into assigned-dev.h. Remaining kvm_iommu_(un)map_pages() would require new code to be moved. Signed-off-by: Radim Krčmář rkrc...@redhat.com --- arch/x86/kvm/Makefile | 2 +- {virt = arch/x86}/kvm/assigned-dev.c | 1 + arch/x86/kvm/assigned-dev.h | 59 +++ {virt = arch/x86}/kvm/iommu.c| 1 + arch/x86/kvm/x86.c| 3 +- include/linux/kvm_host.h | 55 virt/kvm/kvm_main.c | 2 -- 7 files changed, 64 insertions(+), 59 deletions(-) rename {virt = arch/x86}/kvm/assigned-dev.c (99%) create mode 100644 arch/x86/kvm/assigned-dev.h rename {virt = arch/x86}/kvm/iommu.c (99%) diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index ee1cd92..08f790d 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -9,11 +9,11 @@ KVM := ../../../virt/kvm kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o -kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= $(KVM)/assigned-dev.o $(KVM)/iommu.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o +kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= assigned-dev.o iommu.o kvm-intel-y+= vmx.o kvm-amd-y += svm.o diff --git a/virt/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c similarity index 99% rename from virt/kvm/assigned-dev.c rename to arch/x86/kvm/assigned-dev.c index e05000e..0cfd54f5f 100644 --- a/virt/kvm/assigned-dev.c +++ b/arch/x86/kvm/assigned-dev.c @@ -20,6 +20,7 @@ #include linux/namei.h #include linux/fs.h #include irq.h +#include assigned-dev.h static struct kvm_assigned_dev_kernel *kvm_find_assigned_dev(struct list_head *head, int assigned_dev_id) diff --git a/arch/x86/kvm/assigned-dev.h b/arch/x86/kvm/assigned-dev.h new file mode 100644 index 000..4caabc5 --- /dev/null +++ b/arch/x86/kvm/assigned-dev.h @@ -0,0 +1,59 @@ +#ifndef ARCH_X86_KVM_ASSIGNED_DEV_H +#define ARCH_X86_KVM_ASSIGNED_DEV_H + +#include linux/kvm_host.h + +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT +struct kvm_assigned_dev_kernel { + struct kvm_irq_ack_notifier ack_notifier; + struct list_head list; + int assigned_dev_id; + int host_segnr; + int host_busnr; + int host_devfn; + unsigned int entries_nr; + int host_irq; + bool host_irq_disabled; + bool pci_2_3; + struct msix_entry *host_msix_entries; + int guest_irq; + struct msix_entry *guest_msix_entries; + unsigned long irq_requested_type; + int irq_source_id; + int flags; + struct pci_dev *dev; + struct kvm *kvm; + spinlock_t intx_lock; + spinlock_t intx_mask_lock; + char irq_name[32]; + struct pci_saved_state *pci_saved_state; +}; + +int kvm_assign_device(struct kvm *kvm, + struct kvm_assigned_dev_kernel *assigned_dev); +int kvm_deassign_device(struct kvm *kvm, + struct kvm_assigned_dev_kernel *assigned_dev); + +int kvm_iommu_map_guest(struct kvm *kvm); +int kvm_iommu_unmap_guest(struct kvm *kvm); + +long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg); + +void kvm_free_all_assigned_devices(struct kvm *kvm); +#else +static inline int kvm_iommu_unmap_guest(struct kvm *kvm) +{ + return 0; +} + +static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg) +{ + return -ENOTTY; +} + +static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} +#endif /* CONFIG_KVM_DEVICE_ASSIGNMENT */ + +#endif /* ARCH_X86_KVM_ASSIGNED_DEV_H */ diff --git a/virt/kvm/iommu.c b/arch/x86/kvm/iommu.c similarity index 99% rename
Re: [PATCH] kvm: x86: move assigned-dev.c and iommu.c to arch/x86/
On 21/11/2014 22:21, Radim Krčmář wrote: > Now that ia64 is gone, we can hide deprecated device assignment in x86. > > Notable changes: > - kvm_vm_ioctl_assigned_device() was moved to x86/kvm_arch_vm_ioctl() > > The easy parts were removed from generic kvm code, remaining > - kvm_iommu_(un)map_pages() would require new code to be moved > - struct kvm_assigned_dev_kernel depends on struct kvm_irq_ack_notifier kvm_assign_device and kvm_deassign_device can also be moved to arch/x86, in a new assigned-dev.h header. The header could include struct kvm_assigned_dev_kernel too but, if you change the argument of kvm_assign_device and kvm_deassign_device to struct pci_dev, the struct can move directly to assigned-dev.c and remain hidden there. It's fine to do this as a follow up. Thanks! Paolo > Signed-off-by: Radim Krčmář > --- > Or are we going to remove it instead? ;) > > arch/x86/include/asm/kvm_host.h | 23 +++ > arch/x86/kvm/Makefile | 2 +- > {virt => arch/x86}/kvm/assigned-dev.c | 0 > {virt => arch/x86}/kvm/iommu.c| 0 > arch/x86/kvm/x86.c| 2 +- > include/linux/kvm_host.h | 26 -- > virt/kvm/kvm_main.c | 2 -- > 7 files changed, 25 insertions(+), 30 deletions(-) > rename {virt => arch/x86}/kvm/assigned-dev.c (100%) > rename {virt => arch/x86}/kvm/iommu.c (100%) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 76ff3e2..d549cf8 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1112,4 +1112,27 @@ int kvm_pmu_read_pmc(struct kvm_vcpu *vcpu, unsigned > pmc, u64 *data); > void kvm_handle_pmu_event(struct kvm_vcpu *vcpu); > void kvm_deliver_pmi(struct kvm_vcpu *vcpu); > > +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT > +int kvm_iommu_map_guest(struct kvm *kvm); > +int kvm_iommu_unmap_guest(struct kvm *kvm); > + > +long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, > + unsigned long arg); > + > +void kvm_free_all_assigned_devices(struct kvm *kvm); > +#else > +static inline int kvm_iommu_unmap_guest(struct kvm *kvm) > +{ > + return 0; > +} > + > +static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned > ioctl, > + unsigned long arg) > +{ > + return -ENOTTY; > +} > + > +static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} > +#endif > + > #endif /* _ASM_X86_KVM_HOST_H */ > diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile > index ee1cd92..08f790d 100644 > --- a/arch/x86/kvm/Makefile > +++ b/arch/x86/kvm/Makefile > @@ -9,11 +9,11 @@ KVM := ../../../virt/kvm > > kvm-y+= $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ > $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o > -kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += $(KVM)/assigned-dev.o $(KVM)/iommu.o > kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o > > kvm-y+= x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ > i8254.o ioapic.o irq_comm.o cpuid.o pmu.o > +kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += assigned-dev.o iommu.o > kvm-intel-y += vmx.o > kvm-amd-y+= svm.o > > diff --git a/virt/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c > similarity index 100% > rename from virt/kvm/assigned-dev.c > rename to arch/x86/kvm/assigned-dev.c > diff --git a/virt/kvm/iommu.c b/arch/x86/kvm/iommu.c > similarity index 100% > rename from virt/kvm/iommu.c > rename to arch/x86/kvm/iommu.c > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 5337039..782e4ea 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -4007,7 +4007,7 @@ long kvm_arch_vm_ioctl(struct file *filp, > } > > default: > - ; > + r = kvm_vm_ioctl_assigned_device(kvm, ioctl, arg); > } > out: > return r; > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index d2d4270..746e3ef 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -764,8 +764,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int > irq_source_id); > #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT > int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); > void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot); > -int kvm_iommu_map_guest(struct kvm *kvm); > -int kvm_iommu_unmap_guest(struct kvm *kvm); > int kvm_assign_device(struct kvm *kvm, > struct kvm_assigned_dev_kernel *assigned_dev); > int kvm_deassign_device(struct kvm *kvm, > @@ -781,11 +779,6 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm, >struct kvm_memory_slot *slot) > { > } > - > -static inline int kvm_iommu_unmap_guest(struct kvm *kvm) > -{ > - return 0; > -} > #endif > > static
Re: [PATCH] kvm: x86: move assigned-dev.c and iommu.c to arch/x86/
On 21/11/2014 22:21, Radim Krčmář wrote: Now that ia64 is gone, we can hide deprecated device assignment in x86. Notable changes: - kvm_vm_ioctl_assigned_device() was moved to x86/kvm_arch_vm_ioctl() The easy parts were removed from generic kvm code, remaining - kvm_iommu_(un)map_pages() would require new code to be moved - struct kvm_assigned_dev_kernel depends on struct kvm_irq_ack_notifier kvm_assign_device and kvm_deassign_device can also be moved to arch/x86, in a new assigned-dev.h header. The header could include struct kvm_assigned_dev_kernel too but, if you change the argument of kvm_assign_device and kvm_deassign_device to struct pci_dev, the struct can move directly to assigned-dev.c and remain hidden there. It's fine to do this as a follow up. Thanks! Paolo Signed-off-by: Radim Krčmář rkrc...@redhat.com --- Or are we going to remove it instead? ;) arch/x86/include/asm/kvm_host.h | 23 +++ arch/x86/kvm/Makefile | 2 +- {virt = arch/x86}/kvm/assigned-dev.c | 0 {virt = arch/x86}/kvm/iommu.c| 0 arch/x86/kvm/x86.c| 2 +- include/linux/kvm_host.h | 26 -- virt/kvm/kvm_main.c | 2 -- 7 files changed, 25 insertions(+), 30 deletions(-) rename {virt = arch/x86}/kvm/assigned-dev.c (100%) rename {virt = arch/x86}/kvm/iommu.c (100%) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 76ff3e2..d549cf8 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1112,4 +1112,27 @@ int kvm_pmu_read_pmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data); void kvm_handle_pmu_event(struct kvm_vcpu *vcpu); void kvm_deliver_pmi(struct kvm_vcpu *vcpu); +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT +int kvm_iommu_map_guest(struct kvm *kvm); +int kvm_iommu_unmap_guest(struct kvm *kvm); + +long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg); + +void kvm_free_all_assigned_devices(struct kvm *kvm); +#else +static inline int kvm_iommu_unmap_guest(struct kvm *kvm) +{ + return 0; +} + +static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg) +{ + return -ENOTTY; +} + +static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} +#endif + #endif /* _ASM_X86_KVM_HOST_H */ diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index ee1cd92..08f790d 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -9,11 +9,11 @@ KVM := ../../../virt/kvm kvm-y+= $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o -kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += $(KVM)/assigned-dev.o $(KVM)/iommu.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y+= x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o +kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += assigned-dev.o iommu.o kvm-intel-y += vmx.o kvm-amd-y+= svm.o diff --git a/virt/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c similarity index 100% rename from virt/kvm/assigned-dev.c rename to arch/x86/kvm/assigned-dev.c diff --git a/virt/kvm/iommu.c b/arch/x86/kvm/iommu.c similarity index 100% rename from virt/kvm/iommu.c rename to arch/x86/kvm/iommu.c diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5337039..782e4ea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4007,7 +4007,7 @@ long kvm_arch_vm_ioctl(struct file *filp, } default: - ; + r = kvm_vm_ioctl_assigned_device(kvm, ioctl, arg); } out: return r; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d2d4270..746e3ef 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -764,8 +764,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot); -int kvm_iommu_map_guest(struct kvm *kvm); -int kvm_iommu_unmap_guest(struct kvm *kvm); int kvm_assign_device(struct kvm *kvm, struct kvm_assigned_dev_kernel *assigned_dev); int kvm_deassign_device(struct kvm *kvm, @@ -781,11 +779,6 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot) { } - -static inline int kvm_iommu_unmap_guest(struct kvm *kvm) -{ - return 0; -} #endif static inline void kvm_guest_enter(void) @@ -1005,25 +998,6 @@ static inline bool kvm_vcpu_compatible(struct kvm_vcpu
[PATCH] kvm: x86: move assigned-dev.c and iommu.c to arch/x86/
Now that ia64 is gone, we can hide deprecated device assignment in x86. Notable changes: - kvm_vm_ioctl_assigned_device() was moved to x86/kvm_arch_vm_ioctl() The easy parts were removed from generic kvm code, remaining - kvm_iommu_(un)map_pages() would require new code to be moved - struct kvm_assigned_dev_kernel depends on struct kvm_irq_ack_notifier Signed-off-by: Radim Krčmář --- Or are we going to remove it instead? ;) arch/x86/include/asm/kvm_host.h | 23 +++ arch/x86/kvm/Makefile | 2 +- {virt => arch/x86}/kvm/assigned-dev.c | 0 {virt => arch/x86}/kvm/iommu.c| 0 arch/x86/kvm/x86.c| 2 +- include/linux/kvm_host.h | 26 -- virt/kvm/kvm_main.c | 2 -- 7 files changed, 25 insertions(+), 30 deletions(-) rename {virt => arch/x86}/kvm/assigned-dev.c (100%) rename {virt => arch/x86}/kvm/iommu.c (100%) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 76ff3e2..d549cf8 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1112,4 +1112,27 @@ int kvm_pmu_read_pmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data); void kvm_handle_pmu_event(struct kvm_vcpu *vcpu); void kvm_deliver_pmi(struct kvm_vcpu *vcpu); +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT +int kvm_iommu_map_guest(struct kvm *kvm); +int kvm_iommu_unmap_guest(struct kvm *kvm); + +long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg); + +void kvm_free_all_assigned_devices(struct kvm *kvm); +#else +static inline int kvm_iommu_unmap_guest(struct kvm *kvm) +{ + return 0; +} + +static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg) +{ + return -ENOTTY; +} + +static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} +#endif + #endif /* _ASM_X86_KVM_HOST_H */ diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index ee1cd92..08f790d 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -9,11 +9,11 @@ KVM := ../../../virt/kvm kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o -kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= $(KVM)/assigned-dev.o $(KVM)/iommu.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o +kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= assigned-dev.o iommu.o kvm-intel-y+= vmx.o kvm-amd-y += svm.o diff --git a/virt/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c similarity index 100% rename from virt/kvm/assigned-dev.c rename to arch/x86/kvm/assigned-dev.c diff --git a/virt/kvm/iommu.c b/arch/x86/kvm/iommu.c similarity index 100% rename from virt/kvm/iommu.c rename to arch/x86/kvm/iommu.c diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5337039..782e4ea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4007,7 +4007,7 @@ long kvm_arch_vm_ioctl(struct file *filp, } default: - ; + r = kvm_vm_ioctl_assigned_device(kvm, ioctl, arg); } out: return r; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d2d4270..746e3ef 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -764,8 +764,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot); -int kvm_iommu_map_guest(struct kvm *kvm); -int kvm_iommu_unmap_guest(struct kvm *kvm); int kvm_assign_device(struct kvm *kvm, struct kvm_assigned_dev_kernel *assigned_dev); int kvm_deassign_device(struct kvm *kvm, @@ -781,11 +779,6 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot) { } - -static inline int kvm_iommu_unmap_guest(struct kvm *kvm) -{ - return 0; -} #endif static inline void kvm_guest_enter(void) @@ -1005,25 +998,6 @@ static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; } #endif -#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT - -long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, - unsigned long arg); - -void kvm_free_all_assigned_devices(struct kvm *kvm); - -#else - -static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, - unsigned long arg) -{ - return -ENOTTY; -} - -static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} - -#endif - static
[PATCH] kvm: x86: move assigned-dev.c and iommu.c to arch/x86/
Now that ia64 is gone, we can hide deprecated device assignment in x86. Notable changes: - kvm_vm_ioctl_assigned_device() was moved to x86/kvm_arch_vm_ioctl() The easy parts were removed from generic kvm code, remaining - kvm_iommu_(un)map_pages() would require new code to be moved - struct kvm_assigned_dev_kernel depends on struct kvm_irq_ack_notifier Signed-off-by: Radim Krčmář rkrc...@redhat.com --- Or are we going to remove it instead? ;) arch/x86/include/asm/kvm_host.h | 23 +++ arch/x86/kvm/Makefile | 2 +- {virt = arch/x86}/kvm/assigned-dev.c | 0 {virt = arch/x86}/kvm/iommu.c| 0 arch/x86/kvm/x86.c| 2 +- include/linux/kvm_host.h | 26 -- virt/kvm/kvm_main.c | 2 -- 7 files changed, 25 insertions(+), 30 deletions(-) rename {virt = arch/x86}/kvm/assigned-dev.c (100%) rename {virt = arch/x86}/kvm/iommu.c (100%) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 76ff3e2..d549cf8 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1112,4 +1112,27 @@ int kvm_pmu_read_pmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data); void kvm_handle_pmu_event(struct kvm_vcpu *vcpu); void kvm_deliver_pmi(struct kvm_vcpu *vcpu); +#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT +int kvm_iommu_map_guest(struct kvm *kvm); +int kvm_iommu_unmap_guest(struct kvm *kvm); + +long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg); + +void kvm_free_all_assigned_devices(struct kvm *kvm); +#else +static inline int kvm_iommu_unmap_guest(struct kvm *kvm) +{ + return 0; +} + +static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, + unsigned long arg) +{ + return -ENOTTY; +} + +static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} +#endif + #endif /* _ASM_X86_KVM_HOST_H */ diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index ee1cd92..08f790d 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -9,11 +9,11 @@ KVM := ../../../virt/kvm kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o -kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= $(KVM)/assigned-dev.o $(KVM)/iommu.o kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o +kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT)+= assigned-dev.o iommu.o kvm-intel-y+= vmx.o kvm-amd-y += svm.o diff --git a/virt/kvm/assigned-dev.c b/arch/x86/kvm/assigned-dev.c similarity index 100% rename from virt/kvm/assigned-dev.c rename to arch/x86/kvm/assigned-dev.c diff --git a/virt/kvm/iommu.c b/arch/x86/kvm/iommu.c similarity index 100% rename from virt/kvm/iommu.c rename to arch/x86/kvm/iommu.c diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5337039..782e4ea 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4007,7 +4007,7 @@ long kvm_arch_vm_ioctl(struct file *filp, } default: - ; + r = kvm_vm_ioctl_assigned_device(kvm, ioctl, arg); } out: return r; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d2d4270..746e3ef 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -764,8 +764,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot); void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot); -int kvm_iommu_map_guest(struct kvm *kvm); -int kvm_iommu_unmap_guest(struct kvm *kvm); int kvm_assign_device(struct kvm *kvm, struct kvm_assigned_dev_kernel *assigned_dev); int kvm_deassign_device(struct kvm *kvm, @@ -781,11 +779,6 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot) { } - -static inline int kvm_iommu_unmap_guest(struct kvm *kvm) -{ - return 0; -} #endif static inline void kvm_guest_enter(void) @@ -1005,25 +998,6 @@ static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; } #endif -#ifdef CONFIG_KVM_DEVICE_ASSIGNMENT - -long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, - unsigned long arg); - -void kvm_free_all_assigned_devices(struct kvm *kvm); - -#else - -static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl, - unsigned long arg) -{ - return -ENOTTY; -} - -static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {} -