MmMapLockedPagesSpecifyCache on Microsoft Vista Beta 2

Hi,

We have a “virtual video miniport driver” basically implemented as mirror driver. It is working fine on Windows 2K and XP. When we install the same on Microsoft Vista beta 2, the installation is crashing.

After setting up the windbg we found that “FindAdapter” is crashing.

We are allocating a huge memory of RAM as the video buffer and locking the pages using MmMapLockedPagesSpecifyCache in the FindAdapter routing, following is the code snippet:

pFrameBuffer = ExAllocatePoolWithTag(NonPagedPool, VMaxFrameBufferSize, …);
pVideoMdl = IoAllocateMdl(pFrameBuffer, VMaxFrameBufferSize, …);
MmBuildMdlForNonPagedPool(pVideoMdl );
pVFrameBuffer = MmMapLockedPagesSpecifyCache((PMDL)pVideoMdl, KernelMode, MmCached, NULL,
FALSE, NormalPagePriority);

This works fine on 2K and Xp, no issues at all.

But on Vista Beta 2, the same thing is not working, the MmMapLockedPagesSpecifyCache is giving a following bug check:

Assertion failure - code c0000420 (first chance)
nt!MmMapLockedPagesSpecifyCache+0x5f:
82496a81 cd2c int 2Ch
kd> c

Can some one please help out in this as to why is this happening on vista. Any sugestions are welcome.

Thanks,
Murali

Worst case you could disassemble the MMLPSC to see how it got to where
it’s at.

Just out of curiosity, why double mapping is needed in the first place?
Pool memory by default is cached.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-258871-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, August 10, 2006 6:48 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] MmMapLockedPagesSpecifyCache on Microsoft Vista Beta
2

Hi,

We have a “virtual video miniport driver” basically implemented as
mirror
driver. It is working fine on Windows 2K and XP. When we install the
same
on Microsoft Vista beta 2, the installation is crashing.

After setting up the windbg we found that “FindAdapter” is crashing.

We are allocating a huge memory of RAM as the video buffer and locking
the
pages using MmMapLockedPagesSpecifyCache in the FindAdapter routing,
following is the code snippet:

pFrameBuffer = ExAllocatePoolWithTag(NonPagedPool,
VMaxFrameBufferSize, …);
pVideoMdl = IoAllocateMdl(pFrameBuffer, VMaxFrameBufferSize, …);
MmBuildMdlForNonPagedPool(pVideoMdl );
pVFrameBuffer = MmMapLockedPagesSpecifyCache((PMDL)pVideoMdl,
KernelMode, MmCached,
NULL,
FALSE,
NormalPagePriority);

This works fine on 2K and Xp, no issues at all.

But on Vista Beta 2, the same thing is not working, the
MmMapLockedPagesSpecifyCache is giving a following bug check:

Assertion failure - code c0000420 (first chance)
nt!MmMapLockedPagesSpecifyCache+0x5f:
82496a81 cd2c int 2Ch
kd> c

Can some one please help out in this as to why is this happening on
vista.
Any sugestions are welcome.

Thanks,
Murali


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Interesting. Vista’s added a LOT of additional ASSERTs to many kernel-level functions.

In this case, I’d guess the assert you’re getting is the result of attempting to map an MDL that describes non-paged pool into kernel virtual address space.

Very interesting indeed. Personally, I wouldn’t have expected this… but there you have it.

The other thing that’s interesting to note (well, *I* think it’s interesting in any case) is the move from ASSERTs that only fire in the checked build, to ASSERTs that fire “INT 2C” in the free build (as you show in your disassembly). See the macro NT_ASSERT in wdm.h in the Vista WDK.

Peter
OSR

(following-up my own post… Why can’t you edit your post in this forum?? arrrghh…)

Checking further, it seems it has NEVER been correct (legal, allowed) to use MmMapLockedPagesSpecifyCache to map a block of NonPagedPool into (a second) kernel virtual address space. However, prior to Vista, you would only discover this if you ran your driver on the checked build of Windows (you DID test your driver on the checked build before releasing it, right??? No???).

Interesting, no??

Peter
OSR

xxxxx@osr.com wrote:

(following-up my own post… Why can’t you edit your post in this forum?? arrrghh…)

Because it’s not a “forum”. It’s a mailing list. When you send a
message, it’s gone, gone, gone.

There happens to be an archive of the mailing list that is made to LOOK
like a web forum, but it ain’t so.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> ----------

From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Tim Roberts[SMTP:xxxxx@probo.com]
Reply To: Windows System Software Devs Interest List
Sent: Friday, August 11, 2006 6:48 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] MmMapLockedPagesSpecifyCache on Microsoft Vista Beta 2

xxxxx@osr.com wrote:

>(following-up my own post… Why can’t you edit your post in this forum?? arrrghh…)
>
>

Because it’s not a “forum”. It’s a mailing list. When you send a
message, it’s gone, gone, gone.

There happens to be an archive of the mailing list that is made to LOOK
like a web forum, but it ain’t so.

Never ask rhetorical question or somebody can answer it :wink:

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

Michal Vodicka wrote:

>xxxxx@osr.com wrote:
>
>
>>(following-up my own post… Why can’t you edit your post in this forum?? arrrghh…)
>>
>>
>Because it’s not a “forum”. It’s a mailing list. When you send a
>message, it’s gone, gone, gone.
>
>There happens to be an archive of the mailing list that is made to LOOK
>like a web forum, but it ain’t so.
>
>
Never ask rhetorical question or somebody can answer it :wink:

Now I wish I had taken 10 seconds to notice the author of the original
comment. Ah, well, maybe a lesson has been learned today.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> Checking further, it seems it has NEVER been correct (legal, allowed) to

use MmMapLockedPagesSpecifyCache to map a block of NonPagedPool into (a
second) kernel virtual address space. However, prior to Vista, you would
only discover this if you ran your driver on the checked build of Windows
(you DID test your driver on the checked build before releasing it,
right??? No???).

Interesting, no??

Peter
OSR

  1. It is not interesting, it is irritating! I’ve spent a lot of time figuring
    out this “feature.” Why it is not allowed? What is wrong with that? The DDK
    documentation doesn’t say anything about this restriction. It creates
    problems when one wants to have dynamically generated code in the kernel
    space and to use MmProtectMdlSystemAddress to mark NonPagedPool pages as
    executable.

  2. The (not fully tested for this specific case) workaround: call
    MmProbeAndLockPages on the (already locked!) block of NonPagedPool and use
    the resulting MDL for MmMapLockedPagesSpecifyCache.

Dmitriy Budko
VMware

I did comment out the MmMapLockedPagesSpecifyCache call for the non paged pool and the installation is going fine now. But now clicking on the “Display Settings” I am getting the following error “The currently selected graphics display driver cannot be used. It was written for a previous version of Windows, and is no longer compatible with this version of windows. The system has been started using the default VGA driver. Please contact your hardware manufacturer to get an updated driver, or select one of the Microsoft provided drivers”.

I found an article http://support.microsoft.com/?kbid=891387 which has an fix for XP for such errors. Is there a fix for Vista too?

One more thing there is a display driver model change in Vista as compared to XP/2K, will I have to reimplement the drivers for the new model?

> One more thing there is a display driver model change in Vista as
compared

to XP/2K, will I have to reimplement the drivers for the new model?

[CG] Oh yes. The vista model is completely different from the xp/2k one.
It was called LDDM (longhorn display driver model) at the time I worked
for a major graphics chip company. If you can live with the XPDM, do
bother the LDDM unless you are writing h/w driver for high performance
graphics chips.

Calvin Guan (DDK MVP)
Sr. Staff Engineer
NetXtreme NTX Miniport
Broadcom Corporation
Connecting Everything(r)

> MmBuildMdlForNonPagedPool(pVideoMdl );

pVFrameBuffer = MmMapLockedPagesSpecifyCache((PMDL)pVideoMdl,

No need to do this. You already have the nonpaged address of this memory area.

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

> In this case, I’d guess the assert you’re getting is the result of attempting
to map

an MDL that describes non-paged pool into kernel virtual address space.

Yes, absolutely useless operation. Just use the VA from which the MDL was built
in this case.

Also - MmGetSystemAddressForMdlSafe will be a no-op for such a MDL and just
return the VA mentioned above.

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