>> + if (index == VFIO_PCI_BAR2_REGION_INDEX) { >> + if (!nvdev->opregion) { >> + nvdev->opregion = memremap(nvdev->hpa, nvdev->mem_length, MEMREMAP_WB); >> + if (!nvdev->opregion) >> + return -ENOMEM; >> + } > > [AW] Seems like this would be susceptible to concurrent accesses causing > duplicate mappings. > > [JG] Needs some kind of locking on opregion Right, will add a new lock item in nvdev to control the access to opregion/memmap. Please let me know if it is preferable to do memremap in open_device instead of read/write.