From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.92.41.66]) by mx.groups.io with SMTP id smtpd.web12.3154.1586543905229349522 for ; Fri, 10 Apr 2020 11:38:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=udZxkLd4; spf=pass (domain: outlook.com, ip: 40.92.41.66, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WsyYMs+ys0p8rgvxmXAft9eukAuuFyCEBrww9g2vGB9vtsfW8qV0Z+t6W4eG2FO24MId1sBZP+KJFioNLOr1JsxlZKAa9VJ5BR8c/ZHFYpb/TIp/KrSLGtXoVpx4IpsT9vJhDs7QLQJmUl8aJNg1ig0L0blLo/T9e1QtOhxGWXzAPHQdjO/Rxk1UywB8cLgaRSEwIk94HdmtyCXOGDnEeSjt0EgOzoVYmpaLV3u+VSKW5ADaVaTfCedkwFWnagjNSQcjGkXgX0j7ruIkNK4ukhSoo6ZpP/KdYnadSdmLX77x+nJpvtZfRCUB1C33z6Ipn+bcGahZw2Wgub9YEJ4yyw== 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=L/XV8FLmH7eSwkse+z+KM4rXoVJ7nGtc4Xvbxg/q5ZA=; b=TaZhaZQUPhSFB8CFkJAWTqMjh4AHf/vr/UnWjTfEJCSetJvcei0F7PN2+NXoRvQqudfUfMJIZZZv64Oxjr91ePBr76KyikA3EWRQFTexeQ9kgvFbJFPnYcPeZIpOivgbmumubFmHtRVaMx9ksycS7kim0E0Xp4unzWcJlOGQXIBXirCtlyW94lHQl0aEw8aFAJccSqUN9Sg3psCPzX6SZbm7k2s+Ua4l6pQBXnvcH7yi47TCH6e2tBG0qn9ujmhke5DO43vw/pr+sQVIrxl+X+PWFNyPY5BN3nUFrDI9HoxPsYk+GjqIymxe9mgSF9pvBedY21oP9WDHzj+GM4023g== 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=L/XV8FLmH7eSwkse+z+KM4rXoVJ7nGtc4Xvbxg/q5ZA=; b=udZxkLd4u6kXEKbQqbsHTQsUoNjg8C+ivMveIbllVWUmO9wDC88Ewe+ek2XwSn8tXF6SpVtQzIPhiNj+BwWgbCwi6K67h21v2F3v9wm2nxoA2wjj7JtYME+LH3YoFSBGhh0Q1UvDb5IddVYmFtj15ZkUwnWA7Y+STHCp7aEht/mArKiHSDOuW2Dx87dV9Yj3hTbZipu4ox3Y0tG3jdpbYx6OdGyavJeLb07BkDV1M4Mphq72ePE3fHYbWCexcC9+7fg2M0FjaLEY/BvPInw7JcEAPQSEqwIAsmPsSHXMEQ2o35+poYm1W6fU43pq5iI4QUyM+NfLcey6r1+TrqLsXg== Received: from DM6NAM10FT037.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::40) by DM6NAM10HT128.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15; Fri, 10 Apr 2020 18:38:24 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e86::44) by DM6NAM10FT037.mail.protection.outlook.com (2a01:111:e400:7e86::285) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Fri, 10 Apr 2020 18:38:24 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4D9040F1AD291C6E407348364C52DAE2F05B59EA88BA5F90ECC138A2268D3A12;UpperCasedChecksum:4D7ABE6C97AE4960422B610748F82C24546450167C34D5578E5448915091D421;SizeAsReceived:7640;Count:47 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3%6]) with mapi id 15.20.2900.015; Fri, 10 Apr 2020 18:38:24 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Liming Gao Subject: [PATCH v1 1/9] MdeModulePkg: Define the VariablePolicy protocol interface Date: Fri, 10 Apr 2020 11:37:54 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 X-ClientProxiedBy: MWHPR20CA0007.namprd20.prod.outlook.com (2603:10b6:300:13d::17) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200410183802.21192-1-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:9:2d7c:9ade:505:3bf5) by MWHPR20CA0007.namprd20.prod.outlook.com (2603:10b6:300:13d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.17 via Frontend Transport; Fri, 10 Apr 2020 18:38:23 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200410183802.21192-1-michael.kubacki@outlook.com> X-TMN: [kruuiKs1ynL0haiyasmFUYCEm/5NKTf/zz8IzcNUhkHm1Tbf92VaWY+S7T6wF+4Z] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ca238171-a775-41ae-efdb-08d7dd7e59db X-MS-TrafficTypeDiagnostic: DM6NAM10HT128: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0/pYZHaLe1fOgLTD4+0aelrrAW0Lf+UGWgfJ+60mRMwcOU/U73GQ0e6KNMPGtQGGjL5MrQqdI5rilm2QUL6KHxMwyX/ffpuTOKk6Gsf9+gaUFpVoVndT9RZa2McinoUeguv3sxnN44y5115XnjQLUcMv7WbD+E5PMFjcG1gMm5ANLNxi7AJej6BjEP4PT6S/+Q/t56FsksMEppi/5mtqElR8JOrjRk0Qv0JqvGIeUOc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR07MB3440.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: QxeZzGwituSOYX21TZ78sVbzT7j7XaX/LDZE5FvZAp9ax638WcHD7pZD3/mNf8tmyPcIzv6QocWGSuVCEkznm0dIQQ/RtaPPOXpnvWoaP2hiSc8N/roQ2ipN8wcxcAfYb06BJp0mZhzg3JvT4lEYw1+kabgDKw94FiPp/b3amU4bl6KO14FdMqaweZgxZ8zis37uwl1ClSnonYp+5eOtUA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca238171-a775-41ae-efdb-08d7dd7e59db X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2020 18:38:24.1277 (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: DM6NAM10HT128 Content-Type: text/plain From: Bret Barkelew https://bugzilla.tianocore.org/show_bug.cgi?id=2522 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: Bret Barkelew Signed-off-by: Michael Kubacki --- MdeModulePkg/Include/Protocol/VariablePolicy.h | 156 ++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 5 +- 2 files changed, 160 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Include/Protocol/VariablePolicy.h b/MdeModulePkg/Include/Protocol/VariablePolicy.h new file mode 100644 index 000000000000..602431eeb540 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/VariablePolicy.h @@ -0,0 +1,156 @@ +/** @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, 0x25, 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 boot. + @retval EFI_WRITE_PROTECTED Interface has been locked until reboot. + +**/ +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 policy enforcement + is currently enabled. + + @retval EFI_SUCCESS + @retval Others 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 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 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 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 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 + of the data returned. + + @retval EFI_SUCCESS Policy data is in the output buffer 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 policy. 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 boot. + + @retval EFI_SUCCESS + @retval Others An error has prevented this command from completing. + +**/ +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.dec index 91a3c608231c..956276e30a72 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 # ## @@ -623,6 +623,9 @@ # 0x80000006 | Incorrect error code provided. # + ## Include/Protocol/VariablePolicy.h + gVariablePolicyProtocolGuid = { 0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } } + [PcdsFeatureFlag] ## Indicates if the platform can support update capsule across a system reset.

# TRUE - Supports update capsule across a system reset.
-- 2.16.3.windows.1