Re: MmGetSystemAddressForMdlSafe
- From: "anton bassov" <soviet_bloke@xxxxxxxxxxx>
- Date: 14 Jul 2006 16:05:51 -0700
Hi mate
What's better about MmGetPhysicalAddress + MmMapIoSpace that makes you
mention it as a solution (before then pointing out that it's not going to
help)?
The only reason why I mentioned MmGetPhysicalAddress + MmMapIoSpace is
because
the OP asked if there is any alternative to
MmGetSystemAddressForMdlSafe().Therefore, I showed him that there is
one more way to run into exactly the same problem that he had described
- as they say, there is more than one way to skin a cat
The call to MmGetSystemAddressForMdlSafe doesn't allocate memory from
non-paged pool".
Both MmGetSystemAddressForMdlSafe() and MmMapIoSpace() map pages to
non-paged memory. It is understandable that there is no need to
allocate new pages of memory once we just map the existing ones into
the kernel address space. Therefore, I should have said "maps to
non-paged area", rather than "allocates from non-paged pool" - I have
expressed myself the wrong way, I admit. Non-paged area starts at
0xEB000000 and ends at 0xFFB00000. Therefore, if the system fails to
find contigious space in this range that is sufficient for mapping MDL,
the call fails. This is what I meant to say
I would say that the problem may arise only if you map more than 4MB of
space, i.e. more than one page table can map (in such case the system
has to find adjacent free
entries in page directories)
Anton Bassov
peterwie@xxxxxxxxxxxxxxxxxxxx wrote:
What's better about MmGetPhysicalAddress + MmMapIoSpace that makes you
mention it as a solution (before then pointing out that it's not going to
help)?
The call to MmGetSystemAddressForMdlSafe doesn't allocate memory from
non-paged pool". It's failing because there isn't a contiguous range of
free kernel VA PTEs with which the pages can be mapped.
-p
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"anton bassov" <soviet_bloke@xxxxxxxxxxx> wrote in message
news:1152672496.895027.235370@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi mate
If you are not happy with MmGetSystemAddressForMdlSafe(), you can try
MmGetPhysicalAddress() - MmMapIoSpace() sequence in order to map
user-mode address to the kernel address space. Just keep in mind that
the page, corresponding to the virtual address in question, has to be
present in RAM at the time of your call to MmGetPhysicalAddress().
However, this hardly solves your problem, because both MmMapIoSpace()
and MmGetSystemAddressForMdlSafe() allocate memory from non-paged pool.
Therefore, if your buffer is large, these calls may fail (in fact, I
believe your call to MmGetSystemAddressForMdlSafe() fails just because
there is not enough non-paged memory to map your buffer) .
Actually, as long as you access memory in the context of the process
where user-mode address resides and your code runs at
IRQL<DISPATCH_LEVEL, you can access it directly from the kernel mode
(this is how METHOD_NEITHER works). Are you 100% sure you need to map
memory to the kernel address space, in the first place????? If you
don't mind, could you please tell us a little bit more about your
driver and your objectives, so that we can try to find an optimal
solution to your problem
Anton Bassov
Michael wrote:
Hi
We are using MmGetSystemAddressForMdlSafe function to convert address
from user space to kernel space, we call it with priority parameter set
to High.
When we call this function is sometimes fails and returns NULL.
What can be the reason for this function to fail?
Do i need to lock and MDL before calling this function?
Do i need to unlock the MDL after calling this function?
Is there any other way to convert user mode address to kernel mode
address?
Thanks,
Michael
.
- References:
- Re: MmGetSystemAddressForMdlSafe
- From: anton bassov
- Re: MmGetSystemAddressForMdlSafe
- From: peterwie
- Re: MmGetSystemAddressForMdlSafe
- Prev by Date: Re: Question about sdelete from sysinternals
- Next by Date: Re: Question about FILE_OBJECT
- Previous by thread: Re: MmGetSystemAddressForMdlSafe
- Next by thread: Executing CPUID instruction question
- Index(es):
Relevant Pages
|