2 This driver measures SMBIOS table to TPM.
4 Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Protocol/Smbios.h>
12 #include <IndustryStandard/SmBios.h>
13 #include <IndustryStandard/UefiTcgPlatform.h>
14 #include <Guid/EventGroup.h>
15 #include <Guid/SmBios.h>
16 #include <Library/DebugLib.h>
17 #include <Library/UefiDriverEntryPoint.h>
18 #include <Library/UefiLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/MemoryAllocationLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 #include <Library/PcdLib.h>
24 #include <Library/TpmMeasurementLib.h>
26 #define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
33 } SMBIOS_FILTER_TABLE
;
34 #define SMBIOS_FILTER_TABLE_FLAG_IS_STRING BIT0
38 SMBIOS_FILTER_TABLE
*Filter
; // NULL means all fields
40 } SMBIOS_FILTER_STRUCT
;
43 // Platform Specific Policy
45 SMBIOS_FILTER_TABLE mSmbiosFilterType1BlackList
[] = {
46 { 0x01, OFFSET_OF (SMBIOS_TABLE_TYPE1
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE1
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
47 { 0x01, OFFSET_OF (SMBIOS_TABLE_TYPE1
, Uuid
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE1
, Uuid
), 0 },
48 { 0x01, OFFSET_OF (SMBIOS_TABLE_TYPE1
, WakeUpType
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE1
, WakeUpType
), 0 },
50 SMBIOS_FILTER_TABLE mSmbiosFilterType2BlackList
[] = {
51 { 0x02, OFFSET_OF (SMBIOS_TABLE_TYPE2
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE2
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
52 { 0x02, OFFSET_OF (SMBIOS_TABLE_TYPE2
, LocationInChassis
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE2
, LocationInChassis
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
54 SMBIOS_FILTER_TABLE mSmbiosFilterType3BlackList
[] = {
55 { 0x03, OFFSET_OF (SMBIOS_TABLE_TYPE3
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE3
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
56 { 0x03, OFFSET_OF (SMBIOS_TABLE_TYPE3
, AssetTag
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE3
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
58 SMBIOS_FILTER_TABLE mSmbiosFilterType4BlackList
[] = {
59 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
60 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, AssetTag
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
61 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, PartNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
62 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, CoreCount
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, CoreCount
), 0 },
63 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), 0 },
64 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, ThreadCount
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, ThreadCount
), 0 },
65 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, CoreCount2
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, CoreCount2
), 0 },
66 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), 0 },
67 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, ThreadCount2
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, ThreadCount2
), 0 },
68 { 0x04, OFFSET_OF (SMBIOS_TABLE_TYPE4
, Voltage
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE4
, Voltage
), 0 },
70 SMBIOS_FILTER_TABLE mSmbiosFilterType17BlackList
[] = {
71 { 0x11, OFFSET_OF (SMBIOS_TABLE_TYPE17
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE17
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
72 { 0x11, OFFSET_OF (SMBIOS_TABLE_TYPE17
, AssetTag
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE17
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
73 { 0x11, OFFSET_OF (SMBIOS_TABLE_TYPE17
, PartNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE17
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
75 SMBIOS_FILTER_TABLE mSmbiosFilterType22BlackList
[] = {
76 { 0x16, OFFSET_OF (SMBIOS_TABLE_TYPE22
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE22
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
77 { 0x16, OFFSET_OF (SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), 0 },
78 { 0x16, OFFSET_OF (SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), 0 },
80 SMBIOS_FILTER_TABLE mSmbiosFilterType23BlackList
[] = {
81 { 0x17, OFFSET_OF (SMBIOS_TABLE_TYPE23
, ResetCount
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE23
, ResetCount
), 0 },
83 SMBIOS_FILTER_TABLE mSmbiosFilterType27BlackList
[] = {
84 { 0x1B, OFFSET_OF (SMBIOS_TABLE_TYPE27
, NominalSpeed
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE27
, NominalSpeed
), 0 },
86 SMBIOS_FILTER_TABLE mSmbiosFilterType39BlackList
[] = {
87 { 0x27, OFFSET_OF (SMBIOS_TABLE_TYPE39
, SerialNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE39
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
88 { 0x27, OFFSET_OF (SMBIOS_TABLE_TYPE39
, AssetTagNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE39
, AssetTagNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
89 { 0x27, OFFSET_OF (SMBIOS_TABLE_TYPE39
, ModelPartNumber
), FIELD_SIZE_OF (SMBIOS_TABLE_TYPE39
, ModelPartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
92 SMBIOS_FILTER_STRUCT mSmbiosFilterStandardTableBlackList
[] = {
93 { 0x01, mSmbiosFilterType1BlackList
, sizeof (mSmbiosFilterType1BlackList
)/sizeof (mSmbiosFilterType1BlackList
[0]) },
94 { 0x02, mSmbiosFilterType2BlackList
, sizeof (mSmbiosFilterType2BlackList
)/sizeof (mSmbiosFilterType2BlackList
[0]) },
95 { 0x03, mSmbiosFilterType3BlackList
, sizeof (mSmbiosFilterType3BlackList
)/sizeof (mSmbiosFilterType3BlackList
[0]) },
96 { 0x04, mSmbiosFilterType4BlackList
, sizeof (mSmbiosFilterType4BlackList
)/sizeof (mSmbiosFilterType4BlackList
[0]) },
99 { 0x11, mSmbiosFilterType17BlackList
, sizeof (mSmbiosFilterType17BlackList
)/sizeof (mSmbiosFilterType17BlackList
[0]) },
101 { 0x16, mSmbiosFilterType22BlackList
, sizeof (mSmbiosFilterType22BlackList
)/sizeof (mSmbiosFilterType22BlackList
[0]) },
102 { 0x17, mSmbiosFilterType23BlackList
, sizeof (mSmbiosFilterType23BlackList
)/sizeof (mSmbiosFilterType23BlackList
[0]) },
103 { 0x1B, mSmbiosFilterType27BlackList
, sizeof (mSmbiosFilterType27BlackList
)/sizeof (mSmbiosFilterType27BlackList
[0]) },
106 { 0x27, mSmbiosFilterType39BlackList
, sizeof (mSmbiosFilterType39BlackList
)/sizeof (mSmbiosFilterType39BlackList
[0]) },
109 EFI_SMBIOS_PROTOCOL
*mSmbios
;
114 #define SMBIOS_HANDOFF_TABLE_DESC "SmbiosTable"
116 UINT8 TableDescriptionSize
;
117 UINT8 TableDescription
[sizeof (SMBIOS_HANDOFF_TABLE_DESC
)];
118 UINT64 NumberOfTables
;
119 EFI_CONFIGURATION_TABLE TableEntry
[1];
120 } SMBIOS_HANDOFF_TABLE_POINTERS2
;
126 This function dump raw data.
129 @param Size raw data size
140 for (Index
= 0; Index
< Size
; Index
++) {
141 DEBUG ((DEBUG_VERBOSE
, "%02x", (UINTN
)Data
[Index
]));
147 This function dump raw data with colume format.
150 @param Size raw data size
163 #define COLUME_SIZE (16 * 2)
165 Count
= Size
/ COLUME_SIZE
;
166 Left
= Size
% COLUME_SIZE
;
167 for (Index
= 0; Index
< Count
; Index
++) {
168 DEBUG ((DEBUG_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
169 InternalDumpData (Data
+ Index
* COLUME_SIZE
, COLUME_SIZE
);
170 DEBUG ((DEBUG_VERBOSE
, "\n"));
174 DEBUG ((DEBUG_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
175 InternalDumpData (Data
+ Index
* COLUME_SIZE
, Left
);
176 DEBUG ((DEBUG_VERBOSE
, "\n"));
182 This function get filter structure by SMBIOS type.
184 @param Type SMBIOS type
187 SMBIOS_FILTER_STRUCT
*
188 GetFilterStructByType (
194 for (Index
= 0; Index
< sizeof (mSmbiosFilterStandardTableBlackList
)/sizeof (mSmbiosFilterStandardTableBlackList
[0]); Index
++) {
195 if (mSmbiosFilterStandardTableBlackList
[Index
].Type
== Type
) {
196 return &mSmbiosFilterStandardTableBlackList
[Index
];
205 This function get SMBIOS string in SMBIOS table.
207 @param Head SMBIOS table head
208 @param StringId SMBIOS string ID
209 @param StringLen length of SMBIOS string
211 @return SMBIOS string data
214 GetSmbiosStringById (
215 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
216 IN SMBIOS_TABLE_STRING StringId
,
226 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
231 // look for the two consecutive zeros, check the string limit by the way.
234 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
235 if (*CharInStr
== 0) {
242 for (StrLen
= 0; StrLen
< mMaxLen
; StrLen
++) {
243 if (*(CharInStr
+StrLen
) == 0) {
250 if (StrLen
== mMaxLen
) {
255 // forward the pointer
260 if (StringsNumber
== StringId
) {
270 This function update SMBIOS table based on policy.
272 @param TableEntry SMBIOS table
273 @param TableEntrySize SMBIOS table size
278 IN OUT VOID
*TableEntry
,
279 IN UINTN TableEntrySize
282 SMBIOS_FILTER_STRUCT
*FilterStruct
;
283 SMBIOS_FILTER_TABLE
*Filter
;
285 SMBIOS_TABLE_STRING StringId
;
289 DEBUG ((DEBUG_INFO
, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
291 InternalDumpHex (TableEntry
, TableEntrySize
);
295 // Skip measurement for OEM types.
297 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
>= SMBIOS_OEM_BEGIN
) {
298 // zero all table fields, except header
299 ZeroMem ((UINT8
*)TableEntry
+ sizeof (SMBIOS_STRUCTURE
), TableEntrySize
- sizeof (SMBIOS_STRUCTURE
));
301 FilterStruct
= GetFilterStructByType (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
);
302 if (FilterStruct
!= NULL
) {
303 if ((FilterStruct
->Filter
== NULL
) || (FilterStruct
->FilterCount
== 0)) {
304 // zero all table fields, except header
305 ZeroMem ((UINT8
*)TableEntry
+ sizeof (SMBIOS_STRUCTURE
), TableEntrySize
- sizeof (SMBIOS_STRUCTURE
));
307 Filter
= FilterStruct
->Filter
;
308 for (Index
= 0; Index
< FilterStruct
->FilterCount
; Index
++) {
309 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Length
>= (Filter
[Index
].Offset
+ Filter
[Index
].Size
)) {
311 // The field is present in the SMBIOS entry.
313 if ((Filter
[Index
].Flags
& SMBIOS_FILTER_TABLE_FLAG_IS_STRING
) != 0) {
314 CopyMem (&StringId
, (UINT8
*)TableEntry
+ Filter
[Index
].Offset
, sizeof (StringId
));
316 // set ' ' for string field
317 String
= GetSmbiosStringById (TableEntry
, StringId
, &StringLen
);
318 ASSERT (String
!= NULL
);
319 // DEBUG ((DEBUG_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
320 SetMem (String
, StringLen
, ' ');
324 // zero non-string field
325 ZeroMem ((UINT8
*)TableEntry
+ Filter
[Index
].Offset
, Filter
[Index
].Size
);
332 DEBUG ((DEBUG_INFO
, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
334 InternalDumpHex (TableEntry
, TableEntrySize
);
340 Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
342 @param Head Pointer to the beginning of SMBIOS structure.
343 @param NumberOfStrings The returned number of optional strings that follow the formatted structure.
345 @return Size The returned size.
348 GetSmbiosStructureSize (
349 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
350 OUT UINTN
*NumberOfStrings
358 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
363 // look for the two consecutive zeros, check the string limit by the way.
365 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
366 if (*CharInStr
== 0) {
371 for (StrLen
= 0; StrLen
< mMaxLen
; StrLen
++) {
372 if (*(CharInStr
+StrLen
) == 0) {
377 if (StrLen
== mMaxLen
) {
382 // forward the pointer
390 // count ending two zeros.
394 if (NumberOfStrings
!= NULL
) {
395 *NumberOfStrings
= StringsNumber
;
403 This function returns full SMBIOS table length.
405 @param TableAddress SMBIOS table based address
406 @param TableMaximumSize Maximum size of SMBIOS table
408 @return SMBIOS table length
412 GetSmbiosTableLength (
413 IN VOID
*TableAddress
,
414 IN UINTN TableMaximumSize
418 VOID
*TableAddressEnd
;
419 UINTN TableEntryLength
;
421 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableMaximumSize
);
422 TableEntry
= TableAddress
;
423 while (TableEntry
< TableAddressEnd
) {
424 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
425 if (TableEntryLength
== 0) {
429 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
== 127) {
430 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
434 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
437 return ((UINTN
)TableEntry
- (UINTN
)TableAddress
);
442 This function updatess full SMBIOS table length.
444 @param TableAddress SMBIOS table based address
445 @param TableLength SMBIOS table length
450 IN OUT VOID
*TableAddress
,
454 VOID
*TableAddressEnd
;
456 UINTN TableEntryLength
;
458 TableEntry
= TableAddress
;
459 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableLength
);
460 while ((UINTN
)TableEntry
< (UINTN
)TableAddressEnd
) {
461 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
462 if (TableEntryLength
== 0) {
466 FilterSmbiosEntry (TableEntry
, TableEntryLength
);
468 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
473 Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1].
475 @param[in] Event Event whose notification function is being invoked.
476 @param[in] Context Pointer to the notification function's context.
487 EFI_HANDOFF_TABLE_POINTERS HandoffTables
;
488 SMBIOS_HANDOFF_TABLE_POINTERS2 SmbiosHandoffTables2
;
492 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTable
;
493 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios3Table
;
494 VOID
*SmbiosTableAddress
;
500 SmbiosTableAddress
= NULL
;
503 if (mSmbios
->MajorVersion
>= 3) {
504 Status
= EfiGetSystemConfigurationTable (
505 &gEfiSmbios3TableGuid
,
506 (VOID
**)&Smbios3Table
508 if (!EFI_ERROR (Status
)) {
509 DEBUG ((DEBUG_INFO
, "Smbios3Table:\n"));
512 " AnchorString - '%c%c%c%c%c'\n",
513 Smbios3Table
->AnchorString
[0],
514 Smbios3Table
->AnchorString
[1],
515 Smbios3Table
->AnchorString
[2],
516 Smbios3Table
->AnchorString
[3],
517 Smbios3Table
->AnchorString
[4]
519 DEBUG ((DEBUG_INFO
, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table
->EntryPointStructureChecksum
));
520 DEBUG ((DEBUG_INFO
, " EntryPointLength - 0x%02x\n", Smbios3Table
->EntryPointLength
));
521 DEBUG ((DEBUG_INFO
, " MajorVersion - 0x%02x\n", Smbios3Table
->MajorVersion
));
522 DEBUG ((DEBUG_INFO
, " MinorVersion - 0x%02x\n", Smbios3Table
->MinorVersion
));
523 DEBUG ((DEBUG_INFO
, " DocRev - 0x%02x\n", Smbios3Table
->DocRev
));
524 DEBUG ((DEBUG_INFO
, " EntryPointRevision - 0x%02x\n", Smbios3Table
->EntryPointRevision
));
525 DEBUG ((DEBUG_INFO
, " TableMaximumSize - 0x%08x\n", Smbios3Table
->TableMaximumSize
));
526 DEBUG ((DEBUG_INFO
, " TableAddress - 0x%016lx\n", Smbios3Table
->TableAddress
));
530 if (Smbios3Table
== NULL
) {
531 Status
= EfiGetSystemConfigurationTable (
532 &gEfiSmbiosTableGuid
,
533 (VOID
**)&SmbiosTable
535 if (!EFI_ERROR (Status
)) {
536 DEBUG ((DEBUG_INFO
, "SmbiosTable:\n"));
539 " AnchorString - '%c%c%c%c'\n",
540 SmbiosTable
->AnchorString
[0],
541 SmbiosTable
->AnchorString
[1],
542 SmbiosTable
->AnchorString
[2],
543 SmbiosTable
->AnchorString
[3]
545 DEBUG ((DEBUG_INFO
, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable
->EntryPointStructureChecksum
));
546 DEBUG ((DEBUG_INFO
, " EntryPointLength - 0x%02x\n", SmbiosTable
->EntryPointLength
));
547 DEBUG ((DEBUG_INFO
, " MajorVersion - 0x%02x\n", SmbiosTable
->MajorVersion
));
548 DEBUG ((DEBUG_INFO
, " MinorVersion - 0x%02x\n", SmbiosTable
->MinorVersion
));
549 DEBUG ((DEBUG_INFO
, " MaxStructureSize - 0x%08x\n", SmbiosTable
->MaxStructureSize
));
550 DEBUG ((DEBUG_INFO
, " EntryPointRevision - 0x%02x\n", SmbiosTable
->EntryPointRevision
));
553 " FormattedArea - '%c%c%c%c%c'\n",
554 SmbiosTable
->FormattedArea
[0],
555 SmbiosTable
->FormattedArea
[1],
556 SmbiosTable
->FormattedArea
[2],
557 SmbiosTable
->FormattedArea
[3],
558 SmbiosTable
->FormattedArea
[4]
562 " IntermediateAnchorString - '%c%c%c%c%c'\n",
563 SmbiosTable
->IntermediateAnchorString
[0],
564 SmbiosTable
->IntermediateAnchorString
[1],
565 SmbiosTable
->IntermediateAnchorString
[2],
566 SmbiosTable
->IntermediateAnchorString
[3],
567 SmbiosTable
->IntermediateAnchorString
[4]
569 DEBUG ((DEBUG_INFO
, " IntermediateChecksum - 0x%02x\n", SmbiosTable
->IntermediateChecksum
));
570 DEBUG ((DEBUG_INFO
, " TableLength - 0x%04x\n", SmbiosTable
->TableLength
));
571 DEBUG ((DEBUG_INFO
, " TableAddress - 0x%08x\n", SmbiosTable
->TableAddress
));
572 DEBUG ((DEBUG_INFO
, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable
->NumberOfSmbiosStructures
));
573 DEBUG ((DEBUG_INFO
, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable
->SmbiosBcdRevision
));
577 if (Smbios3Table
!= NULL
) {
578 SmbiosTableAddress
= (VOID
*)(UINTN
)Smbios3Table
->TableAddress
;
579 TableLength
= GetSmbiosTableLength (SmbiosTableAddress
, Smbios3Table
->TableMaximumSize
);
580 } else if (SmbiosTable
!= NULL
) {
581 SmbiosTableAddress
= (VOID
*)(UINTN
)SmbiosTable
->TableAddress
;
582 TableLength
= SmbiosTable
->TableLength
;
585 if (SmbiosTableAddress
!= NULL
) {
586 DEBUG ((DEBUG_INFO
, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress
));
587 DEBUG ((DEBUG_INFO
, "The Smbios Table size: 0x%x\n", TableLength
));
589 InternalDumpHex ((UINT8
*)(UINTN
)SmbiosTableAddress
, TableLength
);
592 TableAddress
= AllocateCopyPool ((UINTN
)TableLength
, (VOID
*)(UINTN
)SmbiosTableAddress
);
593 if (TableAddress
== NULL
) {
597 FilterSmbiosTable (TableAddress
, TableLength
);
599 DEBUG ((DEBUG_INFO
, "The final Smbios Table starts at: 0x%x\n", TableAddress
));
600 DEBUG ((DEBUG_INFO
, "The final Smbios Table size: 0x%x\n", TableLength
));
602 InternalDumpHex (TableAddress
, TableLength
);
605 HandoffTables
.NumberOfTables
= 1;
606 if (Smbios3Table
!= NULL
) {
607 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbios3TableGuid
);
608 HandoffTables
.TableEntry
[0].VendorTable
= Smbios3Table
;
610 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbiosTableGuid
);
611 HandoffTables
.TableEntry
[0].VendorTable
= SmbiosTable
;
614 EventType
= EV_EFI_HANDOFF_TABLES
;
615 EventLog
= &HandoffTables
;
616 EventLogSize
= sizeof (HandoffTables
);
618 if (PcdGet32 (PcdTcgPfpMeasurementRevision
) >= TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105
) {
619 SmbiosHandoffTables2
.TableDescriptionSize
= sizeof (SmbiosHandoffTables2
.TableDescription
);
620 CopyMem (SmbiosHandoffTables2
.TableDescription
, SMBIOS_HANDOFF_TABLE_DESC
, sizeof (SmbiosHandoffTables2
.TableDescription
));
621 SmbiosHandoffTables2
.NumberOfTables
= HandoffTables
.NumberOfTables
;
622 CopyMem (&(SmbiosHandoffTables2
.TableEntry
[0]), &(HandoffTables
.TableEntry
[0]), sizeof (SmbiosHandoffTables2
.TableEntry
[0]));
623 EventType
= EV_EFI_HANDOFF_TABLES2
;
624 EventLog
= &SmbiosHandoffTables2
;
625 EventLogSize
= sizeof (SmbiosHandoffTables2
);
628 Status
= TpmMeasureAndLogData (
630 EventType
, // EventType
631 EventLog
, // EventLog
632 EventLogSize
, // LogLen
633 TableAddress
, // HashData
634 TableLength
// HashDataLen
636 if (!EFI_ERROR (Status
)) {
637 gBS
->CloseEvent (Event
);
646 Driver to produce Smbios measurement.
648 @param ImageHandle Module's image handle
649 @param SystemTable Pointer of EFI_SYSTEM_TABLE
651 @return Status returned from EfiCreateEventReadyToBootEx().
656 SmbiosMeasurementDriverEntryPoint (
657 IN EFI_HANDLE ImageHandle
,
658 IN EFI_SYSTEM_TABLE
*SystemTable
664 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&mSmbios
);
665 ASSERT_EFI_ERROR (Status
);
666 DEBUG ((DEBUG_INFO
, "The Smbios Table Version: %x.%x\n", mSmbios
->MajorVersion
, mSmbios
->MinorVersion
));
668 if ((mSmbios
->MajorVersion
< 2) || ((mSmbios
->MajorVersion
== 2) && (mSmbios
->MinorVersion
< 7))) {
669 mMaxLen
= SMBIOS_STRING_MAX_LENGTH
;
670 } else if (mSmbios
->MajorVersion
< 3) {
672 // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on the length of each individual text string.
673 // However, the length of the entire structure table (including all strings) must be reported
674 // in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
675 // which is a WORD field limited to 65,535 bytes.
677 mMaxLen
= SMBIOS_TABLE_MAX_LENGTH
;
680 // SMBIOS 3.0 defines the Structure table maximum size as DWORD field limited to 0xFFFFFFFF bytes.
681 // Locate the end of string as long as possible.
683 mMaxLen
= SMBIOS_3_0_TABLE_MAX_LENGTH
;
687 // Measure Smbios tables
689 Status
= EfiCreateEventReadyToBootEx (