From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.3816.1684957748008849218 for ; Wed, 24 May 2023 12:49:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Z3Xv8DpV; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: chasel.chiu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684957748; x=1716493748; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=tbH/4rjLfzyPaj+pP7Ru/ftsQ38lr7J9X+TyfslRhlA=; b=Z3Xv8DpVsIz3zMWfj6FHwtvFxO8mp08y13K+OktZXC5sdaYGra47/p8X kAaxXSrNf+P40roujt4HpXU0FRRHapFS820pSji8TDVg5sn+cxVtGkIRb RWfRW93fXqUmc+pVIQx9Tmpsgy2aM8DwLI88GIjhS6efxQjtObAbmIGKK ZWgEs3y0TGEr+XivB60OH7WAWKznRq6lXvAYW7R4jaDw49UHVMeHIS9HL 6slstqf2NVqdExtpr1IO8CsfDt55njGpLqab9rM1rZIfI5V1094gu2g9U kjmLd+NE5x1bT1+5+w+VJ1gviKLtZME7Ri9zQ3QsMbbMwwKII1yC49YOL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="351186694" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="351186694" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 12:48:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="878800877" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="878800877" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga005.jf.intel.com with ESMTP; 24 May 2023 12:48:38 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 24 May 2023 12:48:37 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 24 May 2023 12:48:37 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Wed, 24 May 2023 12:48:37 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.47) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Wed, 24 May 2023 12:48:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ORHAI96SodboI5CNGyCqquxheComdxjSPQTZfOo/pHHg/Y5d8DBR/peSc1/isTl0cSr0HefMYTDd/yI1VjdsCFf1P4L8tbxHyWqlRBwOfKHO/Ap4HQIIlkQkIULU0QeKKK4Fxyyv+bRDfRgXOrtwSfY7iEKgGuJyP6ln57RuUupLjrXXyRRCQxt9d+4SzWcNj5UoLnTB1tpQXirT3BAxXCnxFScwfpGLKkffYlhTHWDZAr28wdxwH8eUSxxMd+5Ezh8sk+TyjjhHzfm+7k/bBRBIjtlpGLtA/VS2ZFk7HJi3T+H/jcRoYJbiKJYA/LbwTjR/R/zP50XQUtbE0Dz2Og== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z1+8RmGF7beR1NOMsbqrUVR4caWEQRRrw89gaUdhrg4=; b=ThppiOa5RT8wlGwbOeDEHD+LaDC6hH4kNv2qXjb8ate3JJy7hraFF/jOF9GoD/aDbhXlqeugzR/1XGygp8SOY7Qrztq6ctUzxE/kP+MUakuh45SQUhVA0ZUSmpZ9x4N5UMjPSQm2HmAYkeCnk1bBoiGIClkU29jsEN856ldsMSLFgBbqGRXkrVStvE+u8BvcOb7GPokOPN+1TLoCqj8yHFIS5xYGP0v7LejmtCj7I4MZkK5KfFuSo9XJNOjcGMuFUOjgaozckSVJZD9wQBk9GwnOE96ROlseqcbuCXSPg7/nWQNUm5vc0qjzjXhZdYMcjdFwx44OZlv7agsI3jc/eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by CH3PR11MB8187.namprd11.prod.outlook.com (2603:10b6:610:160::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Wed, 24 May 2023 19:48:33 +0000 Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::1eb1:2222:1823:8e7a]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::1eb1:2222:1823:8e7a%5]) with mapi id 15.20.6411.028; Wed, 24 May 2023 19:48:33 +0000 From: "Chiu, Chasel" To: "Shindo, Miki" , "devel@edk2.groups.io" CC: "Desimone, Nathaniel L" , "Gao, Liming" , "Dong, Eric" , "Zhang, Xiaoqiang" Subject: Re: [edk2-platforms:PATCH v2] MinPlatformPkg: Fix SetLargeVariable fail issue Thread-Topic: [edk2-platforms:PATCH v2] MinPlatformPkg: Fix SetLargeVariable fail issue Thread-Index: AQHZjdjfxd4vVvDa/UWwVxFGjY/vba9p1aSQ Date: Wed, 24 May 2023 19:48:33 +0000 Message-ID: References: <20230524004403.3338-1-miki.shindo@intel.com> In-Reply-To: <20230524004403.3338-1-miki.shindo@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN9PR11MB5483:EE_|CH3PR11MB8187:EE_ x-ms-office365-filtering-correlation-id: eafccd96-f67e-49a8-f9a6-08db5c8fdb87 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zKG0QFwxdZeAAIARyuBdWt3GpPjuCByRq1CAfmyytyNb8/sm9o0nHBo2FLUjH9uxjg18sKyqktXjv6sBCAYKDUuuOK6Bam7Hd6yhRWdia09hH01X3bqHs1JFVJqUXf+UUqpzjm5U2ykBcf9DYmAfq427Hl0czZBNRE+g8kg4reNIgodNQF/7oMbadR55v0fewAsvAXVTMENTMPH+lBJweKsR5X6Ga7GOs5F56DN+mO3Ac3A70dpLOwTwj723ahovOnVDWz4BT2bhE3B+2ct5BgvLINeFb1deCiLnxIHGTDZ5aeklv8hve4abKtExny2oA+Z9R1SIpQJXu7pcOKyioTgD2Hwls30fOzhMm+1ZRK7D9Vm7yc2aoYX8UD15mCfoTjC9ta7I0GZHXMya9eO3Adu84hwv3AJMyRx7vN9ffwks3SYwTK1YOpXcVsIo2SwM8qnTNzxvGYmPQLjXEklifYMvJmPhieDSHomax1I5ySrEBL4CeqcoQL4e9J+cNByVmeARzvr6ctt0af60MIfwQoVLiTy7x0PGH4n1UiTWDy4BdgM672IrVgPtHsMia2hP1ku85McEjmdROXyyYBZvTlV81mhRSCEpAdL33uliowWM5x2i0wM9yYDPcbCRx6JlqDd+85R/v8ICmPfaiqMJXg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR11MB5483.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(136003)(396003)(376002)(451199021)(2906002)(110136005)(30864003)(54906003)(5660300002)(52536014)(8676002)(8936002)(76116006)(41300700001)(66476007)(316002)(64756008)(66446008)(478600001)(4326008)(7696005)(66556008)(66946007)(966005)(71200400001)(33656002)(55016003)(83380400001)(26005)(6506007)(122000001)(38100700002)(86362001)(53546011)(9686003)(107886003)(186003)(38070700005)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?j+Tjs2Hl50ZydAfRarEjoczYmRbFvOzB6ALG7h07TgpXr4yigejmYf7MzaeF?= =?us-ascii?Q?r89Q4Gitw9OOklBjJ61/LMSlPimlrhpp1pkoZ+hou3as3b5Qdlnoh7BsPCzV?= =?us-ascii?Q?EaQsNYzOPx3XSYhtUWdm6dpun41zHjnuu7kItkOwKX4dmMa9/9ghGVjvI1SX?= =?us-ascii?Q?PKhTo3vVYOTDHkOUOUwDCoE98hk01z/gH+h5E163mQC6mmJiF0AVOh5ZbqBt?= =?us-ascii?Q?JhzCX+YpEj1VArG6NAj/X3e6MFgYzSzv1eoWap8ANndecxCLxCS15Gvg1YN7?= =?us-ascii?Q?esY/mgyRqWdryR1s9ZQnn/Fj6iusaxVwtPqN+JS8ErtYQFPG6Nmm/zx9HJJI?= =?us-ascii?Q?WgroaIfJFhjC/h4+jsoYXyxl287pn123IhqRLMXrL1whTQVOIDtSCI2z5jGJ?= =?us-ascii?Q?JhxOCsmV+nDV90gr3TNb0zOxRbt1gvIXyAVnuZhk8YcxkL45TP36U31ByISm?= =?us-ascii?Q?0yHRdvw3/yAkUBVIzHHg8hmFBW+cSgjck76syK1ndnCzwL2Z619qOwbWQ+yE?= =?us-ascii?Q?HOvnt5EyZi4i7pGApZ2Egf0d9WMX+jxbkj1yveM+pqCZYRnrf6sPzIDFOCH3?= =?us-ascii?Q?hCHsfpxWurVddmVodap8VrV0SRTrPqXXYNA9ONo9QwfR6uhr8SjCjcBIwNs9?= =?us-ascii?Q?19wjeTl3Iosm1+DpMjS0hEiUcDE0o52jm4CBlc79ntGSij3zePYn3Ss5ZLnF?= =?us-ascii?Q?7cidzRcFDg48V6XLANl5dOorDelS1y6+cI80wYkBxoTicdoZJUKRKRKBkFS2?= =?us-ascii?Q?nnQkJENCx7MuqFGXmKchp4MFswhfOl5/Di1NH7Xe0l3bH/UfFh5BLYv4Y/UO?= =?us-ascii?Q?wfVaXQwEwxSWA6vhqXB2uXr5BHSrklzpHjXzIK2+Ght0QKdLQpWUftXivOZL?= =?us-ascii?Q?COGvZxzLXqsgQDJSwWgX+Iwm5EFPM2bBRmXhkuWf0qP5w4ALbYqlhMrR769r?= =?us-ascii?Q?6+2IGee+Yip/Co7MKo5fmlNmoFwWTnoCUMH3Pam9KdHJrVF8i+Q3kxnuM+wr?= =?us-ascii?Q?fd7w4x/cY1MNMT2x14YcB/jZj0ta5VQkua27MKxVNWtwHNddUlCsLo8ahQLo?= =?us-ascii?Q?3CQH7a1K8XVaOyVldnqy01RnHvbTz+F0INzLKXdLVbMDkQ9DihynkfitBFJO?= =?us-ascii?Q?QLb61J75Fv8CVPp3/sXC/ia2e3lit2jSaYOd91FKhOYNI9JZ6v3StVsvOjKx?= =?us-ascii?Q?wRcsSXo24vqpwKDKX34nYgun2QrU1AeFIb2tv6CSUWHzt+tcmU2PcL2N4t3r?= =?us-ascii?Q?O2eQmE+4FY8YuZF6XVB5rL9lWMK9sVGTeRcnq60tDf5naElhNHVAgq33FqgG?= =?us-ascii?Q?BQD6cRrjn+a6NPH6e/a+q/8epo3pp8uxqnYkWi6ZW0YwIkKLRWceqFXVrAUk?= =?us-ascii?Q?PLnNVIe4SH+J35P8FPSE0vQIaTe8WdidREIgf13VjsfuaGels5/DyEBeCRoX?= =?us-ascii?Q?iz3Lpfxe31dhn3DEH/5nOAMxh4rbl8uBIYltXoJnXl2Cer0HAu/J3RS9fk8T?= =?us-ascii?Q?2II8UfA1e+H3XLulz+OwOCzRrbsGZ9UlBIyBhlUk93NpijpADuxzWwS16KJS?= =?us-ascii?Q?oSrfrPBtJYz7odB62ZCBl2LMrVYtKjAuMDQfw7q2?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eafccd96-f67e-49a8-f9a6-08db5c8fdb87 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2023 19:48:33.6061 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0xngd27di8FtYmx+uXyeOyMKwZAFDk6pcHsFPdHNDQMxmgqm/7O3eN92xIQR+Bz2G3hg0DZkIuA03v7ZUmx33g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB8187 Return-Path: chasel.chiu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Patch merged: https://github.com/tianocore/edk2-platforms/commit/b71f2bda9e4fc183068eef5d= 1d90a631181a2506 Thanks, Chasel > -----Original Message----- > From: Shindo, Miki > Sent: Tuesday, May 23, 2023 5:44 PM > To: devel@edk2.groups.io > Cc: Chiu, Chasel ; Desimone, Nathaniel L > ; Gao, Liming ; > Dong, Eric ; Zhang, Xiaoqiang > > Subject: [edk2-platforms:PATCH v2] MinPlatformPkg: Fix SetLargeVariable f= ail > issue >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4454 >=20 > On Server platform, when the large variable "FspNvsBuffer" is already in = the > UEFI variable store and the remaining variable storage space is less than= the > large variable size, and also not in OS runtime, then we need to add the = size of > the current data that will end up being replaced by the new data to the > remaining space before we decide that there is not enough space to store = the > large variable. >=20 > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Cc: Eric Dong > Co-authored-by: Xiaoqiang Zhang > Signed-off-by: Miki Shindo > --- >=20 > Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableW= ri > teLib.c | 10 +++++++++- >=20 > Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRunti > meVariableWriteLib.c | 15 +++++++++++++++ >=20 > Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableWrit > eCommon.c | 16 ++++++++++++++++ >=20 > Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVa > riableWriteLibConstructor.c | 30 ++++++++++++++++++++++++++++++ > Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVa > riableWriteLibConstructor.c | 30 ++++++++++++++++++++++++++++++ > Platform/Intel/MinPlatformPkg/Include/Library/VariableWriteLib.h > | 12 ++++++++++++ >=20 > Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVaria= bl > eWriteLib.inf | 1 + >=20 > Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVa > riableWriteLib.inf | 3 ++- >=20 > Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMmVa > riableWriteLib.inf | 3 ++- > 9 files changed, 117 insertions(+), 3 deletions(-) >=20 > diff --git > a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariabl= e > WriteLib.c > b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariabl= e > WriteLib.c > index de23ae6160..4bf9a6994f 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariabl= e > WriteLib.c > +++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVa > +++ riableWriteLib.c > @@ -22,7 +22,7 @@ > #include #include #incl= ude > -+#include > #include "LargeVariableCommon.h" /**@@ -270,6 +270,7 @@ > SetLargeVariable ( > UINT8 *OffsetPtr; UINTN BytesRemaining; UINTN > SizeToSave;+ UINTN BufferSize =3D 0; // // Check input para= meters.@@ - > 365,6 +366,13 @@ SetLargeVariable ( > // Non-Volatile storage to store the data. // RemainingVaria= bleStorage =3D > GetRemainingVariableStorageSpace ();+ //+ // Check if current varia= ble > already existed in NV storage variable space+ //+ Status =3D GetLar= geVariable > (VariableName, VendorGuid, &BufferSize, NULL);+ if ((Status =3D=3D > EFI_BUFFER_TOO_SMALL) && (BufferSize !=3D 0) && !VarLibAtOsRuntime ()) {+ > RemainingVariableStorage =3D RemainingVariableStorage + BufferSize;+ }= if > (DataSize > RemainingVariableStorage) { DEBUG ((DEBUG_ERROR, > "SetLargeVariable: Not enough NV storage space to store the data\n")); > Status =3D EFI_OUT_OF_RESOURCES;diff --git > a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRun > timeVariableWriteLib.c > b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRun > timeVariableWriteLib.c > index 28730f858b..9ca4734f24 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRun > timeVariableWriteLib.c > +++ b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/D > +++ xeRuntimeVariableWriteLib.c > @@ -195,6 +195,21 @@ VarLibVariableRequestToLock ( > return Status; } +/**+ Indicator of whether it is runtime or not.++ = @retval > TRUE It is Runtime.+ @retval FALSE It is not > Runtime.+**/+BOOLEAN+EFIAPI+VarLibAtOsRuntime (+ VOID+ )+{+ return > (mVariableWriteLibVariablePolicy =3D=3D NULL) ? TRUE : FALSE;+}+ /** Cl= ose > events when driver unloaded. diff --git > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableW > riteCommon.c > b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableW > riteCommon.c > index 50ebb544b8..cd7118d1fb 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVariableW > riteCommon.c > +++ b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/SmmVaria > +++ bleWriteCommon.c > @@ -18,6 +18,7 @@ > #include EFI_SMM_VARIABLE_PROTOCOL > *mVariableWriteLibSmmVariable =3D NULL;+BOOLEAN mEfiAt= Runtime =3D > FALSE; /** Sets the value of a variable.@@ -169,3 +170,18 @@ > VarLibVariableRequestToLock ( > // return EFI_UNSUPPORTED; }++/**+ Indicator of whether it is runti= me or > not.++ @retval TRUE It is Runtime.+ @retval FALSE It is no= t > Runtime.+**/+BOOLEAN+EFIAPI+VarLibAtOsRuntime (+ VOID+ )+{+ return > mEfiAtRuntime;+}diff --git > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMm > VariableWriteLibConstructor.c > b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMm > VariableWriteLibConstructor.c > index d39418abd2..8c2b7d18f5 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMm > VariableWriteLibConstructor.c > +++ b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/Standalo > +++ neMmVariableWriteLibConstructor.c > @@ -20,6 +20,28 @@ > #include extern > EFI_SMM_VARIABLE_PROTOCOL *mVariableWriteLibSmmVariable;+extern > BOOLEAN mEfiAtRuntime;++/**+ Callback for ExitBootSer= vice, which > is registered at the constructor.+ This callback sets a global variable > mEfiAtRuntime to indicate whether+ it is after ExitBootService.++ @para= m[in] > Protocol Protocol unique ID.+ @param[in] Interface Interfac= e instance.+ > @param[in] Handle The handle on which the interface is > installed.+**/+EFI_STATUS+EFIAPI+VarLibExitBootServicesCallback (+ IN > CONST EFI_GUID *Protocol,+ IN VOID *Interface,+ IN > EFI_HANDLE Handle+ )+{+ mEfiAtRuntime =3D TRUE;+ return EFI_SUC= CESS;+} > /** The constructor function acquires the EFI SMM Variable Services@@ - > 41,11 +63,19 @@ StandaloneMmVariableWriteLibConstructor ( > ) { EFI_STATUS Status;+ VOID *Registration =3D NULL; = // // Locate > SmmVariableProtocol. // Status =3D gMmst->MmLocateProtocol > (&gEfiSmmVariableProtocolGuid, NULL, (VOID **) > &mVariableWriteLibSmmVariable); ASSERT_EFI_ERROR (Status);++ //+ // > Register VarLibExitBootServicesCallback for > gEdkiiSmmExitBootServicesProtocolGuid.+ //+ Status =3D > SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServicesProtocolGuid, > VarLibExitBootServicesCallback, &Registration);+ ASSERT_EFI_ERROR (Statu= s);+ > return Status; }diff --git > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMm > VariableWriteLibConstructor.c > b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMm > VariableWriteLibConstructor.c > index d142527e17..abc1e25cde 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMm > VariableWriteLibConstructor.c > +++ b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/Traditio > +++ nalMmVariableWriteLibConstructor.c > @@ -20,6 +20,28 @@ > #include extern > EFI_SMM_VARIABLE_PROTOCOL *mVariableWriteLibSmmVariable;+extern > BOOLEAN mEfiAtRuntime;++/**+ Callback for ExitBootSer= vice, which > is registered at the constructor.+ This callback sets a global variable > mEfiAtRuntime to indicate whether+ it is after ExitBootService.++ @para= m[in] > Protocol Protocol unique ID.+ @param[in] Interface Interfac= e instance.+ > @param[in] Handle The handle on which the interface is > installed.+**/+EFI_STATUS+EFIAPI+VarLibExitBootServicesCallback (+ IN > CONST EFI_GUID *Protocol,+ IN VOID *Interface,+ IN > EFI_HANDLE Handle+ )+{+ mEfiAtRuntime =3D TRUE;+ return EFI_SUC= CESS;+} > /** The constructor function acquires the EFI SMM Variable Services@@ - > 41,11 +63,19 @@ TraditionalMmVariableWriteLibConstructor ( > ) { EFI_STATUS Status;+ VOID *Registration =3D NULL; = // // Locate > SmmVariableProtocol. // Status =3D gSmst->SmmLocateProtocol > (&gEfiSmmVariableProtocolGuid, NULL, (VOID **) > &mVariableWriteLibSmmVariable); ASSERT_EFI_ERROR (Status);++ //+ // > Register VarLibExitBootServicesCallback for > gEdkiiSmmExitBootServicesProtocolGuid.+ //+ Status =3D > SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServicesProtocolGuid, > VarLibExitBootServicesCallback, &Registration);+ ASSERT_EFI_ERROR (Statu= s);+ > return Status; }diff --git > a/Platform/Intel/MinPlatformPkg/Include/Library/VariableWriteLib.h > b/Platform/Intel/MinPlatformPkg/Include/Library/VariableWriteLib.h > index fab87f2e48..bc0b52d782 100644 > --- a/Platform/Intel/MinPlatformPkg/Include/Library/VariableWriteLib.h > +++ b/Platform/Intel/MinPlatformPkg/Include/Library/VariableWriteLib.h > @@ -135,4 +135,16 @@ VarLibVariableRequestToLock ( > IN EFI_GUID *VendorGuid ); +/**+ Indicator of = whether it is > runtime or not.++ @retval TRUE It is Runtime.+ @retval FALSE = It is not > Runtime.+**/+BOOLEAN+EFIAPI+VarLibAtOsRuntime (+ VOID+ );+ #endif // > _VARIABLE_WRITE_LIB_H_diff --git > a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVar= ia > bleWriteLib.inf > b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVar= ia > bleWriteLib.inf > index 2493a94596..cbc2a5d93a 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVar= ia > bleWriteLib.inf > +++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLar > +++ geVariableWriteLib.inf > @@ -49,3 +49,4 @@ > PrintLib VariableReadLib VariableWriteLib+ LargeVariableReadLibdi= ff --git > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMm > VariableWriteLib.inf > b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMm > VariableWriteLib.inf > index 0d1c63a297..868be49630 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMm > VariableWriteLib.inf > +++ b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/Standalo > +++ neMmVariableWriteLib.inf > @@ -39,7 +39,8 @@ > MmServicesTableLib [Protocols]- gEfiSmmVariableProtocolGuid ## > CONSUMES+ gEfiSmmVariableProtocolGuid ## CONSUMES+ > gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES [Depex] > gEfiSmmVariableProtocolGuiddiff --git > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMm > VariableWriteLib.inf > b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMm > VariableWriteLib.inf > index 5d833b7e0f..4aaab069ab 100644 > --- > a/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/TraditionalMm > VariableWriteLib.inf > +++ b/Platform/Intel/MinPlatformPkg/Library/SmmVariableWriteLib/Traditio > +++ nalMmVariableWriteLib.inf > @@ -38,7 +38,8 @@ > SmmServicesTableLib [Protocols]- gEfiSmmVariableProtocolGuid ## > CONSUMES+ gEfiSmmVariableProtocolGuid ## CONSUMES+ > gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES [Depex] > gEfiSmmVariableProtocolGuid-- > 2.39.1.windows.1