]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Define the VariablePolicy protocol interface
authorBret Barkelew <brbarkel@microsoft.com>
Mon, 9 Nov 2020 06:45:10 +0000 (14:45 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 17 Nov 2020 01:03:43 +0000 (01:03 +0000)
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 <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bret Barkelew <brbarkel@microsoft.com>
Signed-off-by: Bret Barkelew <brbarkel@microsoft.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Acked-by: Jian J Wang <jian.j.wang@intel.com>
MdeModulePkg/Include/Protocol/VariablePolicy.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.uni

diff --git a/MdeModulePkg/Include/Protocol/VariablePolicy.h b/MdeModulePkg/Include/Protocol/VariablePolicy.h
new file mode 100644 (file)
index 0000000..8226c18
--- /dev/null
@@ -0,0 +1,157 @@
+/** @file -- VariablePolicy.h\r
+\r
+This protocol allows communication with Variable Policy Engine.\r
+\r
+Copyright (c) Microsoft Corporation.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef __EDKII_VARIABLE_POLICY_PROTOCOL__\r
+#define __EDKII_VARIABLE_POLICY_PROTOCOL__\r
+\r
+#define EDKII_VARIABLE_POLICY_PROTOCOL_REVISION   0x0000000000010000\r
+\r
+#define EDKII_VARIABLE_POLICY_PROTOCOL_GUID \\r
+  { \\r
+    0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } \\r
+  }\r
+\r
+#define VARIABLE_POLICY_ENTRY_REVISION      0x00010000\r
+\r
+#pragma pack(push, 1)\r
+typedef struct {\r
+  UINT32   Version;\r
+  UINT16   Size;\r
+  UINT16   OffsetToName;\r
+  EFI_GUID Namespace;\r
+  UINT32   MinSize;\r
+  UINT32   MaxSize;\r
+  UINT32   AttributesMustHave;\r
+  UINT32   AttributesCantHave;\r
+  UINT8    LockPolicyType;\r
+  UINT8    Padding[3];\r
+  // UINT8    LockPolicy[];     // Variable Length Field\r
+  // CHAR16   Name[]            // Variable Length Field\r
+} VARIABLE_POLICY_ENTRY;\r
+\r
+#define     VARIABLE_POLICY_NO_MIN_SIZE             0\r
+#define     VARIABLE_POLICY_NO_MAX_SIZE             MAX_UINT32\r
+#define     VARIABLE_POLICY_NO_MUST_ATTR            0\r
+#define     VARIABLE_POLICY_NO_CANT_ATTR            0\r
+\r
+#define     VARIABLE_POLICY_TYPE_NO_LOCK            0\r
+#define     VARIABLE_POLICY_TYPE_LOCK_NOW           1\r
+#define     VARIABLE_POLICY_TYPE_LOCK_ON_CREATE     2\r
+#define     VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE  3\r
+\r
+typedef struct {\r
+  EFI_GUID Namespace;\r
+  UINT8    Value;\r
+  UINT8    Padding;\r
+  // CHAR16   Name[];           // Variable Length Field\r
+} VARIABLE_LOCK_ON_VAR_STATE_POLICY;\r
+#pragma pack(pop)\r
+\r
+/**\r
+  This API function disables the variable policy enforcement. If it's\r
+  already been called once, will return EFI_ALREADY_STARTED.\r
+\r
+  @retval     EFI_SUCCESS\r
+  @retval     EFI_ALREADY_STARTED   Has already been called once this boot.\r
+  @retval     EFI_WRITE_PROTECTED   Interface has been locked until reboot.\r
+  @retval     EFI_WRITE_PROTECTED   Interface option is disabled by platform PCD.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *DISABLE_VARIABLE_POLICY)(\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This API function returns whether or not the policy engine is\r
+  currently being enforced.\r
+\r
+  @param[out]   State       Pointer to a return value for whether the policy enforcement\r
+                            is currently enabled.\r
+\r
+  @retval     EFI_SUCCESS\r
+  @retval     Others        An error has prevented this command from completing.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *IS_VARIABLE_POLICY_ENABLED)(\r
+  OUT BOOLEAN *State\r
+  );\r
+\r
+/**\r
+  This API function validates and registers a new policy with\r
+  the policy enforcement engine.\r
+\r
+  @param[in]  NewPolicy     Pointer to the incoming policy structure.\r
+\r
+  @retval     EFI_SUCCESS\r
+  @retval     EFI_INVALID_PARAMETER   NewPolicy is NULL or is internally inconsistent.\r
+  @retval     EFI_ALREADY_STARTED     An identical matching policy already exists.\r
+  @retval     EFI_WRITE_PROTECTED     The interface has been locked until the next reboot.\r
+  @retval     EFI_ABORTED             A calculation error has prevented this function from completing.\r
+  @retval     EFI_OUT_OF_RESOURCES    Cannot grow the table to hold any more policies.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *REGISTER_VARIABLE_POLICY)(\r
+  IN CONST VARIABLE_POLICY_ENTRY  *PolicyEntry\r
+  );\r
+\r
+/**\r
+  This API function will dump the entire contents of the variable policy table.\r
+\r
+  Similar to GetVariable, the first call can be made with a 0 size and it will return\r
+  the size of the buffer required to hold the entire table.\r
+\r
+  @param[out]     Policy  Pointer to the policy buffer. Can be NULL if Size is 0.\r
+  @param[in,out]  Size    On input, the size of the output buffer. On output, the size\r
+                          of the data returned.\r
+\r
+  @retval     EFI_SUCCESS             Policy data is in the output buffer and Size has been updated.\r
+  @retval     EFI_INVALID_PARAMETER   Size is NULL, or Size is non-zero and Policy is NULL.\r
+  @retval     EFI_BUFFER_TOO_SMALL    Size is insufficient to hold policy. Size updated with required size.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *DUMP_VARIABLE_POLICY)(\r
+  IN OUT UINT8  *Policy,\r
+  IN OUT UINT32 *Size\r
+  );\r
+\r
+/**\r
+  This API function locks the interface so that no more policy updates\r
+  can be performed or changes made to the enforcement until the next boot.\r
+\r
+  @retval     EFI_SUCCESS\r
+  @retval     Others        An error has prevented this command from completing.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *LOCK_VARIABLE_POLICY)(\r
+  VOID\r
+  );\r
+\r
+typedef struct {\r
+  UINT64                     Revision;\r
+  DISABLE_VARIABLE_POLICY    DisableVariablePolicy;\r
+  IS_VARIABLE_POLICY_ENABLED IsVariablePolicyEnabled;\r
+  REGISTER_VARIABLE_POLICY   RegisterVariablePolicy;\r
+  DUMP_VARIABLE_POLICY       DumpVariablePolicy;\r
+  LOCK_VARIABLE_POLICY       LockVariablePolicy;\r
+} _EDKII_VARIABLE_POLICY_PROTOCOL;\r
+\r
+typedef _EDKII_VARIABLE_POLICY_PROTOCOL EDKII_VARIABLE_POLICY_PROTOCOL;\r
+\r
+extern EFI_GUID gEdkiiVariablePolicyProtocolGuid;\r
+\r
+#endif\r
index cb30a7975849b4da9f0fb682118c603326f3aadb..82aecc40d9a9ae72df4961364f28cf43f51a817d 100644 (file)
@@ -8,7 +8,7 @@
 # Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
 # (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Development LP<BR>\r
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
-# Copyright (c) 2016, Microsoft Corporation<BR>\r
+# Copyright (c) Microsoft Corporation.<BR>\r
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
 #   0x80000006 | Incorrect error code provided.\r
 #\r
 \r
+  ## Include/Protocol/VariablePolicy.h\r
+  gEdkiiVariablePolicyProtocolGuid = { 0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } }\r
+\r
 [PcdsFeatureFlag]\r
   ## Indicates if the platform can support update capsule across a system reset.<BR><BR>\r
   #   TRUE  - Supports update capsule across a system reset.<BR>\r
   # @Prompt Variable storage size.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000|UINT32|0x30000005\r
 \r
+  ## Toggle for whether the VariablePolicy engine should allow disabling.\r
+  # The engine is enabled at power-on, but the interface allows the platform to\r
+  # disable enforcement for servicing flexibility. If this PCD is disabled, it will block the ability to\r
+  # disable the enforcement and VariablePolicy enforcement will always be ON.\r
+  #   TRUE - VariablePolicy can be disabled by request through the interface (until interface is locked)\r
+  #   FALSE - VariablePolicy interface will not accept requests to disable and is ALWAYS ON\r
+  # @Prompt Allow VariablePolicy enforcement to be disabled.\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDisable|FALSE|BOOLEAN|0x30000020\r
+\r
   ## FFS filename to find the ACPI tables.\r
   # @Prompt FFS name of ACPI tables storage.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile|{ 0x25, 0x4e, 0x37, 0x7e, 0x01, 0x8e, 0xee, 0x4f, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd }|VOID*|0x30000016\r
index b8c867379a864c602342299b41dbf791ecc23f12..40884c57a46059761e73620a1539faa3bfe2c0dd 100644 (file)
 \r
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdVariableStoreSize_HELP  #language en-US "The size of volatile buffer. This buffer is used to store VOLATILE attribute variables."\r
 \r
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAllowVariablePolicyEnforcementDisable_PROMPT  #language en-US "Allow VariablePolicy enforcement to be disabled."\r
+\r
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAllowVariablePolicyEnforcementDisable_HELP  #language en-US "If this PCD is disabled, it will block the ability to<BR>\n"\r
+                                                                                                          "disable the enforcement and VariablePolicy enforcement will always be ON.<BR>\n"\r
+                                                                                                          "TRUE - VariablePolicy can be disabled by request through the interface (until interface is locked)<BR>\n"\r
+                                                                                                          "FALSE - VariablePolicy interface will not accept requests to disable and is ALWAYS ON<BR>\n"\r
+\r
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiTableStorageFile_PROMPT  #language en-US "FFS name of ACPI tables storage"\r
 \r
 #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdAcpiTableStorageFile_HELP  #language en-US "FFS filename to find the ACPI tables."\r