How to prevent physical to virtual address mapping from changing?

> @anton_bassov said: > Therefore, someone (I think it was Mr.Noone) pointed out to him that a call MmMapLockedPagesSpecifyCache() on the existing userland address was bound to fail. Thanks, that may be a dead end then. We will do a quick try on this tomorrow. > How may your current problem be possibly related to caching type that is specified in PTE??? I don’t know… Peter eluded that we may have a weird problem with Windows Cache Manager, I am not familiar with that area and was wondering if the same problem could happen even if we change from CreateFileMapping to the approach I described above What’s PTE?

> @MBond2 said: > If my problem is relevant for your problem, I’ll continue to tell you about my progress in the hope that it helps you. Thank you for your replies @MBond2. Please go ahead to describe your progress if possible… I am particularly interested in the part to allocate non paged large memory to allow accesses from the card, the driver and multiple apps. The user cases at upper layers doesn’t really matter.

Yes… I do suspect some sort of strange Cache Manager edge condition. But I’m not sure. I wouldn’t write the code the way you did… I would either (a) allocate the memory in the driver with MmAllocatePagesForMdlEx and map them back to the user address space, or (b) I would allocate the memory with VirtualAlloc in user-space, pin it in the driver, and it map it into the other (non-allocating) app’s address spaces in the driver.

This whole problem also begs the question of how to handle security issues… such as when an app calls DuplicateHandle on the handle that’s used to map the memory.

I reject the idea that, outside the context of the CC not being aware that a page is in use by a given UVA space or an odd OS bug, somehow the UVA to PA mapping arbitrarily changes. Like I said… one does not have a pointer (UVA) that points to something one minute… and then that pointer “goes bad” the next minute. If this is happening, it’s GOT to be happening because something is being mishandled in the app or in the driver. Some assumption is probably being made that was never strictly technically/architecturally correct, but is no longer the way things work.

But this problem needs focused work and analysis. I stepped out because this discussion got away from me. Sorry… there’s only so much I can do on a forum.

Peter

1 Like

Thanks Peter, your insights are very much appreciated.

Hi all,

We just completed an successful over-the-weekend test on a Server 2016 machine but used MMAgent to disable all the following OS features:

  • ApplicationLaunchPrefetching
  • ApplicationPreLaunch
  • OperationAPI
  • PageCombining
  • MemoryCompression
  • CimSession <CimSession>
  • ThrottleLimit
  • AsJob

Memory Management Agent was introduced with Windows 8/2012, our upgrade path happens to cross it.

Not sure which ones are more relevant to the problem… we could use binary search to find it out eventually, but thought you might have some insights.

Page Combing and Memory Compression look the most suspicious to me… any suggestions?

Thanks,
Hua

Wow. I had never even heard of that applet.

Thanks. I learned something today. I’m not sure how I’ll use it, by I did learn something.

Peter

1 Like

Well, is my problem relevant to your problem? How are you planning to synchronize access to the data in this shared memory region?