From: Paul Durrant Date: Thu, 25 Jan 2018 13:37:22 +0000 (+0000) Subject: Make sure Mdl->StartVa is set by __AllocatePages() X-Git-Tag: 9.0.0-rc1~58 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e36bf3fb45127a807c58b95a5555b93a8db11b8b;p=pvdrivers%2Fwin%2Fxenvbd.git Make sure Mdl->StartVa is set by __AllocatePages() 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 --- diff --git a/src/common/util.h b/src/common/util.h index 9383817..b303bbc 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -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);