Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Linux compatibility fixes
[palacios.git] / linux_module / iface-host-pci-hw.h
index 0439b51..36e3849 100644 (file)
 
 #define PCI_HDR_SIZE 256
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 43)
+#define IOMMU_FOUND()        iommu_present(&pci_bus_type)
+#define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc(&pci_bus_type)
+#else
+#define IOMMU_FOUND()        iommu_found()
+#define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc()
+#endif
+
+
 
 static int setup_hw_pci_dev(struct host_pci_device * host_dev) {
     int ret = 0;
@@ -77,8 +86,10 @@ static int setup_hw_pci_dev(struct host_pci_device * host_dev) {
            if (flags & IORESOURCE_IO) {
                bar->type = PT_BAR_IO;
            } else if (flags & IORESOURCE_MEM) {
-               if (flags & IORESOURCE_MEM_64) {
-                   struct v3_host_pci_bar * hi_bar = &(v3_dev->bars[i + 1]); 
+               if ((flags & IORESOURCE_MEM_64)) {
+                   // this should never happen with i==5, but it
+                   // is technically an OOB access without the modulo
+                   struct v3_host_pci_bar * hi_bar = &(v3_dev->bars[(i + 1) % 6]); 
            
                    bar->type = PT_BAR_MEM64_LO;
 
@@ -134,7 +145,7 @@ static int setup_hw_pci_dev(struct host_pci_device * host_dev) {
 
 
     /* HARDCODED for now but this will need to depend on IOMMU support detection */
-    if (iommu_found()) {
+    if (IOMMU_FOUND()) {
        printk("Setting host PCI device (%s) as IOMMU\n", host_dev->name);
        v3_dev->iface = IOMMU;
     } else {
@@ -343,7 +354,7 @@ static int reserve_hw_pci_dev(struct host_pci_device * host_dev, void * v3_ctx)
        int flags = 0;
        uintptr_t gpa = 0;
 
-       host_dev->hw_dev.iommu_domain = iommu_domain_alloc();
+       host_dev->hw_dev.iommu_domain = IOMMU_DOMAIN_ALLOC();
 
        while (V3_get_guest_mem_region(v3_ctx, &region, gpa)) {