From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from huawei.com (huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web11.14256.1593519951719683397 for ; Tue, 30 Jun 2020 05:25:52 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.190, mailfrom: huangming23@huawei.com) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 53AABF807B5EFBBB63D8 for ; Tue, 30 Jun 2020 20:25:47 +0800 (CST) Received: from [127.0.0.1] (10.78.51.60) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 30 Jun 2020 20:25:39 +0800 Subject: Re: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable To: "Jiang, Guomin" , "devel@edk2.groups.io" , "Wang, Jian J" , "Wu, Hao A" , "Gao, Liming" CC: "lidongzhan@huawei.com" , "songdongkuang@huawei.com" , "wanghuiqiang@huawei.com" , "qiuliangen@huawei.com" , "shenlimei@huawei.com" , "xiewenyi2@huawei.com" References: <1593410773-62704-1-git-send-email-huangming23@huawei.com> <1593410773-62704-2-git-send-email-huangming23@huawei.com> From: "Ming Huang" Message-ID: Date: Tue, 30 Jun 2020 20:25:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.78.51.60] X-CFilter-Loop: Reflected Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: quoted-printable =D4=DA 2020/6/30 8:58, Jiang, Guomin =D0=B4=B5=C0: > Hi Huang, >=20 >>>>From issue statement, I guess that > 1. AutoUpdateLangVariable() invoked, and it will invoke FindVariable() f= irst, at the same time, reclaim occur and Variable.CurrPtr is invalid, it r= eturn with success > 2. UpdateVariable() is invoked when The old Lang's State is valid and th= e new Lang's State is also valid. > 3. In the situation, FindVariable() checked Lang's State and only enable= one Lang's State. But it didn't in fact. > 4. BmForEachVariable() deadloop in the situation. >=20 > Am I right? Yes, right. Thanks, Ming >=20 >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of Ming >> Huang via groups.io >> Sent: Monday, June 29, 2020 2:06 PM >> To: devel@edk2.groups.io; Wang, Jian J ; Wu, Hao= A >> ; Gao, Liming >> Cc: lidongzhan@huawei.com; huangming23@huawei.com; >> songdongkuang@huawei.com; wanghuiqiang@huawei.com; >> qiuliangen@huawei.com; shenlimei@huawei.com; xiewenyi2@huawei.com >> Subject: [edk2-devel] [PATCH edk2 v1 1/1] MdeModulePkg/Variable: Move >> FindVariable after AutoUpdateLangVariable >> >> When occur reclaim in AutoUpdateLangVariable(), the CurrPtr of Variable= is >> invalid. The State will be update with wrong position after UpdateVaria= ble in >> this situation and two valid PlatformLang or Lang variables will exist. >> BmForEachVariable() will enter endless loop while exist two valid >> PlatformLang variables. So FindVariable() should be invoked atfer >> AutoUpdateLangVariable(). >> >> https://bugzilla.tianocore.org/show_bug.cgi?id=3D2667 >> >> Signed-off-by: Ming Huang >> --- >> MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 26 >> ++++++++++---------- >> 1 file changed, 13 insertions(+), 13 deletions(-) >> >> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> index 1e71fc6..0cec981 100644 >> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> @@ -2741,6 +2741,19 @@ VariableServiceSetVariable ( >> mVariableModuleGlobal->NonVolatileLastVariableOffset =3D (UINTN) >> NextVariable - (UINTN) Point; >> } >> >> + if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) { >> + // >> + // Hook the operation of setting PlatformLangCodes/PlatformLang an= d >> LangCodes/Lang. >> + // >> + Status =3D AutoUpdateLangVariable (VariableName, Data, DataSize); >> + if (EFI_ERROR (Status)) { >> + // >> + // The auto update operation failed, directly return to avoid >> inconsistency between PlatformLang and Lang. >> + // >> + goto Done; >> + } >> + } >> + >> // >> // Check whether the input variable is already existed. >> // >> @@ -2763,19 +2776,6 @@ VariableServiceSetVariable ( >> } >> } >> >> - if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) { >> - // >> - // Hook the operation of setting PlatformLangCodes/PlatformLang an= d >> LangCodes/Lang. >> - // >> - Status =3D AutoUpdateLangVariable (VariableName, Data, DataSize); >> - if (EFI_ERROR (Status)) { >> - // >> - // The auto update operation failed, directly return to avoid in= consistency >> between PlatformLang and Lang. >> - // >> - goto Done; >> - } >> - } >> - >> if (mVariableModuleGlobal->VariableGlobal.AuthSupport) { >> Status =3D AuthVariableLibProcessVariable (VariableName, VendorGui= d, >> Data, DataSize, Attributes); >> } else { >> -- >> 2.8.1 >> >> >>=20 >=20 >=20 >=20