locking user allocated buffer specifying a physical adress range

Is it possible to lock a user allocated buffer in kernel with specifying a physical address range (e.g. locking a user allocated buffer so that that the physical pages reside in the lower 4GB of the pyhsical adress range)?

Thanks,

StefanF

No it is not. Think about it, the user already allocated the buffer so
there are physical pages behind it when it comes to your driver, you
cannot after the fact specify that the pages need to be in a certain
range.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@stfunk.de” wrote in message news:xxxxx@ntdev:

> Is it possible to lock a user allocated buffer in kernel with specifying a physical address range (e.g. locking a user allocated buffer so that that the physical pages reside in the lower 4GB of the pyhsical adress range)?
>
> Thanks,
>
> StefanF

wrote in message news:xxxxx@ntdev…
> Is it possible to lock a user allocated buffer in kernel with specifying a
> physical address range (e.g. locking a user allocated buffer so that that
> the physical pages reside in the lower 4GB of the pyhsical adress range)?
>
> Thanks,
>
> StefanF

No, you cannot force physical page addresses of user allocated buffer be
under 4 GB.
But the system-provided DMA bounce buffers (a.k.a. mapping registers) can do
just what you want.

–pa

You’re doing it wrong. Instead, call IoAllocateDmaAdapter with arguments that tell that you can’t do DMA on addresses above 4GB (that means don’t set “64 bit address supported” flag).

>

Is it possible to lock a user allocated buffer in kernel with
specifying a
physical address range (e.g. locking a user allocated buffer so that
that the
physical pages reside in the lower 4GB of the pyhsical adress range)?

The user has already allocated the memory and it is already either
mapped to a physical page or swapped out to disk. The only way to do it
would be to force the kernel to copy the underlying page to another
physical address and remap the va to that (eg swap it out and back in
again). There is no guarantee that your user buffer has 100% use of that
page either - there might be other data on it.

Any solution you come up with will be harder to implement and less
efficient than simply copying the data to/from another buffer under 4GB,
and if you are wanting to do this for DMA reasons then Windows already
takes care of this for you in the best way possible.

James

> Is it possible to lock a user allocated buffer in kernel with specifying a physical address range (e.g.

locking a user allocated buffer so that that the physical pages reside in the lower 4GB of the pyhsical
adress range)?

Impossible.

That’s why Windows has a rich set of DMA APIs.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com