From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from APC01-HK2-obe.outbound.protection.outlook.com (APC01-HK2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.6054.1583290141109503854 for ; Tue, 03 Mar 2020 18:49:02 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=p0guvBa1; spf=softfail (domain: outlook.com, ip: , mailfrom: ming.huang-@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dzhlMOKYWhPeOH57IRyv9aSVbcWqgo5exnXv1kV5qztNPh8EfOCxHaI0m/jL+QxK7rYzY1mSzDBXdgC+rCYjotHdyI+YJ6kwE0how9usFzn1jcA54wDFrKMaXycRHmGgonsSxWzjHnTEzGj5EF3K2Afmjx0bSeCKSlCu9cqL5J/UJq2bCzHlE2PEDdOAqE03kSr8/SmZUZINu8MpJO8Emg5/MG57cVemW4lSYvv/LgeNIZBRdjU7/vvnnuhUruSusK27YxCvH+SB0Sd4jCUvPlMIK5dKHRfb49clRyippy5S3UQ7V2ZBSS0QJSRoSNijEHnt8IMs+QTKiU/evMZvrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p55E2K62vGAi/ne8PxHNx7BRlRgWzHTEfVvesgHvTUc=; b=Ipfl5NTjSkGuL2pvtqYR0D1+Z0hwfy8ARoxaaW5hJouQOX3851rGPM2jN5pd2HN+6CgvtVlI8kgxo6jUDJDYo9SXRfD9CEYB0hpxYvdCnd9Y7D9bMOseS6APWtSJOoi1dcCp+JZCHEzV71XIR3iWsm2/yyHae8i6O2ofUHMmbmlVrcUm4CyFqy1B5DcY1/nmq10n9EjAVSKuSd+LlWoRengoAHbBgpdoX26PlKHP3SCqmgicxpHCLVQhm/4O9PzZYIfLcF2+qXc7/nkSEoLQ31XrOjlKlOcstiLekJ7QyMvMJfVqCUMX1PgtZ0Ngu0QJGXc0vNRtnXbLL+uCwLMN9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p55E2K62vGAi/ne8PxHNx7BRlRgWzHTEfVvesgHvTUc=; b=p0guvBa1YoavB4+TWIhpSMeunO1hQXJo7Niv5Iy6NPryOYmyQrH8WDQ+RqeOAXJCChiZcmf5N6kqHuOxstbpNtmWpXyrqpHDX7ay4fj9f3bZi9jDTCYUK/ZNYGQUa/ElYiuJqbQAA9HmZRbgzOgC2Jw1hGWyL7B/2jsuuNgNv6CEmNIyNPPaArnprF/4x8/LS4IyGNj54+l3vWkFOxlFWfeMFgZz8zByjcZ4DkcQyCyab8OdK6DjYSztCI9ULgXll+gJma3dqOlLM5hu3xJVciabqJdnLyYtw6hjiNtZD5ExiYA5+cK96TD+p6HLjoT7/eOnMPEBlFsBiYq48/C1RQ== Received: from SG2APC01FT039.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::36) by SG2APC01HT070.eop-APC01.prod.protection.outlook.com (2a01:111:e400:7ebd::477) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15; Wed, 4 Mar 2020 02:48:57 +0000 Received: from HK0PR02MB2593.apcprd02.prod.outlook.com (10.152.250.55) by SG2APC01FT039.mail.protection.outlook.com (10.152.251.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.11 via Frontend Transport; Wed, 4 Mar 2020 02:48:57 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:41E7E472347E2C28FE42E02067438AFA2A2D4690706EFCD943052313B2211001;UpperCasedChecksum:E9AD87748F7D16D2BC5A3630614A2C113F9AEC00AF8CDF84B2C93F29B7DBA16E;SizeAsReceived:7773;Count:49 Received: from HK0PR02MB2593.apcprd02.prod.outlook.com ([fe80::2589:c718:6ebe:e2ba]) by HK0PR02MB2593.apcprd02.prod.outlook.com ([fe80::2589:c718:6ebe:e2ba%6]) with mapi id 15.20.2772.019; Wed, 4 Mar 2020 02:48:57 +0000 From: "Ming Huang" To: devel@edk2.groups.io, hao.a.wu@intel.com, liming.gao@intel.com, edk2-devel@lists.01.org Cc: phoenix.liyi@huawei.com, songdongkuang@huawei.com, huangming23@huawei.com, shenlimei@huawei.com, wanghuiqiang@huawei.com, Ming Huang Subject: [PATCH v1 2/2] MdeModulePkg/Variable: Move FindVariable after AutoUpdateLangVariable Date: Wed, 4 Mar 2020 10:48:52 +0800 Message-ID: X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200304024852.30669-1-ming.huang-@outlook.com> References: <20200304024852.30669-1-ming.huang-@outlook.com> X-ClientProxiedBy: HK2P15301CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::17) To HK0PR02MB2593.apcprd02.prod.outlook.com (2603:1096:203:1f::15) Return-Path: ming.huang-@outlook.com X-Microsoft-Original-Message-ID: <20200304024852.30669-3-ming.huang-@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (114.119.4.74) by HK2P15301CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:202:1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2814.3 via Frontend Transport; Wed, 4 Mar 2020 02:48:56 +0000 X-Mailer: git-send-email 2.9.5 X-Microsoft-Original-Message-ID: <20200304024852.30669-3-ming.huang-@outlook.com> X-TMN: [gTpeFq6qAeavz+dsvmiGNJL4R+hizZ5r] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: eccb5840-5e90-4c82-f065-08d7bfe695a8 X-MS-TrafficTypeDiagnostic: SG2APC01HT070: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OhVKTCiYayREpVcVAFaeRBYVIrOQINlVi1ORRel2JLElXmcz7C3E6dUV/gQfVTag/L8hY2D4/GPjxPf+KrBlXraILKO8MExdQXNlcvmd6J3XPSGsGzoxbc6o2kZGNPZJpVhuKb1BRDwpat5aQ5dO1PQZTCCnTyeeeWUljF0q0gEwaX+t/adEASoSiFTBM8vp X-MS-Exchange-AntiSpam-MessageData: 27iel8OOLItcnzJPL90xUhUWXl1YzH6HjjaHIvvKhrj/KmZzsEcVuunjByqtVwCIJcsMGGsm/q1RSfu02/KViWADlBXax2DpTa9SI0KcrWdKjOjasXAEFfHjD2yWYmwMzseXE/4L2UZJoJDXFr1xiw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eccb5840-5e90-4c82-f065-08d7bfe695a8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2020 02:48:57.2043 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT070 Content-Type: text/plain When occur reclaim in AutoUpdateLangVariable(), the CurrPtr of Variable is invalid. The State will be update with wrong position after UpdateVariable 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(). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang --- .../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 40efa10839ad..9a20be3e581f 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -2735,6 +2735,19 @@ VariableServiceSetVariable ( mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) Point; } + if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) { + // + // Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang. + // + Status = 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. // @@ -2757,19 +2770,6 @@ VariableServiceSetVariable ( } } - if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) { - // - // Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang. - // - Status = AutoUpdateLangVariable (VariableName, Data, DataSize); - if (EFI_ERROR (Status)) { - // - // The auto update operation failed, directly return to avoid inconsistency between PlatformLang and Lang. - // - goto Done; - } - } - if (mVariableModuleGlobal->VariableGlobal.AuthSupport) { Status = AuthVariableLibProcessVariable (VariableName, VendorGuid, Data, DataSize, Attributes); } else { -- 2.9.5