From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5A234740039 for ; Tue, 28 Nov 2023 18:10:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=FCCyYcfdld8NOygUTCY0e1S7qZeUKXMt6xxIMfqG1zg=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1701195026; v=1; b=t8OAPnBCz/yeyp/Czs0K1BkJ9pcVUgj+J3mo8tAqn0tIwNCFKgx+zqVaSuX+0gkgnKq/xjRn ZknKqiI/RVHJxmJrWHGtxJ/xkm7KDU8qGB+s8KphJGKHot5UmHWYOd64FyGGVsF7jikdwVa84Dj 6SVlVZYmnYxdsdZABz6GJU/s= X-Received: by 127.0.0.2 with SMTP id gYcnYY7687511xaILQ1zSsna; Tue, 28 Nov 2023 10:10:26 -0800 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.41691.1701195024953410669 for ; Tue, 28 Nov 2023 10:10:25 -0800 X-Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 8582BB83A5B for ; Tue, 28 Nov 2023 18:10:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6BE7C433CB for ; Tue, 28 Nov 2023 18:10:21 +0000 (UTC) X-Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c887d1fb8fso72677251fa.0 for ; Tue, 28 Nov 2023 10:10:21 -0800 (PST) X-Gm-Message-State: NRyzis8mKq6uUXAWAi7odgzNx7686176AA= X-Google-Smtp-Source: AGHT+IE8NTavsyn99dY1M3YEHh/Bi7NEMwAgVke6HUdaT7XymwhDJZ2+StrLQQ1QA5oXKtO6qPPLU7WWfw32W9E9YQM= X-Received: by 2002:a05:651c:149:b0:2c6:ed6a:780f with SMTP id c9-20020a05651c014900b002c6ed6a780fmr9635580ljd.11.1701195020044; Tue, 28 Nov 2023 10:10:20 -0800 (PST) MIME-Version: 1.0 References: <20231123044854.3003826-1-nhi@os.amperecomputing.com> <026f01da220d$a6217260$f2645720$@byosoft.com.cn> In-Reply-To: <026f01da220d$a6217260$f2645720$@byosoft.com.cn> From: "Ard Biesheuvel" Date: Tue, 28 Nov 2023 19:10:08 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1] MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap omitted To: devel@edk2.groups.io, gaoliming@byosoft.com.cn Cc: Nhi Pham , ardb+tianocore@kernel.org Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=t8OAPnBC; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Tue, 28 Nov 2023 at 16:15, gaoliming via groups.io wrote: > > Reviewed-by: Liming Gao > Thanks I'll queue this up. > > -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- > > =E5=8F=91=E4=BB=B6=E4=BA=BA: devel@edk2.groups.io =E4=BB=A3=E8=A1=A8 Ard > > Biesheuvel > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B411=E6=9C=8823=E6=97= =A5 16:36 > > =E6=94=B6=E4=BB=B6=E4=BA=BA: Nhi Pham > > =E6=8A=84=E9=80=81: devel@edk2.groups.io; gaoliming@byosoft.com.cn; > > ardb+tianocore@kernel.org > > =E4=B8=BB=E9=A2=98: Re: [edk2-devel] [Proposed Fix][PATCH v1 1/1] > > MdeModulePkg/DxeCapsuleLibFmp: Fix crash with VirtualAddressMap > > omitted > > > > On Thu, 23 Nov 2023 at 05:49, Nhi Pham > > wrote: > > > > > > If the SetVirtualAddressMap() is not called, mIsVirtualAddrConverted > > > is FALSE and the kernel crash occurs in IsNestedFmpCapsule() when > > > executing gBS->LocateProtocol () in the else case. > > > > > > To serve the omitted SetVirtualAddressMap() call, we could just check > > > mEsrtTable presence instead of relying on mIsVirtualAddrConverted. > > > > > > Signed-off-by: Nhi Pham > > > > Agreed: SetVirtualAddressMap() is optional, so whether it has been > > called or not should not be used as a proxy to decide whether or not > > we are still running in the boot services context. > > > > Reviewed-by: Ard Biesheuvel > > > > > > > --- > > > MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 17 > > +++++++---------- > > > MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c | 2 -- > > > 2 files changed, 7 insertions(+), 12 deletions(-) > > > > > > diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > > > index 197af267aff3..2433c76a8c6f 100644 > > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c > > > @@ -41,8 +41,7 @@ > > > #include > > > #include > > > > > > -EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable =3D NULL; > > > -BOOLEAN mIsVirtualAddrConverted =3D FALSE; > > > +EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable =3D NULL; > > > > > > BOOLEAN mDxeCapsuleLibEndOfDxe =3D FALSE; > > > EFI_EVENT mDxeCapsuleLibEndOfDxeEvent =3D NULL; > > > @@ -1394,14 +1393,12 @@ IsNestedFmpCapsule ( > > > EFI_SYSTEM_RESOURCE_ENTRY Entry; > > > > > > EsrtGuidFound =3D FALSE; > > > - if (mIsVirtualAddrConverted) { > > > - if (mEsrtTable !=3D NULL) { > > > - EsrtEntry =3D (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1); > > > - for (Index =3D 0; Index < mEsrtTable->FwResourceCount; Index++= , > > EsrtEntry++) { > > > - if (CompareGuid (&EsrtEntry->FwClass, > > &CapsuleHeader->CapsuleGuid)) { > > > - EsrtGuidFound =3D TRUE; > > > - break; > > > - } > > > + if (mEsrtTable !=3D NULL) { > > > + EsrtEntry =3D (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1); > > > + for (Index =3D 0; Index < mEsrtTable->FwResourceCount; Index++, > > EsrtEntry++) { > > > + if (CompareGuid (&EsrtEntry->FwClass, > > &CapsuleHeader->CapsuleGuid)) { > > > + EsrtGuidFound =3D TRUE; > > > + break; > > > } > > > } > > > } else { > > > diff --git > > a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c > > b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c > > > index 9ceb44fe4d79..44f30c16c284 100644 > > > --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c > > > +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c > > > @@ -21,7 +21,6 @@ > > > #include > > > > > > extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable; > > > -extern BOOLEAN mIsVirtualAddrConverted; > > > EFI_EVENT > > mDxeRuntimeCapsuleLibVirtualAddressChangeEvent =3D NULL; > > > EFI_EVENT > > mDxeRuntimeCapsuleLibReadyToBootEvent =3D NULL; > > > > > > @@ -40,7 +39,6 @@ DxeCapsuleLibVirtualAddressChangeEvent ( > > > ) > > > { > > > gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable); > > > - mIsVirtualAddrConverted =3D TRUE; > > > } > > > > > > /** > > > -- > > > 2.25.1 > > > > > > > > > > > > > > > > >=20 > > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111822): https://edk2.groups.io/g/devel/message/111822 Mute This Topic: https://groups.io/mt/102855986/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-