Discussion:
MmMapLockedPagesSpecifyCache in XP and Server2003
(too old to reply)
ysht
2010-07-05 08:11:45 UTC
Permalink
Hi,
I'm Yot and I'm writing a driver.

Here is my driver code:
===
DeviceExtension->SystemVirtualAddress = ExAllocatePool( NonPagedPool , Size6M );
DeviceExtension->Mdl = IoAllocateMdl( DeviceExtension->SystemVirtualAddress,
Size6M, FALSE, FALSE, NULL );
DeviceExtension->UserVirtualAddress = MmMapLockedPagesSpecifyCache(
DeviceExtension->Mdl,
UserMode, MmNonCached, NULL,
FALSE, NormalPagePriority);
===

This code code works well in WindowsXP Professional Version 2002 SP3.
(MmMapLockedPagesSpecifyCache returns non-NULL value.)

But in Windows Server 2003 R2 Standard Edition SP3,
MmMapLockedPagesSpecifyCache returns NULL.

Therefore I use WindowsXP,but want to actually Windows Server 2003 now.

Can anyone provide suggestions ?
Any help or guidance would be appreciated.

Thanks!
Maxim S. Shatskih
2010-07-05 19:32:01 UTC
Permalink
Post by ysht
But in Windows Server 2003 R2 Standard Edition SP3,
MmMapLockedPagesSpecifyCache returns NULL.
So what? you're out of system PTEs, just handle such a thing properly.
--
Maxim S. Shatskih
Windows DDK MVP
***@storagecraft.com
http://www.storagecraft.com
ysht
2010-07-06 02:44:21 UTC
Permalink
Thanks,Maxim.

Could you answer one more ?

Did you mean that MmMapLockedPagesSpecificCache failed
(returned NULL) for lack of system PTEs ?


Yot.
Post by Maxim S. Shatskih
Post by ysht
But in Windows Server 2003 R2 Standard Edition SP3,
MmMapLockedPagesSpecifyCache returns NULL.
So what? you're out of system PTEs, just handle such a thing properly.
Pavel Lebedinsky [MSFT]
2010-07-06 04:56:08 UTC
Permalink
Post by ysht
DeviceExtension->SystemVirtualAddress = ExAllocatePool( NonPagedPool , Size6M );
DeviceExtension->Mdl = IoAllocateMdl(
DeviceExtension->SystemVirtualAddress,
Size6M, FALSE, FALSE, NULL );
DeviceExtension->UserVirtualAddress = MmMapLockedPagesSpecifyCache(
DeviceExtension->Mdl,
UserMode, MmNonCached, NULL,
FALSE, NormalPagePriority);
===
This code code works well in WindowsXP Professional Version 2002 SP3.
(MmMapLockedPagesSpecifyCache returns non-NULL value.)
But in Windows Server 2003 R2 Standard Edition SP3,
MmMapLockedPagesSpecifyCache returns NULL.
Two problems here:

1. You need to call MmBuildMdlForNonPagedPool before attempting to
map the pages.

2. Nonpaged pool memory is fully cached, and mapping it as MmNonCached
is not allowed. You need to either a) use MmCached when mapping the MDL,
or b) if you really need a non-cached mapping, use
MmAllocatePagesForMdlEx (instead of ExAllocatePool) to allocate pages
with the MmNonCached attribute.
--
Pavel Lebedinsky/Windows Fundamentals Test
This posting is provided "AS IS" with no warranties, and confers no rights.
ysht
2010-07-06 06:06:05 UTC
Permalink
Pavel,Thanks a lot.

I will take your advice into account and try it.

Thank you very much.
(Pavel-san,domo arigatou.)

Yot.
Post by Pavel Lebedinsky [MSFT]
Post by ysht
DeviceExtension->SystemVirtualAddress = ExAllocatePool( NonPagedPool , Size6M );
DeviceExtension->Mdl = IoAllocateMdl(
DeviceExtension->SystemVirtualAddress,
Size6M, FALSE, FALSE, NULL );
DeviceExtension->UserVirtualAddress = MmMapLockedPagesSpecifyCache(
DeviceExtension->Mdl,
UserMode, MmNonCached, NULL,
FALSE, NormalPagePriority);
===
This code code works well in WindowsXP Professional Version 2002 SP3.
(MmMapLockedPagesSpecifyCache returns non-NULL value.)
But in Windows Server 2003 R2 Standard Edition SP3,
MmMapLockedPagesSpecifyCache returns NULL.
1. You need to call MmBuildMdlForNonPagedPool before attempting to
map the pages.
2. Nonpaged pool memory is fully cached, and mapping it as MmNonCached
is not allowed. You need to either a) use MmCached when mapping the MDL,
or b) if you really need a non-cached mapping, use
MmAllocatePagesForMdlEx (instead of ExAllocatePool) to allocate pages
with the MmNonCached attribute.
Loading...