MdeModulePkg/RuntimeDxe: clear mVirtualMapMaxIndex

When setting mVirtualMap to NULL also set mVirtualMapMaxIndex to 0.
Without that RuntimeDriverConvertPointer() will go search the ZeroPage
for EFI_MEMORY_DESCRIPTOR entries.

In case mVirtualMapMaxIndex happens to be small small enough that'll go
unnoticed, the search will not find anything and EFI_NOT_FOUND will be
returned.

In case mVirtualMapMaxIndex is big enough the search will reach the end
of the ZeroPage and trigger a page fault.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Gerd Hoffmann 2022-01-21 20:58:48 +08:00 committed by mergify[bot]
parent d4ac53aa91
commit f78b937c95

View File

@ -366,6 +366,7 @@ RuntimeDriverSetVirtualAddressMap (
// mVirtualMap is only valid during SetVirtualAddressMap() call // mVirtualMap is only valid during SetVirtualAddressMap() call
// //
mVirtualMap = NULL; mVirtualMap = NULL;
mVirtualMapMaxIndex = 0;
return EFI_SUCCESS; return EFI_SUCCESS;
} }