]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Make sure Mdl->StartVa is set by __AllocatePages()
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 25 Jan 2018 13:37:22 +0000 (13:37 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 25 Jan 2018 13:40:59 +0000 (13:40 +0000)
wdm.h carries this comment:

// Notice that while in the context of the subject thread, the base virtual
// address of a buffer mapped by an MDL may be referenced using the
// following:
//
//      Mdl->StartVa | Mdl->ByteOffset
//

Hence it is important that a mapped MDL has a valid StartVa field as well
as a valid MappedSystemVa field. Unfortunately, for reasons best known to
Microsoft, MmMapLockedPagesSpecifyCache() does not ensure this is the
case, so it needs to be fixed up by __AllocatePages() itself.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/common/util.h

index 93838171e62fc85815969e52a059c9b732027928..b303bbc0a9da929a2de996c83a8aa3cbf2d78c56 100644 (file)
@@ -219,7 +219,11 @@ __AllocatePages(
     if (MdlMappedSystemVa == NULL)
         goto fail3;
 
-    ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa);
+    Mdl->StartVa = PAGE_ALIGN(MdlMappedSystemVa);
+
+    ASSERT3U(Mdl->ByteOffset, ==, 0);
+    ASSERT3P(Mdl->StartVa, ==, MdlMappedSystemVa);
+    ASSERT3P(Mdl->MappedSystemVa, ==, MdlMappedSystemVa);
 
     RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount);