]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.c
SecurityPkg: Remove Counter Based AuthVariable support
[mirror_edk2.git] / SecurityPkg / Tcg / MemoryOverwriteRequestControlLock / TcgMorLockSmm.c
CommitLineData
70c7664c
JY
1/** @file\r
2 TCG MOR (Memory Overwrite Request) Lock Control Driver SMM wrapper.\r
3 \r
4Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiSmm.h>\r
16#include <Library/SmmServicesTableLib.h>\r
17#include <Library/DebugLib.h>\r
18#include <Protocol/SmmVarCheck.h>\r
19#include <Protocol/SmmVariable.h>\r
20#include "TcgMorLock.h"\r
21\r
22EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable;\r
23\r
24/**\r
25 This service is a wrapper for the UEFI Runtime Service GetVariable().\r
26\r
27 @param VariableName the name of the vendor's variable, it's a Null-Terminated Unicode String\r
28 @param VendorGuid Unify identifier for vendor.\r
29 @param Attributes Point to memory location to return the attributes of variable. If the point\r
30 is NULL, the parameter would be ignored.\r
31 @param DataSize As input, point to the maximum size of return Data-Buffer.\r
32 As output, point to the actual size of the returned Data-Buffer.\r
33 @param Data Point to return Data-Buffer.\r
34\r
35 @retval EFI_SUCCESS The function completed successfully.\r
36 @retval EFI_NOT_FOUND The variable was not found.\r
37 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has\r
38 been updated with the size needed to complete the request.\r
39 @retval EFI_INVALID_PARAMETER VariableName is NULL.\r
40 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.\r
41 @retval EFI_INVALID_PARAMETER DataSize is NULL.\r
42 @retval EFI_INVALID_PARAMETER The DataSize is not too small and Data is NULL.\r
43 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r
44 @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r
45**/\r
46EFI_STATUS\r
47EFIAPI\r
48InternalGetVariable (\r
49 IN CHAR16 *VariableName,\r
50 IN EFI_GUID *VendorGuid,\r
51 OUT UINT32 *Attributes OPTIONAL,\r
52 IN OUT UINTN *DataSize,\r
53 OUT VOID *Data\r
54 )\r
55{\r
56 return mSmmVariable->SmmGetVariable (\r
57 VariableName,\r
58 VendorGuid,\r
59 Attributes,\r
60 DataSize,\r
61 Data\r
62 );\r
63}\r
64\r
65/**\r
66 This service is a wrapper for the UEFI Runtime Service SetVariable()\r
67\r
68 @param VariableName the name of the vendor's variable, as a\r
69 Null-Terminated Unicode String\r
70 @param VendorGuid Unify identifier for vendor.\r
71 @param Attributes Point to memory location to return the attributes of variable. If the point\r
72 is NULL, the parameter would be ignored.\r
73 @param DataSize The size in bytes of Data-Buffer.\r
74 @param Data Point to the content of the variable.\r
75\r
76 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r
77 defined by the Attributes.\r
78 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the\r
79 DataSize exceeds the maximum allowed.\r
80 @retval EFI_INVALID_PARAMETER VariableName is an empty Unicode string.\r
81 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
82 @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.\r
83 @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r
84 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r
0130fdde 85 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\r
70c7664c
JY
86 set but the AuthInfo does NOT pass the validation check carried\r
87 out by the firmware.\r
88 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r
89\r
90**/\r
91EFI_STATUS\r
92EFIAPI\r
93InternalSetVariable (\r
94 IN CHAR16 *VariableName,\r
95 IN EFI_GUID *VendorGuid,\r
96 IN UINT32 Attributes,\r
97 IN UINTN DataSize,\r
98 IN VOID *Data\r
99 )\r
100{\r
101 return mSmmVariable->SmmSetVariable (\r
102 VariableName,\r
103 VendorGuid,\r
104 Attributes,\r
105 DataSize,\r
106 Data\r
107 );\r
108}\r
109\r
110/**\r
111 Entry Point for MOR Lock Control driver.\r
112\r
113 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
114 @param[in] SystemTable A pointer to the EFI System Table.\r
115\r
116 @retval EFI_SUCCESS EntryPoint runs successfully.\r
117\r
118**/\r
119EFI_STATUS\r
120EFIAPI\r
121MorLockDriverEntryPointSmm (\r
122 IN EFI_HANDLE ImageHandle,\r
123 IN EFI_SYSTEM_TABLE *SystemTable\r
124 )\r
125{\r
126 EFI_STATUS Status;\r
127 EDKII_SMM_VAR_CHECK_PROTOCOL *SmmVarCheck;\r
128\r
129 //\r
130 // This driver link to Smm Variable driver\r
131 //\r
132 DEBUG ((EFI_D_INFO, "MorLockDriverEntryPointSmm\n"));\r
133 \r
134 Status = gSmst->SmmLocateProtocol (\r
135 &gEfiSmmVariableProtocolGuid,\r
136 NULL,\r
137 (VOID **) &mSmmVariable\r
138 );\r
139 ASSERT_EFI_ERROR (Status);\r
140\r
141 Status = gSmst->SmmLocateProtocol (\r
142 &gEdkiiSmmVarCheckProtocolGuid,\r
143 NULL,\r
144 (VOID **) &SmmVarCheck\r
145 );\r
146 ASSERT_EFI_ERROR (Status);\r
147\r
148 Status = MorLockDriverInit ();\r
149 if (EFI_ERROR (Status)) {\r
150 return Status;\r
151 }\r
152\r
153 Status = SmmVarCheck->SmmRegisterSetVariableCheckHandler (SetVariableCheckHandlerMor);\r
154 ASSERT_EFI_ERROR (Status);\r
155\r
156 return Status;\r
157}\r
158\r