Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

swiotlb-xen: use vmalloc_to_page on vmalloc virt addresses

xen_alloc_coherent_pages might return pages for which virt_to_phys and
virt_to_page don't work, e.g. ioremap'ed pages.

So in xen_swiotlb_free_coherent we can't assume that virt_to_page works.
Instead add a is_vmalloc_addr check and use vmalloc_to_page on vmalloc
virt addresses.

This patch fixes the following crash at boot on RPi4 (the underlying
issue is not RPi4 specific):
https://marc.info/?l=xen-devel&m=158862573216800

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Tested-by: Corey Minyard <cminyard@mvista.com>
Tested-by: Roman Shaposhnik <roman@zededa.com>
Link: https://lore.kernel.org/r/20200710223427.6897-1-sstabellini@kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Boris Ostrovsky and committed by
Juergen Gross
8b1e868f f5ec6723

+7 -1
+7 -1
drivers/xen/swiotlb-xen.c
··· 335 335 int order = get_order(size); 336 336 phys_addr_t phys; 337 337 u64 dma_mask = DMA_BIT_MASK(32); 338 + struct page *page; 338 339 339 340 if (hwdev && hwdev->coherent_dma_mask) 340 341 dma_mask = hwdev->coherent_dma_mask; ··· 347 346 /* Convert the size to actually allocated. */ 348 347 size = 1UL << (order + XEN_PAGE_SHIFT); 349 348 349 + if (is_vmalloc_addr(vaddr)) 350 + page = vmalloc_to_page(vaddr); 351 + else 352 + page = virt_to_page(vaddr); 353 + 350 354 if (!WARN_ON((dev_addr + size - 1 > dma_mask) || 351 355 range_straddles_page_boundary(phys, size)) && 352 - TestClearPageXenRemapped(virt_to_page(vaddr))) 356 + TestClearPageXenRemapped(page)) 353 357 xen_destroy_contiguous_region(phys, order); 354 358 355 359 xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys, attrs);