summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-10-23 11:02:05 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-23 11:02:05 +0100
commita4648c75b95d972e08f84529c4e8ee4f81cf09e4 (patch)
tree219a95d511c41668c2cee9e5a07c46866e39dfe4
parent58a0228707870c8330917f919804986855443a19 (diff)
parent7250f422da0480d8512b756640f131b9b893ccda (diff)
downloadlinux-a4648c75b95d972e08f84529c4e8ee4f81cf09e4.tar.bz2
Merge branch 'stable/for-linus-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb
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
-rw-r--r--drivers/xen/swiotlb-xen.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 28819a0e61d0..f5c1af4ce9ab 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -303,6 +303,9 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
*/
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 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
* 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);