From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web08.11335.1642769946164985388 for ; Fri, 21 Jan 2022 04:59:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EuTTOdil; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642769945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zKH6evq4KYdHdhxXHJLS/9Qqsd1Qo8NcjYyGqL8tAF4=; b=EuTTOdil9sPvAPmVwl4VSh2JYoWeJBCKrVzWnHBIvLJTxBHzlDhJuwSItXQ642kvkzCRv9 f3jRDUrJ9vvXeuAf1rPrf5DeeEY2Xqah9UwFBn6lonCmGivyi4pm4w89GnrEVxR2f0iVG3 9hksI2juJXkmOFsR9ZCdlBTbiwrFfoA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-DD21on_DNayP3KiojtYAxw-1; Fri, 21 Jan 2022 07:58:59 -0500 X-MC-Unique: DD21on_DNayP3KiojtYAxw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE17D1083F60; Fri, 21 Jan 2022 12:58:57 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 237F97AB5C; Fri, 21 Jan 2022 12:58:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A61F0180009C; Fri, 21 Jan 2022 13:58:48 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Dandan Bi , Pawel Polawski , Jian J Wang , Liming Gao , Gerd Hoffmann Subject: [PATCH 1/1] MdeModulePkg/RuntimeDxe: clear mVirtualMapMaxIndex Date: Fri, 21 Jan 2022 13:58:48 +0100 Message-Id: <20220121125848.52621-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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 --- 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 2a541408731d..de8f2bfce0f8 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.34.1