A bug was reported to me regarding mmaping of BAR0 in ivshmem. Indeed the mmap fails. This bug will affect those using the ivshmem server as BAR0 contains the registers for sending and receiving interrupts. It does not affect those mapping just the shared memory region.
commit 7314e613d5ff9f0934f7a0f74ed7973b903315d1
Date: Tue Oct 29 10:21:34 2013 -0700
Fix a few incorrectly checked [io_]remap_pfn_range() calls
Nico Golde reports a few straggling uses of [io_]remap_pfn_range() that
really should use the vm_iomap_memory() helper. This trivially converts
two of them to the helper, and comments about why the third one really
needs to continue to use remap_pfn_range(), and adds the missing size
check.
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index ba47563..0e808cf 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -642,16 +642,29 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
{
struct uio_device *idev = vma->vm_private_data;
int mi = uio_find_mem_index(vma);
+ struct uio_mem *mem;
if (mi < 0)
return -EINVAL;
+ mem = idev->info->mem + mi;
- vma->vm_ops = &uio_physical_vm_ops;
+ if (vma->vm_end - vma->vm_start > mem->size)
+ return -EINVAL;
Finally, I apologize for not catching this bug earlier. It's an effect of not having the uio driver in the kernel. To avoid this in future, I will work to get the UIO ivshmem driver into the kernel.