TianoCore EDK2 master
Loading...
Searching...
No Matches
WsmtGenerator.c
Go to the documentation of this file.
1
13#include <AcpiTableGenerator.h>
18#include <Library/DebugLib.h>
20#include <Protocol/AcpiTable.h>
22#include <X64NameSpaceObjects.h>
23
24#define WSMT_PROTECTION_VALID_FLAGS \
25 (EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS | \
26 EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION | \
27 EFI_WSMT_PROTECTION_FLAGS_SYSTEM_RESOURCE_PROTECTION)
28
36 );
37
43 EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE,
45 EFI_WSMT_TABLE_REVISION
46 ),
47 // ProtectionFlags
48 0
49};
50
66EFIAPI
69 )
70{
71 EFI_STATUS Status;
72 CM_X64_WSMT_FLAGS_INFO *WsmtFlagInfo;
73
74 ASSERT (CfgMgrProtocol != NULL);
75
76 // Get the WSMT protection flag from the Platform Configuration Manager
77 Status = GetEX64ObjWsmtFlagsInfo (
78 CfgMgrProtocol,
80 &WsmtFlagInfo,
81 NULL
82 );
83 if (EFI_ERROR (Status)) {
84 DEBUG ((
85 DEBUG_ERROR,
86 "ERROR: WSMT: Failed to get WSMT protection flag information." \
87 " Status = %r\n",
88 Status
89 ));
90 return Status;
91 }
92
93 DEBUG ((
94 DEBUG_INFO,
95 "WSMT: Protection flags = 0x%x\n",
96 WsmtFlagInfo->ProtectionFlags
97 ));
98
99 // Validate the protection flags
100 if ((WsmtFlagInfo->ProtectionFlags & ~WSMT_PROTECTION_VALID_FLAGS) != 0) {
101 DEBUG ((
102 DEBUG_ERROR,
103 "ERROR: WSMT: Invalid protection flags = 0x%x\n",
104 WsmtFlagInfo->ProtectionFlags
105 ));
106 return EFI_UNSUPPORTED;
107 }
108
109 if ((WsmtFlagInfo->ProtectionFlags & EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION) != 0) {
110 if ((WsmtFlagInfo->ProtectionFlags & EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS) == 0) {
111 DEBUG ((
112 DEBUG_ERROR,
113 "ERROR: WSMT: Invalid protection flags. EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS not set.\n"
114 ));
115 return EFI_UNSUPPORTED;
116 }
117 }
118
119 AcpiWsmt.ProtectionFlags = WsmtFlagInfo->ProtectionFlags;
120 return Status;
121}
122
144STATIC
146EFIAPI
152 )
153{
154 EFI_STATUS Status;
155
156 ASSERT (This != NULL);
157 ASSERT (AcpiTableInfo != NULL);
158 ASSERT (CfgMgrProtocol != NULL);
159 ASSERT (Table != NULL);
160 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
161 ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
162
163 if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||
164 (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision))
165 {
166 DEBUG ((
167 DEBUG_ERROR,
168 "ERROR: WSMT: Requested table revision = %d, is not supported."
169 "Supported table revision: Minimum = %d, Maximum = %d\n",
170 AcpiTableInfo->AcpiTableRevision,
171 This->MinAcpiTableRevision,
172 This->AcpiTableRevision
173 ));
174 return EFI_INVALID_PARAMETER;
175 }
176
177 *Table = NULL;
178
179 Status = AddAcpiHeader (
180 CfgMgrProtocol,
181 This,
183 AcpiTableInfo,
185 );
186 if (EFI_ERROR (Status)) {
187 DEBUG ((
188 DEBUG_ERROR,
189 "ERROR: WSMT: Failed to add ACPI header. Status = %r\n",
190 Status
191 ));
192 goto error_handler;
193 }
194
195 // Update protection flags Info
196 Status = WsmtAddProtectionFlagsInfo (CfgMgrProtocol);
197 if (EFI_ERROR (Status)) {
198 goto error_handler;
199 }
200
202error_handler:
203 return Status;
204}
205
208#define WSMT_GENERATOR_REVISION CREATE_REVISION (1, 0)
209
212STATIC
213CONST
215 // Generator ID
217 // Generator Description
218 L"ACPI.STD.WSMT.GENERATOR",
219 // ACPI Table Signature
220 EFI_ACPI_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE,
221 // ACPI Table Revision supported by this Generator
222 EFI_WSMT_TABLE_REVISION,
223 // Minimum supported ACPI Table Revision
224 EFI_WSMT_TABLE_REVISION,
225 // Creator ID
227 // Creator Revision
229 // Build Table function
231 // No additional resources are allocated by the generator.
232 // Hence the Free Resource function is not required.
233 NULL,
234 // Extended build function not needed
235 NULL,
236 // Extended build function not implemented by the generator.
237 // Hence extended free resource function is not required.
238 NULL
239};
240
252EFIAPI
254 IN EFI_HANDLE ImageHandle,
255 IN EFI_SYSTEM_TABLE *SystemTable
256 )
257{
258 EFI_STATUS Status;
259
261 DEBUG ((DEBUG_INFO, "WSMT: Register Generator. Status = %r\n", Status));
262 ASSERT_EFI_ERROR (Status);
263 return Status;
264}
265
276EFIAPI
278 IN EFI_HANDLE ImageHandle,
279 IN EFI_SYSTEM_TABLE *SystemTable
280 )
281{
282 EFI_STATUS Status;
283
285 DEBUG ((DEBUG_INFO, "WSMT: Deregister Generator. Status = %r\n", Status));
286 ASSERT_EFI_ERROR (Status);
287 return Status;
288}
EFI_STATUS EFIAPI RegisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
EFI_STATUS EFIAPI DeregisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
#define CREATE_STD_ACPI_TABLE_GEN_ID(TableId)
#define TABLE_GENERATOR_CREATOR_ID
@ EStdAcpiTableIdWsmt
WSMT Generator.
#define ACPI_HEADER(Signature, Type, Revision)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceX64
X64 Objects Namespace.
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define CM_NULL_TOKEN
EFI_STATUS EFIAPI AddAcpiHeader(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST ACPI_TABLE_GENERATOR *CONST Generator, IN OUT EFI_ACPI_DESCRIPTION_HEADER *CONST AcpiHeader, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST UINT32 Length)
Definition: TableHelper.c:114
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
STATIC EFI_STATUS EFIAPI WsmtAddProtectionFlagsInfo(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol)
Definition: WsmtGenerator.c:67
EFI_STATUS EFIAPI AcpiWsmtLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC CONST ACPI_TABLE_GENERATOR WsmtGenerator
STATIC EFI_ACPI_WSMT_TABLE AcpiWsmt
Definition: WsmtGenerator.c:41
#define WSMT_GENERATOR_REVISION
EFI_STATUS EFIAPI AcpiWsmtLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC EFI_STATUS EFIAPI BuildWsmtTable(IN CONST ACPI_TABLE_GENERATOR *CONST This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table)
@ EX64ObjWsmtFlagsInfo
10 - WSMT protection flags info