Merge tag 'for-linus-5.3a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 2 Aug 2019 22:26:48 +0000 (15:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 2 Aug 2019 22:26:48 +0000 (15:26 -0700)
Pull xen fixes from Juergen Gross:

 - a small cleanup

 - a fix for a build error on ARM with some configs

 - a fix of a patch for the Xen gntdev driver

 - three patches for fixing a potential problem in the swiotlb-xen
   driver which Konrad was fine with me carrying them through the Xen
   tree

* tag 'for-linus-5.3a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen/swiotlb: remember having called xen_create_contiguous_region()
  xen/swiotlb: simplify range_straddles_page_boundary()
  xen/swiotlb: fix condition for calling xen_destroy_contiguous_region()
  xen: avoid link error on ARM
  xen/gntdev.c: Replace vm_map_pages() with vm_map_pages_zero()
  xen/pciback: remove set but not used variable 'old_state'

1  2 
drivers/xen/swiotlb-xen.c

@@@ -83,34 -83,18 +83,18 @@@ static inline dma_addr_t xen_virt_to_bu
        return xen_phys_to_bus(virt_to_phys(address));
  }
  
- static int check_pages_physically_contiguous(unsigned long xen_pfn,
-                                            unsigned int offset,
-                                            size_t length)
+ static inline int range_straddles_page_boundary(phys_addr_t p, size_t size)
  {
-       unsigned long next_bfn;
-       int i;
-       int nr_pages;
+       unsigned long next_bfn, xen_pfn = XEN_PFN_DOWN(p);
+       unsigned int i, nr_pages = XEN_PFN_UP(xen_offset_in_page(p) + size);
  
        next_bfn = pfn_to_bfn(xen_pfn);
-       nr_pages = (offset + length + XEN_PAGE_SIZE-1) >> XEN_PAGE_SHIFT;
  
-       for (i = 1; i < nr_pages; i++) {
+       for (i = 1; i < nr_pages; i++)
                if (pfn_to_bfn(++xen_pfn) != ++next_bfn)
-                       return 0;
-       }
-       return 1;
- }
+                       return 1;
  
- static inline int range_straddles_page_boundary(phys_addr_t p, size_t size)
- {
-       unsigned long xen_pfn = XEN_PFN_DOWN(p);
-       unsigned int offset = p & ~XEN_PAGE_MASK;
-       if (offset + size <= XEN_PAGE_SIZE)
-               return 0;
-       if (check_pages_physically_contiguous(xen_pfn, offset, size))
-               return 0;
-       return 1;
+       return 0;
  }
  
  static int is_xen_swiotlb_buffer(dma_addr_t dma_addr)
@@@ -338,6 -322,7 +322,7 @@@ xen_swiotlb_alloc_coherent(struct devic
                        xen_free_coherent_pages(hwdev, size, ret, (dma_addr_t)phys, attrs);
                        return NULL;
                }
+               SetPageXenRemapped(virt_to_page(ret));
        }
        memset(ret, 0, size);
        return ret;
@@@ -361,8 -346,9 +346,9 @@@ xen_swiotlb_free_coherent(struct devic
        /* 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))
+       if (!WARN_ON((dev_addr + size - 1 > dma_mask) ||
+                    range_straddles_page_boundary(phys, size)) &&
+           TestClearPageXenRemapped(virt_to_page(vaddr)))
                xen_destroy_contiguous_region(phys, order);
  
        xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs);
@@@ -402,7 -388,7 +388,7 @@@ static dma_addr_t xen_swiotlb_map_page(
  
        map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir,
                                     attrs);
 -      if (map == DMA_MAPPING_ERROR)
 +      if (map == (phys_addr_t)DMA_MAPPING_ERROR)
                return DMA_MAPPING_ERROR;
  
        dev_addr = xen_phys_to_bus(map);