From f78b937c95ddc4f7a29e41fee98e96076828a108 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 21 Jan 2022 20:58:48 +0800 Subject: [PATCH] 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 Reviewed-by: Liming Gao --- MdeModulePkg/Core/RuntimeDxe/Runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.c b/MdeModulePkg/Core/RuntimeDxe/Runtime.c index 2a54140873..de8f2bfce0 100644 --- a/MdeModulePkg/Core/RuntimeDxe/Runtime.c +++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.c @@ -365,7 +365,8 @@ RuntimeDriverSetVirtualAddressMap ( // // mVirtualMap is only valid during SetVirtualAddressMap() call // - mVirtualMap = NULL; + mVirtualMap = NULL; + mVirtualMapMaxIndex = 0; return EFI_SUCCESS; } -- 2.39.2