dma-remap: align the size in dma_common_*_remap()
authorEric Auger <eric.auger@redhat.com>
Tue, 23 Jun 2020 12:07:55 +0000 (14:07 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 23 Jun 2020 12:14:41 +0000 (14:14 +0200)
Running a guest with a virtio-iommu protecting virtio devices
is broken since commit 515e5b6d90d4 ("dma-mapping: use vmap insted
of reimplementing it"). Before the conversion, the size was
page aligned in __get_vm_area_node(). Doing so fixes the
regression.

Fixes: 515e5b6d90d4 ("dma-mapping: use vmap insted of reimplementing it")
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/remap.c

index e739a6eea6e748258523c86b817040ce437510cf..78b23f089cf1c2eb0f50201228bff083a58c3889 100644 (file)
@@ -24,7 +24,8 @@ void *dma_common_pages_remap(struct page **pages, size_t size,
 {
        void *vaddr;
 
-       vaddr = vmap(pages, size >> PAGE_SHIFT, VM_DMA_COHERENT, prot);
+       vaddr = vmap(pages, PAGE_ALIGN(size) >> PAGE_SHIFT,
+                    VM_DMA_COHERENT, prot);
        if (vaddr)
                find_vm_area(vaddr)->pages = pages;
        return vaddr;
@@ -37,7 +38,7 @@ void *dma_common_pages_remap(struct page **pages, size_t size,
 void *dma_common_contiguous_remap(struct page *page, size_t size,
                        pgprot_t prot, const void *caller)
 {
-       int count = size >> PAGE_SHIFT;
+       int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
        struct page **pages;
        void *vaddr;
        int i;