From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (NAM04-CO1-obe.outbound.protection.outlook.com [40.107.69.96]) by mx.groups.io with SMTP id smtpd.web12.225.1589345487493572376 for ; Tue, 12 May 2020 21:51:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=ABBongdK; spf=pass (domain: microsoft.com, ip: 40.107.69.96, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i1oAK2/0s1sdgfxwVGcHemV7+uIayViFVOCtSRZK/Mh1i59A1lHp5lv2+CIjIh43lRaXSHknqG+55ma3EjhUKPZVI2n0JaJ6gL5/88fq7amxuIvXMLtAdjzEqnV4PIij3FDRHPh6Yl1xYvCjiC+LiSZ2GJjRi5HXG+EWvmCYxLoJIv9xnzqS78akR5EysmQEstf4RS8wbqDSg+bKX1ZJ56WGs/u93gb6DIYVDQAATKaoB205IcwKDsu3G6jnakVcB1XSlpl8PBt179MxTGKjxXdzxLSlSZQW7KCj2vWBEIVjYIXhmn+okoLtRf4SrqntjX7fnzPXra8vNUDxXUCFdQ== 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=AIJFSQ/b66ATrFzlh6gzugv0PTwVZon7IjKaobGj5L8=; b=LDFLdM9FqLslz3NC+WwGfrBh6h1CafN4QlhfG76Uf0HeDeiIUAhi3Cgdbn/9RIr3LScqHSrOVHvayNSEWxFwySwnZlOZYpeupq6AGG4KmcOav+NxZl3BWxpQkB/eTBi65GaeCAafTud4tmazFgDR2pPbflhtoi7MvBgSqRHH7C/AWCItbgOa8e8V2yJd+lwINqfnxYsGtK33UQRBwGDO4jve1riCAKpvKKQ9FToi+mFW4xNUBkU+lW09zAIodyILpNTRL0qSZRO6pHDP4gRmN6t3K8cjTB71MMGbsAFL91pO4JNuGtzhyDmsUW6nRZu3tvoPdzHTMtW71VLrEzxdQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AIJFSQ/b66ATrFzlh6gzugv0PTwVZon7IjKaobGj5L8=; b=ABBongdKlNhtfko79Aq6D1uKQh3dFrxiPCtnBeTJaYx1GJal9z+PFlUr4csTj7wId1Qa5yBfiZKqJ/UflhWam0BYFSUunAAAXypTic32jSU9WW3zkh603+oUNZsB6RJTm0xqUaA2B2oVfjjE0Gfm0ujiczzmajEGemIHpw8ISCg= Received: from CY4PR21MB0743.namprd21.prod.outlook.com (2603:10b6:903:b2::9) by CY4PR21MB1538.namprd21.prod.outlook.com (2603:10b6:910:8f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.2; Wed, 13 May 2020 04:51:25 +0000 Received: from CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::9918:8742:bbe7:84e8]) by CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::9918:8742:bbe7:84e8%14]) with mapi id 15.20.3021.002; Wed, 13 May 2020 04:51:25 +0000 From: "Bret Barkelew" To: "devel@edk2.groups.io" , "lersek@redhat.com" , "michael.kubacki@outlook.com" CC: Jian J Wang , Hao A Wu , liming.gao Subject: Re: [EXTERNAL] Re: [edk2-devel] [PATCH v2 01/12] MdeModulePkg: Define the VariablePolicy protocol interface Thread-Topic: [EXTERNAL] Re: [edk2-devel] [PATCH v2 01/12] MdeModulePkg: Define the VariablePolicy protocol interface Thread-Index: AQHWKFeTi1HLp/kUT0Wd6ji6UAujCqilcrn8 Date: Wed, 13 May 2020 04:51:25 +0000 Message-ID: References: <20200512064635.14640-1-michael.kubacki@outlook.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-05-13T04:48:10.4952758Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Privileged authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [71.212.135.200] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 64550120-8f2a-4db6-f4f9-08d7f6f94a9b x-ms-traffictypediagnostic: CY4PR21MB1538: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0402872DA1 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7I9thKgTyLVpFEWNQnldUw2TivhhCyge8Vg6KpipM5E8y2H/vg5genCBvnUd/x20LuFjQAuYMINq1fcqqYtX78exrvFPFpheuuS87LqnW/tVbpwU3OjV5bBSWJctofVJ2yw+VzGuIFjfW6XM8A80kPJA8OehszW9fTw7l/t/yIK8I4MOaJelx7FjMtV0R6/aIVxrXA4kK+2Zi4YcjyTEG83RaXWvsy6n9t5q7vitPmuxxy6fpkJSL4IRTxRY1DNVO+l6DxWHNor+npGC3Yx0JkVNBPvyj1Lzr+NjdeUufWhgpAMiePEj3Znt2+8/xxNshDGLoMr5P8I7lyOzyH9ieIdLZKrsl2v7XUFAStak2WCFyj+wFtPd0QNTynyzKyhJn1bDpV3Np1+uz5wBd0MPOwehBBzGYqZj2ENNYKyulUjpbjqtj5Fu3//p5ic1cCbMArnuJ1cSQPevc4WS231KqD1IsdmK16apqcGoLAH5PLEPaRYnUJ97JBzkdI5sxlGc x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR21MB0743.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(366004)(396003)(136003)(39860400002)(376002)(33430700001)(33656002)(7696005)(5660300002)(966005)(478600001)(30864003)(186003)(110136005)(54906003)(82960400001)(82950400001)(86362001)(166002)(6506007)(53546011)(26005)(316002)(10290500003)(33440700001)(8990500004)(52536014)(76116006)(9686003)(8936002)(8676002)(4326008)(71200400001)(66946007)(66446008)(66556008)(66476007)(2906002)(64756008)(55016002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: U3Dzk2J47gc96GEDUzHeHzwTDB9u5YNKW1tlNGlD4qjSsWg2I1RZz3QEHUE0OTTrMSYKqJYOq27Vj/Fh+EQkVnchJYAUOTv4OpGQcdVBsY80Sz0kBREOB4b9nydfchwZdAhLhdKz24DouymnazBXVGzSM/p5p/sNnDhhqckjzCLYYFVF6qCbQf2aQV8zMNpE/9yPDHCkk2lsmZGcarEnVd/UDCiAUSKNOzzzQvcBkqQ50OChaMRGMRFKfVbR1Ltkte5sExq+CDWhZTcK9FEPWPctkiX98hSFY4XnOcSsWU53HgxqEgibfTtAjBYa3BRJel+j11DoNtDRDw5ZEWEfa0ZlXjH2GpVEUbJt6s0YZ34BkuiTB8cgEm3kc6pK4mLPmBsSLXu235EA60dli4GiGn2UP3BDRvSz/ptsaCl6zGPj6OK3RwLGoHgmHOkVO3ToYKJfjZ/BMP1QOMCLB9/tABqJuix5mnlte35v/VTwMtk3VgA5B34ofqSmLa6YhLkp x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64550120-8f2a-4db6-f4f9-08d7f6f94a9b X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2020 04:51:25.3239 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zhOAni2QLq/8JP7xWN0M02IfVZ4uNU0A6qERLttuB48MpUuNP0c817ybPazCv1R5+BhXssmPdbX2/Y6xJcEyDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB1538 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR21MB0743D5B051A7B8FAD03BCE06EFBF0CY4PR21MB0743namp_" --_000_CY4PR21MB0743D5B051A7B8FAD03BCE06EFBF0CY4PR21MB0743namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I don=92t entirely disagree with the name suggestion, but it=92s pretty lat= e in the process. If it=92s not a hard-stop, I=92d rather not. Other change has been made. - Bret From: Laszlo Ersek via groups.io Sent: Tuesday, May 12, 2020 5:19 AM To: devel@edk2.groups.io; michael.kubacki@out= look.com Cc: Jian J Wang; Hao A Wu; liming.gao Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v2 01/12] MdeModulePkg: Define= the VariablePolicy protocol interface On 05/12/20 08:46, Michael Kubacki wrote: > From: Bret Barkelew > > https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugz= illa.tianocore.org%2Fshow_bug.cgi%3Fid%3D2522&data=3D02%7C01%7CBret.Bar= kelew%40microsoft.com%7Cf9d61ace6d7d42a2b9c008d7f66eb4b3%7C72f988bf86f141af= 91ab2d7cd011db47%7C1%7C0%7C637248827657827126&sdata=3Ds80j2lvjZROfSb9GR= 6g0NO0FwGN2c18v9Im8pmRRenE%3D&reserved=3D0 > > VariablePolicy is an updated interface to > replace VarLock and VarCheckProtocol. > > Add the VariablePolicy protocol interface > header and add to the MdeModulePkg.dec file. > > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Liming Gao > Signed-off-by: Michael Kubacki > --- > MdeModulePkg/Include/Protocol/VariablePolicy.h | 157 ++++++++++++++++++= ++ > MdeModulePkg/MdeModulePkg.dec | 14 +- > 2 files changed, 170 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Include/Protocol/VariablePolicy.h b/MdeModuleP= kg/Include/Protocol/VariablePolicy.h > new file mode 100644 > index 000000000000..2cd025860554 > --- /dev/null > +++ b/MdeModulePkg/Include/Protocol/VariablePolicy.h > @@ -0,0 +1,157 @@ > +/** @file -- VariablePolicy.h > + > +This protocol allows communication with Variable Policy Engine. > + > +Copyright (c) Microsoft Corporation. > +SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef __VARIABLE_POLICY_PROTOCOL__ > +#define __VARIABLE_POLICY_PROTOCOL__ > + > +#define VARIABLE_POLICY_PROTOCOL_REVISION 0x0000000000010000 > + > +#define VARIABLE_POLICY_PROTOCOL_GUID \ > + { \ > + 0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0= x25, 0xC3 } \ > + } > + > +#define VARIABLE_POLICY_ENTRY_REVISION 0x00010000 > + > +#pragma pack(push, 1) > +typedef struct { > + UINT32 Version; > + UINT16 Size; > + UINT16 OffsetToName; > + EFI_GUID Namespace; > + UINT32 MinSize; > + UINT32 MaxSize; > + UINT32 AttributesMustHave; > + UINT32 AttributesCantHave; > + UINT8 LockPolicyType; > + UINT8 Padding[3]; > + // UINT8 LockPolicy[]; // Variable Length Field > + // CHAR16 Name[] // Variable Length Field > +} VARIABLE_POLICY_ENTRY; > + > +#define VARIABLE_POLICY_NO_MIN_SIZE 0 > +#define VARIABLE_POLICY_NO_MAX_SIZE MAX_UINT32 > +#define VARIABLE_POLICY_NO_MUST_ATTR 0 > +#define VARIABLE_POLICY_NO_CANT_ATTR 0 > + > +#define VARIABLE_POLICY_TYPE_NO_LOCK 0 > +#define VARIABLE_POLICY_TYPE_LOCK_NOW 1 > +#define VARIABLE_POLICY_TYPE_LOCK_ON_CREATE 2 > +#define VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE 3 > + > +typedef struct { > + EFI_GUID Namespace; > + UINT8 Value; > + UINT8 Padding; > + // CHAR16 Name[]; // Variable Length Field > +} VARIABLE_LOCK_ON_VAR_STATE_POLICY; > +#pragma pack(pop) > + > +/** > + This API function disables the variable policy enforcement. If it's > + already been called once, will return EFI_ALREADY_STARTED. > + > + @retval EFI_SUCCESS > + @retval EFI_ALREADY_STARTED Has already been called once this b= oot. > + @retval EFI_WRITE_PROTECTED Interface has been locked until reb= oot. > + @retval EFI_WRITE_PROTECTED Interface option is disabled by pla= tform PCD. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *DISABLE_VARIABLE_POLICY)( > + VOID > + ); > + > +/** > + This API function returns whether or not the policy engine is > + currently being enforced. > + > + @param[out] State Pointer to a return value for whether the p= olicy enforcement > + is currently enabled. > + > + @retval EFI_SUCCESS > + @retval Others An error has prevented this command from co= mpleting. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *IS_VARIABLE_POLICY_ENABLED)( > + OUT BOOLEAN *State > + ); > + > +/** > + This API function validates and registers a new policy with > + the policy enforcement engine. > + > + @param[in] NewPolicy Pointer to the incoming policy structure. > + > + @retval EFI_SUCCESS > + @retval EFI_INVALID_PARAMETER NewPolicy is NULL or is internall= y inconsistent. > + @retval EFI_ALREADY_STARTED An identical matching policy alre= ady exists. > + @retval EFI_WRITE_PROTECTED The interface has been locked unt= il the next reboot. > + @retval EFI_ABORTED A calculation error has prevented= this function from completing. > + @retval EFI_OUT_OF_RESOURCES Cannot grow the table to hold any= more policies. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *REGISTER_VARIABLE_POLICY)( > + IN VARIABLE_POLICY_ENTRY *PolicyEntry > + ); > + > +/** > + This API function will dump the entire contents of the variable polic= y table. > + > + Similar to GetVariable, the first call can be made with a 0 size and = it will return > + the size of the buffer required to hold the entire table. > + > + @param[out] Policy Pointer to the policy buffer. Can be NULL if = Size is 0. > + @param[in,out] Size On input, the size of the output buffer. On o= utput, the size > + of the data returned. > + > + @retval EFI_SUCCESS Policy data is in the output buff= er and Size has been updated. > + @retval EFI_INVALID_PARAMETER Size is NULL, or Size is non-zero= and Policy is NULL. > + @retval EFI_BUFFER_TOO_SMALL Size is insufficient to hold poli= cy. Size updated with required size. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *DUMP_VARIABLE_POLICY)( > + IN OUT UINT8 *Policy, > + IN OUT UINT32 *Size > + ); > + > +/** > + This API function locks the interface so that no more policy updates > + can be performed or changes made to the enforcement until the next bo= ot. > + > + @retval EFI_SUCCESS > + @retval Others An error has prevented this command from co= mpleting. > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *LOCK_VARIABLE_POLICY)( > + VOID > + ); > + > +typedef struct { > + UINT64 Revision; > + DISABLE_VARIABLE_POLICY DisableVariablePolicy; > + IS_VARIABLE_POLICY_ENABLED IsVariablePolicyEnabled; > + REGISTER_VARIABLE_POLICY RegisterVariablePolicy; > + DUMP_VARIABLE_POLICY DumpVariablePolicy; > + LOCK_VARIABLE_POLICY LockVariablePolicy; > +} _VARIABLE_POLICY_PROTOCOL; > + > +typedef _VARIABLE_POLICY_PROTOCOL VARIABLE_POLICY_PROTOCOL; > + > +extern EFI_GUID gVariablePolicyProtocolGuid; > + > +#endif > diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.d= ec > index 4f44af694862..f74fea00b6e7 100644 > --- a/MdeModulePkg/MdeModulePkg.dec > +++ b/MdeModulePkg/MdeModulePkg.dec > @@ -8,7 +8,7 @@ > # Copyright (c) 2016, Linaro Ltd. All rights reserved.
> # (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Development LP > # Copyright (c) 2017, AMD Incorporated. All rights reserved.
> -# Copyright (c) 2016, Microsoft Corporation
> +# Copyright (c) Microsoft Corporation.
> # SPDX-License-Identifier: BSD-2-Clause-Patent > # > ## > @@ -624,6 +624,9 @@ > # 0x80000006 | Incorrect error code provided. > # > > + ## Include/Protocol/VariablePolicy.h > + gVariablePolicyProtocolGuid =3D { 0x81D1675C, 0x86F6, 0x48DF, { 0xBD,= 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } } > + (1) Should be called gEdkiiVariablePolicyProtocolGuid, IMO. Similarly, all VARIABLE_POLICY_PROTOCOL substrings should be EDKII_VARIABLE_POLICY_PROTOCOL, in the protocol header file, I believe. > [PcdsFeatureFlag] > ## Indicates if the platform can support update capsule across a syst= em reset.

> # TRUE - Supports update capsule across a system reset.
> @@ -1129,6 +1132,15 @@ > # @Prompt Variable storage size. > gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000|UINT32|0x= 30000005 > > + ## Toggle for whether the VariablePolicy engine should allow disablin= g. > + # The engine is enabled at power-on, but the interface allows the pla= tform to > + # disable enforcement for servicing flexibility. If this PCD is disab= led, it will block the ability to > + # disable the enforcement and VariablePolicy enforcement will always = be ON. > + # TRUE - VariablePolicy can be disabled by request through the inte= rface (until interface is locked) > + # FALSE - VariablePolicy interface will not accept requests to disa= ble and is ALWAYS ON > + # @Prompt Allow VariablePolicy enforcement to be disabled. > + gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDisab= le|FALSE|BOOLEAN|0x30000020 > + > ## FFS filename to find the ACPI tables. > # @Prompt FFS name of ACPI tables storage. > gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile|{ 0x25, 0x4e, = 0x37, 0x7e, 0x01, 0x8e, 0xee, 0x4f, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6,= 0xcd }|VOID*|0x30000016 > (2) This patch should update "MdeModulePkg.uni" in tandem with "MdeModulePkg.dec", I think. Thanks Laszlo --_000_CY4PR21MB0743D5B051A7B8FAD03BCE06EFBF0CY4PR21MB0743namp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

I don=92t entirely disagree with the name suggestio= n, but it=92s pretty late in the process. If it=92s not a hard-stop, I=92d = rather not.

 

Other change has been made.

 

- Bret

 

From: Laszlo Ersek via groups.io=
Sent: Tuesday, May 12, 2020 5:19 AM
To: devel@edk2.groups.io; michael.kubacki@outlook.com
Cc: Jian J Wang; Hao A Wu; liming.gao
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v2 01/12] MdeModulePkg:= Define the VariablePolicy protocol interface

 

On 05/12/20 08:46, M= ichael Kubacki wrote:
> From: Bret Barkelew <brbarkel@microsoft.com>
>
> https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbugzil= la.tianocore.org%2Fshow_bug.cgi%3Fid%3D2522&amp;data=3D02%7C01%7CBret.B= arkelew%40microsoft.com%7Cf9d61ace6d7d42a2b9c008d7f66eb4b3%7C72f988bf86f141= af91ab2d7cd011db47%7C1%7C0%7C637248827657827126&amp;sdata=3Ds80j2lvjZRO= fSb9GR6g0NO0FwGN2c18v9Im8pmRRenE%3D&amp;reserved=3D0
>
> VariablePolicy is an updated interface to
> replace VarLock and VarCheckProtocol.
>
> Add the VariablePolicy protocol interface
> header and add to the MdeModulePkg.dec file.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com><= br> > ---
>  MdeModulePkg/Include/Protocol/VariablePolicy.h | 157 ++= +++++++++++++++= +++
>  MdeModulePkg/MdeModulePkg.dec     &nbs= p;            | = ; 14 +-
>  2 files changed, 170 insertions(+), 1 deletion(-)
>
> diff --git a/MdeModulePkg/Include/Protocol/VariablePolicy.h b/MdeModu= lePkg/Include/Protocol/VariablePolicy.h
> new file mode 100644
> index 000000000000..2cd025860554
> --- /dev/null
> +++ b/MdeModulePkg/Include/Protocol/VariablePolicy.h
> @@ -0,0 +1,157 @@
> +/** @file -- VariablePolicy.h
> +
> +This protocol allows communication with Variable Policy Engine.<= br> > +
> +Copyright (c) Microsoft Corporation.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#ifndef __VARIABLE_POLICY_PROTOCOL__
> +#define __VARIABLE_POLICY_PROTOCOL__
> +
> +#define VARIABLE_POLICY_PROTOCOL_REVISION   0x00000000= 00010000
> +
> +#define VARIABLE_POLICY_PROTOCOL_GUID \
> +  { \
> +    0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9= A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } \
> +  }
> +
> +#define VARIABLE_POLICY_ENTRY_REVISION    &n= bsp; 0x00010000
> +
> +#pragma pack(push, 1)
> +typedef struct {
> +  UINT32   Version;
> +  UINT16   Size;
> +  UINT16   OffsetToName;
> +  EFI_GUID Namespace;
> +  UINT32   MinSize;
> +  UINT32   MaxSize;
> +  UINT32   AttributesMustHave;
> +  UINT32   AttributesCantHave;
> +  UINT8    LockPolicyType;
> +  UINT8    Padding[3];
> +  // UINT8    LockPolicy[];   = ;  // Variable Length Field
> +  // CHAR16   Name[]     = ;       // Variable Length Field
> +} VARIABLE_POLICY_ENTRY;
> +
> +#define     VARIABLE_POLICY_NO_MIN_SIZE = ;            0
> +#define     VARIABLE_POLICY_NO_MAX_SIZE = ;            MAX_UIN= T32
> +#define     VARIABLE_POLICY_NO_MUST_ATTR&nbs= p;           0
> +#define     VARIABLE_POLICY_NO_CANT_ATTR&nbs= p;           0
> +
> +#define     VARIABLE_POLICY_TYPE_NO_LOCK&nbs= p;           0
> +#define     VARIABLE_POLICY_TYPE_LOCK_NOW&nb= sp;          1
> +#define     VARIABLE_POLICY_TYPE_LOCK_ON_CRE= ATE     2
> +#define     VARIABLE_POLICY_TYPE_LOCK_ON_VAR= _STATE  3
> +
> +typedef struct {
> +  EFI_GUID Namespace;
> +  UINT8    Value;
> +  UINT8    Padding;
> +  // CHAR16   Name[];    &nbs= p;      // Variable Length Field
> +} VARIABLE_LOCK_ON_VAR_STATE_POLICY;
> +#pragma pack(pop)
> +
> +/**
> +  This API function disables the variable policy enforcemen= t. If it's
> +  already been called once, will return EFI_ALREADY_STARTED= .
> +
> +  @retval     EFI_SUCCESS
> +  @retval     EFI_ALREADY_STARTED =   Has already been called once this boot.
> +  @retval     EFI_WRITE_PROTECTED =   Interface has been locked until reboot.
> +  @retval     EFI_WRITE_PROTECTED =   Interface option is disabled by platform PCD.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *DISABLE_VARIABLE_POLICY)(
> +  VOID
> +  );
> +
> +/**
> +  This API function returns whether or not the policy engin= e is
> +  currently being enforced.
> +
> +  @param[out]   State    &nbs= p;  Pointer to a return value for whether the policy enforcement
> +          &nbs= p;            &= nbsp;    is currently enabled.
> +
> +  @retval     EFI_SUCCESS
> +  @retval     Others   &= nbsp;    An error has prevented this command from completing= .
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *IS_VARIABLE_POLICY_ENABLED)(
> +  OUT BOOLEAN *State
> +  );
> +
> +/**
> +  This API function validates and registers a new policy wi= th
> +  the policy enforcement engine.
> +
> +  @param[in]  NewPolicy     Pointe= r to the incoming policy structure.
> +
> +  @retval     EFI_SUCCESS
> +  @retval     EFI_INVALID_PARAMETER&nbs= p;  NewPolicy is NULL or is internally inconsistent.
> +  @retval     EFI_ALREADY_STARTED =     An identical matching policy already exists.
> +  @retval     EFI_WRITE_PROTECTED =     The interface has been locked until the next reboot.
> +  @retval     EFI_ABORTED  &n= bsp;          A calculation er= ror has prevented this function from completing.
> +  @retval     EFI_OUT_OF_RESOURCES = ;   Cannot grow the table to hold any more policies.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *REGISTER_VARIABLE_POLICY)(
> +  IN VARIABLE_POLICY_ENTRY *PolicyEntry
> +  );
> +
> +/**
> +  This API function will dump the entire contents of the va= riable policy table.
> +
> +  Similar to GetVariable, the first call can be made with a= 0 size and it will return
> +  the size of the buffer required to hold the entire table.=
> +
> +  @param[out]     Policy  Pointer = to the policy buffer. Can be NULL if Size is 0.
> +  @param[in,out]  Size    On input, the= size of the output buffer. On output, the size
> +          &nbs= p;            &= nbsp;  of the data returned.
> +
> +  @retval     EFI_SUCCESS  &n= bsp;          Policy data is i= n the output buffer and Size has been updated.
> +  @retval     EFI_INVALID_PARAMETER&nbs= p;  Size is NULL, or Size is non-zero and Policy is NULL.
> +  @retval     EFI_BUFFER_TOO_SMALL = ;   Size is insufficient to hold policy. Size updated with requir= ed size.
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *DUMP_VARIABLE_POLICY)(
> +  IN OUT UINT8  *Policy,
> +  IN OUT UINT32 *Size
> +  );
> +
> +/**
> +  This API function locks the interface so that no more pol= icy updates
> +  can be performed or changes made to the enforcement until= the next boot.
> +
> +  @retval     EFI_SUCCESS
> +  @retval     Others   &= nbsp;    An error has prevented this command from completing= .
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *LOCK_VARIABLE_POLICY)(
> +  VOID
> +  );
> +
> +typedef struct {
> +  UINT64        &nb= sp;            Revis= ion;
> +  DISABLE_VARIABLE_POLICY    DisableVariable= Policy;
> +  IS_VARIABLE_POLICY_ENABLED IsVariablePolicyEnabled;
> +  REGISTER_VARIABLE_POLICY   RegisterVariablePoli= cy;
> +  DUMP_VARIABLE_POLICY       = DumpVariablePolicy;
> +  LOCK_VARIABLE_POLICY       = LockVariablePolicy;
> +} _VARIABLE_POLICY_PROTOCOL;
> +
> +typedef _VARIABLE_POLICY_PROTOCOL VARIABLE_POLICY_PROTOCOL;
> +
> +extern EFI_GUID gVariablePolicyProtocolGuid;
> +
> +#endif
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePk= g.dec
> index 4f44af694862..f74fea00b6e7 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -8,7 +8,7 @@
>  # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>= ;
>  # (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Developm= ent LP<BR>
>  # Copyright (c) 2017, AMD Incorporated. All rights reserved.<= ;BR>
> -# Copyright (c) 2016, Microsoft Corporation<BR>
> +# Copyright (c) Microsoft Corporation.<BR>
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
>  ##
> @@ -624,6 +624,9 @@
>  #   0x80000006 | Incorrect error code provided.
>  #

> +  ## Include/Protocol/VariablePolicy.h
> +  gVariablePolicyProtocolGuid =3D { 0x81D1675C, 0x86F6, 0x4= 8DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } }
> +

(1) Should be called gEdkiiVariablePolicyProtocolGuid, IMO.

Similarly, all VARIABLE_POLICY_PROTOCOL substrings should be
EDKII_VARIABLE_POLICY_PROTOCOL, in the protocol header file, I believe.
>  [PcdsFeatureFlag]
>    ## Indicates if the platform can support update cap= sule across a system reset.<BR><BR>
>    #   TRUE  - Supports update capsule = across a system reset.<BR>
> @@ -1129,6 +1132,15 @@
>    # @Prompt Variable storage size.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize= |0x10000|UINT32|0x30000005

> +  ## Toggle for whether the VariablePolicy engine should al= low disabling.
> +  # The engine is enabled at power-on, but the interface al= lows the platform to
> +  # disable enforcement for servicing flexibility. If this = PCD is disabled, it will block the ability to
> +  # disable the enforcement and VariablePolicy enforcement = will always be ON.
> +  #   TRUE - VariablePolicy can be disabled by re= quest through the interface (until interface is locked)
> +  #   FALSE - VariablePolicy interface will not a= ccept requests to disable and is ALWAYS ON
> +  # @Prompt Allow VariablePolicy enforcement to be disabled= .
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnfo= rcementDisable|FALSE|BOOLEAN|0x30000020
> +
>    ## FFS filename to find the ACPI tables.
>    # @Prompt FFS name of ACPI tables storage.
>    gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageF= ile|{ 0x25, 0x4e, 0x37, 0x7e, 0x01, 0x8e, 0xee, 0x4f, 0x87, 0xf2, 0x39, 0xc= , 0x23, 0xc6, 0x6, 0xcd }|VOID*|0x30000016
>

(2) This patch should update "MdeModulePkg.uni" in tandem with "MdeModulePkg.dec", I think.

Thanks
Laszlo


 

--_000_CY4PR21MB0743D5B051A7B8FAD03BCE06EFBF0CY4PR21MB0743namp_--