[PATCH] target/i386: remove unused pci-assign codes

Eiichi Tsukata posted 1 patch 4 years, 4 months ago
Test asan passed
Test checkpatch passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test docker-quick@centos7 passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191209072932.313056-1-devel@etsukata.com
Maintainers: Richard Henderson <rth@twiddle.net>, Marcelo Tosatti <mtosatti@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
target/i386/kvm.c      | 140 -----------------------------------------
target/i386/kvm_i386.h |  20 ------
2 files changed, 160 deletions(-)
[PATCH] target/i386: remove unused pci-assign codes
Posted by Eiichi Tsukata 4 years, 4 months ago
Legacy PCI device assignment has been already removed in commit ab37bfc7d641
("pci-assign: Remove"), but some codes remain unused.

CC: qemu-trivial@nongnu.org
Signed-off-by: Eiichi Tsukata <devel@etsukata.com>
---
 target/i386/kvm.c      | 140 -----------------------------------------
 target/i386/kvm_i386.h |  20 ------
 2 files changed, 160 deletions(-)

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index bf1655645b..efd39843c4 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -4505,146 +4505,6 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
     }
 }
 
-/* Classic KVM device assignment interface. Will remain x86 only. */
-int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr,
-                          uint32_t flags, uint32_t *dev_id)
-{
-    struct kvm_assigned_pci_dev dev_data = {
-        .segnr = dev_addr->domain,
-        .busnr = dev_addr->bus,
-        .devfn = PCI_DEVFN(dev_addr->slot, dev_addr->function),
-        .flags = flags,
-    };
-    int ret;
-
-    dev_data.assigned_dev_id =
-        (dev_addr->domain << 16) | (dev_addr->bus << 8) | dev_data.devfn;
-
-    ret = kvm_vm_ioctl(s, KVM_ASSIGN_PCI_DEVICE, &dev_data);
-    if (ret < 0) {
-        return ret;
-    }
-
-    *dev_id = dev_data.assigned_dev_id;
-
-    return 0;
-}
-
-int kvm_device_pci_deassign(KVMState *s, uint32_t dev_id)
-{
-    struct kvm_assigned_pci_dev dev_data = {
-        .assigned_dev_id = dev_id,
-    };
-
-    return kvm_vm_ioctl(s, KVM_DEASSIGN_PCI_DEVICE, &dev_data);
-}
-
-static int kvm_assign_irq_internal(KVMState *s, uint32_t dev_id,
-                                   uint32_t irq_type, uint32_t guest_irq)
-{
-    struct kvm_assigned_irq assigned_irq = {
-        .assigned_dev_id = dev_id,
-        .guest_irq = guest_irq,
-        .flags = irq_type,
-    };
-
-    if (kvm_check_extension(s, KVM_CAP_ASSIGN_DEV_IRQ)) {
-        return kvm_vm_ioctl(s, KVM_ASSIGN_DEV_IRQ, &assigned_irq);
-    } else {
-        return kvm_vm_ioctl(s, KVM_ASSIGN_IRQ, &assigned_irq);
-    }
-}
-
-int kvm_device_intx_assign(KVMState *s, uint32_t dev_id, bool use_host_msi,
-                           uint32_t guest_irq)
-{
-    uint32_t irq_type = KVM_DEV_IRQ_GUEST_INTX |
-        (use_host_msi ? KVM_DEV_IRQ_HOST_MSI : KVM_DEV_IRQ_HOST_INTX);
-
-    return kvm_assign_irq_internal(s, dev_id, irq_type, guest_irq);
-}
-
-int kvm_device_intx_set_mask(KVMState *s, uint32_t dev_id, bool masked)
-{
-    struct kvm_assigned_pci_dev dev_data = {
-        .assigned_dev_id = dev_id,
-        .flags = masked ? KVM_DEV_ASSIGN_MASK_INTX : 0,
-    };
-
-    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_INTX_MASK, &dev_data);
-}
-
-static int kvm_deassign_irq_internal(KVMState *s, uint32_t dev_id,
-                                     uint32_t type)
-{
-    struct kvm_assigned_irq assigned_irq = {
-        .assigned_dev_id = dev_id,
-        .flags = type,
-    };
-
-    return kvm_vm_ioctl(s, KVM_DEASSIGN_DEV_IRQ, &assigned_irq);
-}
-
-int kvm_device_intx_deassign(KVMState *s, uint32_t dev_id, bool use_host_msi)
-{
-    return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_INTX |
-        (use_host_msi ? KVM_DEV_IRQ_HOST_MSI : KVM_DEV_IRQ_HOST_INTX));
-}
-
-int kvm_device_msi_assign(KVMState *s, uint32_t dev_id, int virq)
-{
-    return kvm_assign_irq_internal(s, dev_id, KVM_DEV_IRQ_HOST_MSI |
-                                              KVM_DEV_IRQ_GUEST_MSI, virq);
-}
-
-int kvm_device_msi_deassign(KVMState *s, uint32_t dev_id)
-{
-    return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_MSI |
-                                                KVM_DEV_IRQ_HOST_MSI);
-}
-
-bool kvm_device_msix_supported(KVMState *s)
-{
-    /* The kernel lacks a corresponding KVM_CAP, so we probe by calling
-     * KVM_ASSIGN_SET_MSIX_NR with an invalid parameter. */
-    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_NR, NULL) == -EFAULT;
-}
-
-int kvm_device_msix_init_vectors(KVMState *s, uint32_t dev_id,
-                                 uint32_t nr_vectors)
-{
-    struct kvm_assigned_msix_nr msix_nr = {
-        .assigned_dev_id = dev_id,
-        .entry_nr = nr_vectors,
-    };
-
-    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_NR, &msix_nr);
-}
-
-int kvm_device_msix_set_vector(KVMState *s, uint32_t dev_id, uint32_t vector,
-                               int virq)
-{
-    struct kvm_assigned_msix_entry msix_entry = {
-        .assigned_dev_id = dev_id,
-        .gsi = virq,
-        .entry = vector,
-    };
-
-    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_ENTRY, &msix_entry);
-}
-
-int kvm_device_msix_assign(KVMState *s, uint32_t dev_id)
-{
-    return kvm_assign_irq_internal(s, dev_id, KVM_DEV_IRQ_HOST_MSIX |
-                                              KVM_DEV_IRQ_GUEST_MSIX, 0);
-}
-
-int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id)
-{
-    return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_MSIX |
-                                                KVM_DEV_IRQ_HOST_MSIX);
-}
-
 int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
                              uint64_t address, uint32_t data, PCIDevice *dev)
 {
diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h
index 06fe06bdb3..7d0242f5fb 100644
--- a/target/i386/kvm_i386.h
+++ b/target/i386/kvm_i386.h
@@ -40,26 +40,6 @@ void kvm_synchronize_all_tsc(void);
 void kvm_arch_reset_vcpu(X86CPU *cs);
 void kvm_arch_do_init_vcpu(X86CPU *cs);
 
-int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr,
-                          uint32_t flags, uint32_t *dev_id);
-int kvm_device_pci_deassign(KVMState *s, uint32_t dev_id);
-
-int kvm_device_intx_assign(KVMState *s, uint32_t dev_id,
-                           bool use_host_msi, uint32_t guest_irq);
-int kvm_device_intx_set_mask(KVMState *s, uint32_t dev_id, bool masked);
-int kvm_device_intx_deassign(KVMState *s, uint32_t dev_id, bool use_host_msi);
-
-int kvm_device_msi_assign(KVMState *s, uint32_t dev_id, int virq);
-int kvm_device_msi_deassign(KVMState *s, uint32_t dev_id);
-
-bool kvm_device_msix_supported(KVMState *s);
-int kvm_device_msix_init_vectors(KVMState *s, uint32_t dev_id,
-                                 uint32_t nr_vectors);
-int kvm_device_msix_set_vector(KVMState *s, uint32_t dev_id, uint32_t vector,
-                               int virq);
-int kvm_device_msix_assign(KVMState *s, uint32_t dev_id);
-int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id);
-
 void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
 
 bool kvm_enable_x2apic(void);
-- 
2.23.0


Re: [PATCH] target/i386: remove unused pci-assign codes
Posted by Paolo Bonzini 4 years, 4 months ago
On 09/12/19 08:29, Eiichi Tsukata wrote:
> Legacy PCI device assignment has been already removed in commit ab37bfc7d641
> ("pci-assign: Remove"), but some codes remain unused.
> 
> CC: qemu-trivial@nongnu.org
> Signed-off-by: Eiichi Tsukata <devel@etsukata.com>
> ---
>  target/i386/kvm.c      | 140 -----------------------------------------
>  target/i386/kvm_i386.h |  20 ------
>  2 files changed, 160 deletions(-)
> 
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index bf1655645b..efd39843c4 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -4505,146 +4505,6 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
>      }
>  }
>  
> -/* Classic KVM device assignment interface. Will remain x86 only. */
> -int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr,
> -                          uint32_t flags, uint32_t *dev_id)
> -{
> -    struct kvm_assigned_pci_dev dev_data = {
> -        .segnr = dev_addr->domain,
> -        .busnr = dev_addr->bus,
> -        .devfn = PCI_DEVFN(dev_addr->slot, dev_addr->function),
> -        .flags = flags,
> -    };
> -    int ret;
> -
> -    dev_data.assigned_dev_id =
> -        (dev_addr->domain << 16) | (dev_addr->bus << 8) | dev_data.devfn;
> -
> -    ret = kvm_vm_ioctl(s, KVM_ASSIGN_PCI_DEVICE, &dev_data);
> -    if (ret < 0) {
> -        return ret;
> -    }
> -
> -    *dev_id = dev_data.assigned_dev_id;
> -
> -    return 0;
> -}
> -
> -int kvm_device_pci_deassign(KVMState *s, uint32_t dev_id)
> -{
> -    struct kvm_assigned_pci_dev dev_data = {
> -        .assigned_dev_id = dev_id,
> -    };
> -
> -    return kvm_vm_ioctl(s, KVM_DEASSIGN_PCI_DEVICE, &dev_data);
> -}
> -
> -static int kvm_assign_irq_internal(KVMState *s, uint32_t dev_id,
> -                                   uint32_t irq_type, uint32_t guest_irq)
> -{
> -    struct kvm_assigned_irq assigned_irq = {
> -        .assigned_dev_id = dev_id,
> -        .guest_irq = guest_irq,
> -        .flags = irq_type,
> -    };
> -
> -    if (kvm_check_extension(s, KVM_CAP_ASSIGN_DEV_IRQ)) {
> -        return kvm_vm_ioctl(s, KVM_ASSIGN_DEV_IRQ, &assigned_irq);
> -    } else {
> -        return kvm_vm_ioctl(s, KVM_ASSIGN_IRQ, &assigned_irq);
> -    }
> -}
> -
> -int kvm_device_intx_assign(KVMState *s, uint32_t dev_id, bool use_host_msi,
> -                           uint32_t guest_irq)
> -{
> -    uint32_t irq_type = KVM_DEV_IRQ_GUEST_INTX |
> -        (use_host_msi ? KVM_DEV_IRQ_HOST_MSI : KVM_DEV_IRQ_HOST_INTX);
> -
> -    return kvm_assign_irq_internal(s, dev_id, irq_type, guest_irq);
> -}
> -
> -int kvm_device_intx_set_mask(KVMState *s, uint32_t dev_id, bool masked)
> -{
> -    struct kvm_assigned_pci_dev dev_data = {
> -        .assigned_dev_id = dev_id,
> -        .flags = masked ? KVM_DEV_ASSIGN_MASK_INTX : 0,
> -    };
> -
> -    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_INTX_MASK, &dev_data);
> -}
> -
> -static int kvm_deassign_irq_internal(KVMState *s, uint32_t dev_id,
> -                                     uint32_t type)
> -{
> -    struct kvm_assigned_irq assigned_irq = {
> -        .assigned_dev_id = dev_id,
> -        .flags = type,
> -    };
> -
> -    return kvm_vm_ioctl(s, KVM_DEASSIGN_DEV_IRQ, &assigned_irq);
> -}
> -
> -int kvm_device_intx_deassign(KVMState *s, uint32_t dev_id, bool use_host_msi)
> -{
> -    return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_INTX |
> -        (use_host_msi ? KVM_DEV_IRQ_HOST_MSI : KVM_DEV_IRQ_HOST_INTX));
> -}
> -
> -int kvm_device_msi_assign(KVMState *s, uint32_t dev_id, int virq)
> -{
> -    return kvm_assign_irq_internal(s, dev_id, KVM_DEV_IRQ_HOST_MSI |
> -                                              KVM_DEV_IRQ_GUEST_MSI, virq);
> -}
> -
> -int kvm_device_msi_deassign(KVMState *s, uint32_t dev_id)
> -{
> -    return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_MSI |
> -                                                KVM_DEV_IRQ_HOST_MSI);
> -}
> -
> -bool kvm_device_msix_supported(KVMState *s)
> -{
> -    /* The kernel lacks a corresponding KVM_CAP, so we probe by calling
> -     * KVM_ASSIGN_SET_MSIX_NR with an invalid parameter. */
> -    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_NR, NULL) == -EFAULT;
> -}
> -
> -int kvm_device_msix_init_vectors(KVMState *s, uint32_t dev_id,
> -                                 uint32_t nr_vectors)
> -{
> -    struct kvm_assigned_msix_nr msix_nr = {
> -        .assigned_dev_id = dev_id,
> -        .entry_nr = nr_vectors,
> -    };
> -
> -    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_NR, &msix_nr);
> -}
> -
> -int kvm_device_msix_set_vector(KVMState *s, uint32_t dev_id, uint32_t vector,
> -                               int virq)
> -{
> -    struct kvm_assigned_msix_entry msix_entry = {
> -        .assigned_dev_id = dev_id,
> -        .gsi = virq,
> -        .entry = vector,
> -    };
> -
> -    return kvm_vm_ioctl(s, KVM_ASSIGN_SET_MSIX_ENTRY, &msix_entry);
> -}
> -
> -int kvm_device_msix_assign(KVMState *s, uint32_t dev_id)
> -{
> -    return kvm_assign_irq_internal(s, dev_id, KVM_DEV_IRQ_HOST_MSIX |
> -                                              KVM_DEV_IRQ_GUEST_MSIX, 0);
> -}
> -
> -int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id)
> -{
> -    return kvm_deassign_irq_internal(s, dev_id, KVM_DEV_IRQ_GUEST_MSIX |
> -                                                KVM_DEV_IRQ_HOST_MSIX);
> -}
> -
>  int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
>                               uint64_t address, uint32_t data, PCIDevice *dev)
>  {
> diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h
> index 06fe06bdb3..7d0242f5fb 100644
> --- a/target/i386/kvm_i386.h
> +++ b/target/i386/kvm_i386.h
> @@ -40,26 +40,6 @@ void kvm_synchronize_all_tsc(void);
>  void kvm_arch_reset_vcpu(X86CPU *cs);
>  void kvm_arch_do_init_vcpu(X86CPU *cs);
>  
> -int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr,
> -                          uint32_t flags, uint32_t *dev_id);
> -int kvm_device_pci_deassign(KVMState *s, uint32_t dev_id);
> -
> -int kvm_device_intx_assign(KVMState *s, uint32_t dev_id,
> -                           bool use_host_msi, uint32_t guest_irq);
> -int kvm_device_intx_set_mask(KVMState *s, uint32_t dev_id, bool masked);
> -int kvm_device_intx_deassign(KVMState *s, uint32_t dev_id, bool use_host_msi);
> -
> -int kvm_device_msi_assign(KVMState *s, uint32_t dev_id, int virq);
> -int kvm_device_msi_deassign(KVMState *s, uint32_t dev_id);
> -
> -bool kvm_device_msix_supported(KVMState *s);
> -int kvm_device_msix_init_vectors(KVMState *s, uint32_t dev_id,
> -                                 uint32_t nr_vectors);
> -int kvm_device_msix_set_vector(KVMState *s, uint32_t dev_id, uint32_t vector,
> -                               int virq);
> -int kvm_device_msix_assign(KVMState *s, uint32_t dev_id);
> -int kvm_device_msix_deassign(KVMState *s, uint32_t dev_id);
> -
>  void kvm_put_apicbase(X86CPU *cpu, uint64_t value);
>  
>  bool kvm_enable_x2apic(void);
> 

Queued, thanks.