Hello,

if you compile the kernel with KVM activated and without PCI support
you get the following crash:

  CC      arch/x86/kvm/../../../virt/kvm/kvm_main.o
arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function
'kvm_free_assigned_device':
arch/x86/kvm/../../../virt/kvm/kvm_main.c:155: error: implicit
declaration of function 'pci_reset_function'
make[1]: *** [arch/x86/kvm/../../../virt/kvm/kvm_main.o] Error 1
make: *** [arch/x86/kvm] Error 2

This can be reproduced by using the attached config file. Obviously
the pci_reset_function should not be called when PCI support is
disabled. These changes fix the issue:

diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 44fd7fa..d93de2c 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -387,7 +387,7 @@ struct kvm_trace_rec {
 #define KVM_CAP_MP_STATE 14
 #define KVM_CAP_COALESCED_MMIO 15
 #define KVM_CAP_SYNC_MMU 16  /* Changes to host mmap are reflected in guest */
-#if defined(CONFIG_X86)||defined(CONFIG_IA64)
+#if (defined(CONFIG_X86)||defined(CONFIG_IA64)) && defined(CONFIG_PCI)
 #define KVM_CAP_DEVICE_ASSIGNMENT 17
 #endif
 #define KVM_CAP_IOMMU 18

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9a4a39c..0397c65 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4148,7 +4148,9 @@ static void kvm_free_vcpus(struct kvm *kvm)

 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
+#ifdef KVM_CAP_DEVICE_ASSIGNMENT
    kvm_free_all_assigned_devices(kvm);
+#endif
    kvm_iommu_unmap_guest(kvm);
    kvm_free_pit(kvm);
    kfree(kvm->arch.vpic);

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 1972266..47c5a7a 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -202,6 +202,7 @@ static __init int iommu_setup(char *p)
            iommu_merge = 0;
        if (!strncmp(p, "forcesac", 8))
            iommu_sac_force = 1;
+#ifdef CONFIG_PCI
        if (!strncmp(p, "allowdac", 8))
            forbid_dac = 0;
        if (!strncmp(p, "nodac", 5))
@@ -210,6 +211,7 @@ static __init int iommu_setup(char *p)
            forbid_dac = -1;
            return 1;
        }
+#endif
 #ifdef CONFIG_SWIOTLB
        if (!strncmp(p, "soft", 4))
            swiotlb = 1;

Cheers,
Daniel

Attachment: test_config
Description: Binary data

Attachment: dep_pci.patch
Description: Binary data

Reply via email to