Skip to contentSkip to conversation

dma-remap: Align the size in dma_common_*_remap()

PATCH In review Eric Auger 2 participants 2 messages Jun 23, 2020 DMA mapping helpers

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH v2 1/1 dma-remap: Align the size in dma_common_*_remap()

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")

---

v1 -> v2:
- fix line over 80 characters

---
 kernel/dma/remap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/dma/remap.c +3 -2
index e739a6eea6e7..78b23f089cf1 100644
@@ -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;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 8 lines · Eric Auger

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")

Thanks,

I've applied this locally, waiting for git.infradead.org to be back up.