My device exposes it's memory (~512MB) via it's BAR. My goal is to map and pass virtual address to user whenever user wants to allocate device memory to r/w directly (No cache).
In preparehardware, I get the physical address from the BAR, and pass it to MmMapIoSpace(). This maps given physical address range to non-paged system space and returns virtual address.
In an IOCTL, I do the followings
a) Pass that virtual address with user specified size to get a MDL using IoAllocateMdl().
b) To prepare the MDL for non-paged virtual memory, call MmBuildMdlForNonPagedPool().
c) On success, call MmMapLockedPagesSpecifyCache() to get a virtual address
So that I can pass it to user.
Though I could successfully get mdl from IoAllocateMdl(), my driver bugchecks (0x50 - PAGE_FAULT_IN_NONPAGED_AREA, read operation) at MmBuildMdlForNonPagedPool(). Seems like some non-paged space got freed. Do I have to add any additional work after calling MmMapIoSpace()? I thought this should already map the whole physical space to non-paged system space and keep until we explicitly unmap.
What am I missing here? Any help would be greatly appreciated.
Thanks in advance,
It looks like you're new here. If you want to get involved, click one of these buttons!
|Upcoming OSR Seminars|
|Writing WDF Drivers||21 Oct 2019||OSR Seminar Space & ONLINE|
|Internals & Software Drivers||18 Nov 2019||Dulles, VA|
|Kernel Debugging||30 Mar 2020||OSR Seminar Space|
|Developing Minifilters||27 Apr 2020||OSR Seminar Space & ONLINE|