Regarding MmGetSystemAddressForMdlSafe

Hello,

I understand that MmGetSystemAddressForMdlSafe maps
the physical pages described by a given MDL into
system space & returns virtual address. Is it required
to unmap these pages, before you call IoFreeMdl? If
so, how do you do it? Who otherwise, unmaps the
pagetable entries created by this new system address?

Sharmila Panse


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

MmUnlockPages does the unmap automatically.

For MDLs created from nonpaged pool, unmap is not needed, and
MmGetSystemAddressForMdlSafe is a no-op.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Sharmila Panse”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, April 27, 2005 5:59 PM
Subject: [ntdev] Regarding MmGetSystemAddressForMdlSafe

> Hello,
>
> I understand that MmGetSystemAddressForMdlSafe maps
> the physical pages described by a given MDL into
> system space & returns virtual address. Is it required
> to unmap these pages, before you call IoFreeMdl? If
> so, how do you do it? Who otherwise, unmaps the
> pagetable entries created by this new system address?
>
> Sharmila Panse
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Sharmila Panse wrote:

Hello,

I understand that MmGetSystemAddressForMdlSafe maps
the physical pages described by a given MDL into
system space & returns virtual address. Is it required
to unmap these pages, before you call IoFreeMdl? If
so, how do you do it? Who otherwise, unmaps the
pagetable entries created by this new system address?

Sharmila Panse


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

MmGetSystemAddressForMdl(Safe) is a macro which is defined as

#define MmGetSystemAddressForMdlSafe(MDL, PRIORITY) \
(((MDL)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \
MDL_SOURCE_IS_NONPAGED_POOL)) ? \
((MDL)->MappedSystemVa) : \
(MmMapLockedPagesSpecifyCache((MDL), \
KernelMode, \
MmCached, \
NULL, \
FALSE, \
(PRIORITY))))

so, you need to unmap locked pages before you free the mdl using
MmUnmapLockedPages. Beware that if you’re using MmProbeAndLockPages
before this, this requires its counterpart MmUnlockPages which calls
itself MmUnmapLockedPages (which is not documented in DDK, afaik). So,
if you call MmProbeAndLockPages, just call MmUnlockPages and that’s all…

regards,
valerio