[vbox-dev] Fix build errors on Linux kernel version 3.2

Larry Finger Larry.Finger at lwfinger.net
Thu Nov 10 03:28:03 GMT 2011


In Linux kernel 3.2, the iommu API changed. The following patch, copyright 2011 
by Larry Finger and released under an MIT license, allows the VirtualBox module 
vboxpci to build:

Index: vboxhost/vboxpci/linux/VBoxPci-linux.c
===================================================================
--- vboxhost.orig/vboxpci/linux/VBoxPci-linux.c
+++ vboxhost/vboxpci/linux/VBoxPci-linux.c
@@ -146,7 +146,11 @@ static int __init VBoxPciLinuxInit(void)
  #endif

  #ifdef VBOX_WITH_IOMMU
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
+    if (iommu_present(&pci_bus_type))
+#else
      if (iommu_found())
+#endif
          printk(KERN_INFO "vboxpci: IOMMU found\n");
      else
          printk(KERN_INFO "vboxpci: IOMMU not found (not registered)\n");
@@ -984,9 +988,15 @@ int  vboxPciOsInitVm(PVBOXRAWPCIDRVVM pT
      printk(KERN_DEBUG "vboxPciOsInitVm: %p\n", pThis);
  #endif
  #ifdef VBOX_WITH_IOMMU
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
+    if (iommu_present(&pci_bus_type))
+    {
+        pThis->pIommuDomain = iommu_domain_alloc(&pci_bus_type);
+#else
      if (iommu_found())
      {
          pThis->pIommuDomain = iommu_domain_alloc();
+#endif
          if (!pThis->pIommuDomain)
          {
              printk(KERN_DEBUG "cannot allocate IOMMU domain\n");





More information about the vbox-dev mailing list