Merge branch 'stable/for-linus-4.20' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 23 Oct 2018 10:02:05 +0000 (11:02 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 23 Oct 2018 10:02:05 +0000 (11:02 +0100)
Pull xen swiotlb fix from Konrad Rzeszutek Wilk:
 "One tiny fix for the Xen SWIOTLB mechanism that occasionally happened
  with devices that didn't allocate size in power of two but rather some
  odd sizes.

  We neglected to make the memory coherent leading to all kinds of fun
  crashes"

* 'stable/for-linus-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb:
  xen-swiotlb: use actually allocated size on check physical continuous

1  2 
drivers/xen/swiotlb-xen.c

index 28819a0e61d0c7c82e87da1165ad91ec4fbe38b2,aa081f8067283bece0384cfb01d4bf5d1d2aa6cc..f5c1af4ce9abb550083d2cae04a4e19a485cbcdc
@@@ -303,6 -303,9 +303,9 @@@ xen_swiotlb_alloc_coherent(struct devic
        */
        flags &= ~(__GFP_DMA | __GFP_HIGHMEM);
  
+       /* Convert the size to actually allocated. */
+       size = 1UL << (order + XEN_PAGE_SHIFT);
        /* On ARM this function returns an ioremap'ped virtual address for
         * which virt_to_phys doesn't return the corresponding physical
         * address. In fact on ARM virt_to_phys only works for kernel direct
@@@ -351,6 -354,9 +354,9 @@@ xen_swiotlb_free_coherent(struct devic
         * physical address */
        phys = xen_bus_to_phys(dev_addr);
  
+       /* Convert the size to actually allocated. */
+       size = 1UL << (order + XEN_PAGE_SHIFT);
        if (((dev_addr + size - 1 <= dma_mask)) ||
            range_straddles_page_boundary(phys, size))
                xen_destroy_contiguous_region(phys, order);
@@@ -662,7 -668,7 +668,7 @@@ xen_swiotlb_dma_mmap(struct device *dev
                return xen_get_dma_ops(dev)->mmap(dev, vma, cpu_addr,
                                                    dma_addr, size, attrs);
  #endif
 -      return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
 +      return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size, attrs);
  }
  
  /*
@@@ -689,7 -695,7 +695,7 @@@ xen_swiotlb_get_sgtable(struct device *
                                                           handle, size, attrs);
        }
  #endif
 -      return dma_common_get_sgtable(dev, sgt, cpu_addr, handle, size);
 +      return dma_common_get_sgtable(dev, sgt, cpu_addr, handle, size, attrs);
  }
  
  static int xen_swiotlb_mapping_error(struct device *dev, dma_addr_t dma_addr)