Skip to contentSkip to conversation

vdpa: fix caching attributes of MMIO regions by setting them explicitly

PATCH In review Kommula Shiva Shankar 3 participants 3 messages Dec 16, 2025 – Dec 19, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vdpa: fix caching attributes of MMIO regions by setting them explicitly

Explicitly set non-cached caching attributes for MMIO regions. Default write-back mode can cause CPU to cache device memory, causing invalid reads and unpredictable behavior.

Invalid read and write issues were observed on ARM64 when mapping the notification area to userspace via mmap.

---
 drivers/vhost/vdpa.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vhost/vdpa.c +1 -0
index 05a481e4c385..b0179e8567ab 100644
@@ -1527,6 +1527,7 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)
 	if (vma->vm_end - vma->vm_start != notify.size)
 		return -ENOTSUPP;
 
+	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 	vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP);
 	vma->vm_ops = &vhost_vdpa_vm_ops;
 	return 0;
Signature · 1 line
2.48.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Kommula Shiva Shankar

Explicitly set non-cached caching attributes for MMIO regions. Default write-back mode can cause CPU to cache device memory, causing invalid reads and unpredictable behavior.

Invalid read and write issues were observed on ARM64 when mapping the notification area to userspace via mmap.

---

Btw, I think this should go with Michael's vhost tree.

Thanks

maintainer
#2 lore raw
In reply to Kommula Shiva Shankar
Quoted 8 lines · Kommula Shiva Shankar

Explicitly set non-cached caching attributes for MMIO regions. Default write-back mode can cause CPU to cache device memory, causing invalid reads and unpredictable behavior.

Invalid read and write issues were observed on ARM64 when mapping the notification area to userspace via mmap.

@Micheal: despite the net-next prefix, I assume this patch will go via your tree, as it looks unrelated from networking.

Cheers,

Paolo