]> xenbits.xensource.com Git - pvdrivers/win/xenvkbd.git/commitdiff
Make sure Mdl->StartVa is set by __AllocatePages()
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 25 Jan 2018 14:11:08 +0000 (14:11 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 25 Jan 2018 14:11:08 +0000 (14:11 +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/xenvkbd/util.h

index 2d4d1c9adb666dc0de43215712c42f74629a1d8f..b82445ed44776046a1a803f462f487ebbd68879c 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);