kvm-guest-drivers-windows
kvm-guest-drivers-windows copied to clipboard
IVSHMEM: Allow multiple processes to map the same shared memory
Previously there was a shmemMap
member inside the DEVICE_CONTEXT
which effectively restricted the mapping to a single process only. I've moved that pointer (that holds the virtual address of the mapping in the usermode process) to a new FILE_CONTEXT
struct. For each CreateFile
call in usermode, a WDFFILEOBJECT
is created in the kernel. The WDFDEVICE
EvtDeviceFileCreate
callback then allocates the file context in the file object.
When a usermode application requests a map via ioctl, we extract the file object (and then file context) from the WDFREQUEST
. Instead of updating the shmemMap
member in the device context (this was before this pull request), now we update that address in the file context, which is unique to each handle to the driver.
With these changes, one or more applications can map the same memory into their virtual address space. One application could even map the region twice, but only from two driver handles (two calls to CreateFile
).
There are line-ending issues in the device.c. It will be great if you fix them too. Thanks.
@polloloco Are you planning to fix the comments?
Thanks, Yan.