2 This driver measures SMBIOS table to TPM.
4 Copyright (c) 2015 - 2017, 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/TpmMeasurementLib.h>
25 #define FIELD_SIZE_OF(TYPE, Field) ((UINTN)sizeof(((TYPE *)0)->Field))
32 } SMBIOS_FILTER_TABLE
;
33 #define SMBIOS_FILTER_TABLE_FLAG_IS_STRING BIT0
37 SMBIOS_FILTER_TABLE
*Filter
; // NULL means all fields
39 } SMBIOS_FILTER_STRUCT
;
42 // Platform Specific Policy
44 SMBIOS_FILTER_TABLE mSmbiosFilterType1BlackList
[] = {
45 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
46 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, Uuid
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, Uuid
), 0},
47 {0x01, OFFSET_OF(SMBIOS_TABLE_TYPE1
, WakeUpType
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE1
, WakeUpType
), 0},
49 SMBIOS_FILTER_TABLE mSmbiosFilterType2BlackList
[] = {
50 {0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
51 {0x02, OFFSET_OF(SMBIOS_TABLE_TYPE2
, LocationInChassis
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE2
, LocationInChassis
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
53 SMBIOS_FILTER_TABLE mSmbiosFilterType3BlackList
[] = {
54 {0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
55 {0x03, OFFSET_OF(SMBIOS_TABLE_TYPE3
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE3
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
57 SMBIOS_FILTER_TABLE mSmbiosFilterType4BlackList
[] = {
58 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
59 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
60 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, PartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
61 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, CoreCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, CoreCount
), 0},
62 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount
), 0},
63 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, ThreadCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, ThreadCount
), 0},
64 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, CoreCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, CoreCount2
), 0},
65 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, EnabledCoreCount2
), 0},
66 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, ThreadCount2
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, ThreadCount2
), 0},
67 {0x04, OFFSET_OF(SMBIOS_TABLE_TYPE4
, Voltage
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE4
, Voltage
), 0},
69 SMBIOS_FILTER_TABLE mSmbiosFilterType17BlackList
[] = {
70 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
71 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, AssetTag
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, AssetTag
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
72 {0x11, OFFSET_OF(SMBIOS_TABLE_TYPE17
, PartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE17
, PartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
74 SMBIOS_FILTER_TABLE mSmbiosFilterType22BlackList
[] = {
75 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
76 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SBDSSerialNumber
), 0},
77 {0x16, OFFSET_OF(SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE22
, SBDSManufactureDate
), 0},
79 SMBIOS_FILTER_TABLE mSmbiosFilterType23BlackList
[] = {
80 {0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23
, ResetCount
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23
, ResetCount
), 0},
82 SMBIOS_FILTER_TABLE mSmbiosFilterType27BlackList
[] = {
83 {0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27
, NominalSpeed
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27
, NominalSpeed
), 0},
85 SMBIOS_FILTER_TABLE mSmbiosFilterType39BlackList
[] = {
86 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, SerialNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
87 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, AssetTagNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
88 {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39
, ModelPartNumber
), SMBIOS_FILTER_TABLE_FLAG_IS_STRING
},
91 SMBIOS_FILTER_STRUCT mSmbiosFilterStandardTableBlackList
[] = {
92 {0x01, mSmbiosFilterType1BlackList
, sizeof(mSmbiosFilterType1BlackList
)/sizeof(mSmbiosFilterType1BlackList
[0])},
93 {0x02, mSmbiosFilterType2BlackList
, sizeof(mSmbiosFilterType2BlackList
)/sizeof(mSmbiosFilterType2BlackList
[0])},
94 {0x03, mSmbiosFilterType3BlackList
, sizeof(mSmbiosFilterType3BlackList
)/sizeof(mSmbiosFilterType3BlackList
[0])},
95 {0x04, mSmbiosFilterType4BlackList
, sizeof(mSmbiosFilterType4BlackList
)/sizeof(mSmbiosFilterType4BlackList
[0])},
98 {0x11, mSmbiosFilterType17BlackList
, sizeof(mSmbiosFilterType17BlackList
)/sizeof(mSmbiosFilterType17BlackList
[0])},
100 {0x16, mSmbiosFilterType22BlackList
, sizeof(mSmbiosFilterType22BlackList
)/sizeof(mSmbiosFilterType22BlackList
[0])},
101 {0x17, mSmbiosFilterType23BlackList
, sizeof(mSmbiosFilterType23BlackList
)/sizeof(mSmbiosFilterType23BlackList
[0])},
102 {0x1B, mSmbiosFilterType27BlackList
, sizeof(mSmbiosFilterType27BlackList
)/sizeof(mSmbiosFilterType27BlackList
[0])},
105 {0x27, mSmbiosFilterType39BlackList
, sizeof(mSmbiosFilterType39BlackList
)/sizeof(mSmbiosFilterType39BlackList
[0])},
108 EFI_SMBIOS_PROTOCOL
*mSmbios
;
113 This function dump raw data.
116 @param Size raw data size
126 for (Index
= 0; Index
< Size
; Index
++) {
127 DEBUG ((EFI_D_VERBOSE
, "%02x", (UINTN
)Data
[Index
]));
133 This function dump raw data with colume format.
136 @param Size raw data size
149 #define COLUME_SIZE (16 * 2)
151 Count
= Size
/ COLUME_SIZE
;
152 Left
= Size
% COLUME_SIZE
;
153 for (Index
= 0; Index
< Count
; Index
++) {
154 DEBUG ((EFI_D_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
155 InternalDumpData (Data
+ Index
* COLUME_SIZE
, COLUME_SIZE
);
156 DEBUG ((EFI_D_VERBOSE
, "\n"));
160 DEBUG ((EFI_D_VERBOSE
, "%04x: ", Index
* COLUME_SIZE
));
161 InternalDumpData (Data
+ Index
* COLUME_SIZE
, Left
);
162 DEBUG ((EFI_D_VERBOSE
, "\n"));
169 This function get filter structure by SMBIOS type.
171 @param Type SMBIOS type
174 SMBIOS_FILTER_STRUCT
*
175 GetFilterStructByType (
180 for (Index
= 0; Index
< sizeof(mSmbiosFilterStandardTableBlackList
)/sizeof(mSmbiosFilterStandardTableBlackList
[0]); Index
++) {
181 if (mSmbiosFilterStandardTableBlackList
[Index
].Type
== Type
) {
182 return &mSmbiosFilterStandardTableBlackList
[Index
];
190 This function get SMBIOS string in SMBIOS table.
192 @param Head SMBIOS table head
193 @param StringId SMBIOS string ID
194 @param StringLen length of SMBIOS string
196 @return SMBIOS string data
199 GetSmbiosStringById (
200 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
201 IN SMBIOS_TABLE_STRING StringId
,
211 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
216 // look for the two consecutive zeros, check the string limit by the way.
219 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
220 if (*CharInStr
== 0) {
226 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
227 if (*(CharInStr
+StrLen
) == 0) {
233 if (StrLen
== mMaxLen
) {
238 // forward the pointer
243 if (StringsNumber
== StringId
) {
253 This function update SMBIOS table based on policy.
255 @param TableEntry SMBIOS table
256 @param TableEntrySize SMBIOS table size
261 IN OUT VOID
*TableEntry
,
262 IN UINTN TableEntrySize
265 SMBIOS_FILTER_STRUCT
*FilterStruct
;
266 SMBIOS_FILTER_TABLE
*Filter
;
268 SMBIOS_TABLE_STRING StringId
;
272 DEBUG ((EFI_D_INFO
, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
273 DEBUG_CODE (InternalDumpHex (TableEntry
, TableEntrySize
););
276 // Skip measurement for OEM types.
278 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
>= SMBIOS_OEM_BEGIN
) {
279 // zero all table fields, except header
280 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
282 FilterStruct
= GetFilterStructByType (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
);
283 if (FilterStruct
!= NULL
) {
284 if (FilterStruct
->Filter
== NULL
|| FilterStruct
->FilterCount
== 0) {
285 // zero all table fields, except header
286 ZeroMem ((UINT8
*)TableEntry
+ sizeof(SMBIOS_STRUCTURE
), TableEntrySize
- sizeof(SMBIOS_STRUCTURE
));
288 Filter
= FilterStruct
->Filter
;
289 for (Index
= 0; Index
< FilterStruct
->FilterCount
; Index
++) {
290 if (((SMBIOS_STRUCTURE
*) TableEntry
)->Length
>= (Filter
[Index
].Offset
+ Filter
[Index
].Size
)) {
292 // The field is present in the SMBIOS entry.
294 if ((Filter
[Index
].Flags
& SMBIOS_FILTER_TABLE_FLAG_IS_STRING
) != 0) {
295 CopyMem (&StringId
, (UINT8
*)TableEntry
+ Filter
[Index
].Offset
, sizeof(StringId
));
297 // set ' ' for string field
298 String
= GetSmbiosStringById (TableEntry
, StringId
, &StringLen
);
299 ASSERT (String
!= NULL
);
300 //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
301 SetMem (String
, StringLen
, ' ');
304 // zero non-string field
305 ZeroMem ((UINT8
*)TableEntry
+ Filter
[Index
].Offset
, Filter
[Index
].Size
);
312 DEBUG ((EFI_D_INFO
, "Filter Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE
*)TableEntry
)->Type
));
313 DEBUG_CODE (InternalDumpHex (TableEntry
, TableEntrySize
););
318 Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
320 @param Head Pointer to the beginning of SMBIOS structure.
321 @param NumberOfStrings The returned number of optional strings that follow the formatted structure.
323 @return Size The returned size.
326 GetSmbiosStructureSize (
327 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
328 OUT UINTN
*NumberOfStrings
336 CharInStr
= (CHAR8
*)Head
+ Head
->Length
;
341 // look for the two consecutive zeros, check the string limit by the way.
343 while (*CharInStr
!= 0 || *(CharInStr
+1) != 0) {
344 if (*CharInStr
== 0) {
349 for (StrLen
= 0 ; StrLen
< mMaxLen
; StrLen
++) {
350 if (*(CharInStr
+StrLen
) == 0) {
355 if (StrLen
== mMaxLen
) {
360 // forward the pointer
368 // count ending two zeros.
372 if (NumberOfStrings
!= NULL
) {
373 *NumberOfStrings
= StringsNumber
;
380 This function returns full SMBIOS table length.
382 @param TableAddress SMBIOS table based address
383 @param TableMaximumSize Maximum size of SMBIOS table
385 @return SMBIOS table length
389 GetSmbiosTableLength (
390 IN VOID
*TableAddress
,
391 IN UINTN TableMaximumSize
395 VOID
*TableAddressEnd
;
396 UINTN TableEntryLength
;
398 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableMaximumSize
);
399 TableEntry
= TableAddress
;
400 while (TableEntry
< TableAddressEnd
) {
401 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
402 if (TableEntryLength
== 0) {
405 if (((SMBIOS_STRUCTURE
*)TableEntry
)->Type
== 127) {
406 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
409 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
412 return ((UINTN
)TableEntry
- (UINTN
)TableAddress
);
417 This function updatess full SMBIOS table length.
419 @param TableAddress SMBIOS table based address
420 @param TableLength SMBIOS table length
425 IN OUT VOID
*TableAddress
,
429 VOID
*TableAddressEnd
;
431 UINTN TableEntryLength
;
433 TableEntry
= TableAddress
;
434 TableAddressEnd
= (VOID
*)((UINTN
)TableAddress
+ TableLength
);
435 while ((UINTN
)TableEntry
< (UINTN
)TableAddressEnd
) {
436 TableEntryLength
= GetSmbiosStructureSize (TableEntry
, NULL
);
437 if (TableEntryLength
== 0) {
441 FilterSmbiosEntry (TableEntry
, TableEntryLength
);
443 TableEntry
= (VOID
*)((UINTN
)TableEntry
+ TableEntryLength
);
448 Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1].
450 @param[in] Event Event whose notification function is being invoked.
451 @param[in] Context Pointer to the notification function's context.
462 EFI_HANDOFF_TABLE_POINTERS HandoffTables
;
463 SMBIOS_TABLE_ENTRY_POINT
*SmbiosTable
;
464 SMBIOS_TABLE_3_0_ENTRY_POINT
*Smbios3Table
;
465 VOID
*SmbiosTableAddress
;
471 SmbiosTableAddress
= NULL
;
474 if (mSmbios
->MajorVersion
>= 3) {
475 Status
= EfiGetSystemConfigurationTable (
476 &gEfiSmbios3TableGuid
,
477 (VOID
**) &Smbios3Table
479 if (!EFI_ERROR (Status
)) {
480 DEBUG ((EFI_D_INFO
, "Smbios3Table:\n"));
481 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c%c'\n",
482 Smbios3Table
->AnchorString
[0],
483 Smbios3Table
->AnchorString
[1],
484 Smbios3Table
->AnchorString
[2],
485 Smbios3Table
->AnchorString
[3],
486 Smbios3Table
->AnchorString
[4]
488 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", Smbios3Table
->EntryPointStructureChecksum
));
489 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", Smbios3Table
->EntryPointLength
));
490 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", Smbios3Table
->MajorVersion
));
491 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", Smbios3Table
->MinorVersion
));
492 DEBUG ((EFI_D_INFO
, " DocRev - 0x%02x\n", Smbios3Table
->DocRev
));
493 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", Smbios3Table
->EntryPointRevision
));
494 DEBUG ((EFI_D_INFO
, " TableMaximumSize - 0x%08x\n", Smbios3Table
->TableMaximumSize
));
495 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%016lx\n", Smbios3Table
->TableAddress
));
499 if (Smbios3Table
== NULL
) {
500 Status
= EfiGetSystemConfigurationTable (
501 &gEfiSmbiosTableGuid
,
502 (VOID
**) &SmbiosTable
504 if (!EFI_ERROR (Status
)) {
505 DEBUG ((EFI_D_INFO
, "SmbiosTable:\n"));
506 DEBUG ((EFI_D_INFO
, " AnchorString - '%c%c%c%c'\n",
507 SmbiosTable
->AnchorString
[0],
508 SmbiosTable
->AnchorString
[1],
509 SmbiosTable
->AnchorString
[2],
510 SmbiosTable
->AnchorString
[3]
512 DEBUG ((EFI_D_INFO
, " EntryPointStructureChecksum - 0x%02x\n", SmbiosTable
->EntryPointStructureChecksum
));
513 DEBUG ((EFI_D_INFO
, " EntryPointLength - 0x%02x\n", SmbiosTable
->EntryPointLength
));
514 DEBUG ((EFI_D_INFO
, " MajorVersion - 0x%02x\n", SmbiosTable
->MajorVersion
));
515 DEBUG ((EFI_D_INFO
, " MinorVersion - 0x%02x\n", SmbiosTable
->MinorVersion
));
516 DEBUG ((EFI_D_INFO
, " MaxStructureSize - 0x%08x\n", SmbiosTable
->MaxStructureSize
));
517 DEBUG ((EFI_D_INFO
, " EntryPointRevision - 0x%02x\n", SmbiosTable
->EntryPointRevision
));
518 DEBUG ((EFI_D_INFO
, " FormattedArea - '%c%c%c%c%c'\n",
519 SmbiosTable
->FormattedArea
[0],
520 SmbiosTable
->FormattedArea
[1],
521 SmbiosTable
->FormattedArea
[2],
522 SmbiosTable
->FormattedArea
[3],
523 SmbiosTable
->FormattedArea
[4]
525 DEBUG ((EFI_D_INFO
, " IntermediateAnchorString - '%c%c%c%c%c'\n",
526 SmbiosTable
->IntermediateAnchorString
[0],
527 SmbiosTable
->IntermediateAnchorString
[1],
528 SmbiosTable
->IntermediateAnchorString
[2],
529 SmbiosTable
->IntermediateAnchorString
[3],
530 SmbiosTable
->IntermediateAnchorString
[4]
532 DEBUG ((EFI_D_INFO
, " IntermediateChecksum - 0x%02x\n", SmbiosTable
->IntermediateChecksum
));
533 DEBUG ((EFI_D_INFO
, " TableLength - 0x%04x\n", SmbiosTable
->TableLength
));
534 DEBUG ((EFI_D_INFO
, " TableAddress - 0x%08x\n", SmbiosTable
->TableAddress
));
535 DEBUG ((EFI_D_INFO
, " NumberOfSmbiosStructures - 0x%04x\n", SmbiosTable
->NumberOfSmbiosStructures
));
536 DEBUG ((EFI_D_INFO
, " SmbiosBcdRevision - 0x%02x\n", SmbiosTable
->SmbiosBcdRevision
));
540 if (Smbios3Table
!= NULL
) {
541 SmbiosTableAddress
= (VOID
*)(UINTN
)Smbios3Table
->TableAddress
;
542 TableLength
= GetSmbiosTableLength (SmbiosTableAddress
, Smbios3Table
->TableMaximumSize
);
543 } else if (SmbiosTable
!= NULL
) {
544 SmbiosTableAddress
= (VOID
*)(UINTN
)SmbiosTable
->TableAddress
;
545 TableLength
= SmbiosTable
->TableLength
;
548 if (SmbiosTableAddress
!= NULL
) {
549 DEBUG ((DEBUG_INFO
, "The Smbios Table starts at: 0x%x\n", SmbiosTableAddress
));
550 DEBUG ((DEBUG_INFO
, "The Smbios Table size: 0x%x\n", TableLength
));
551 DEBUG_CODE (InternalDumpHex ((UINT8
*)(UINTN
)SmbiosTableAddress
, TableLength
););
553 TableAddress
= AllocateCopyPool ((UINTN
)TableLength
, (VOID
*)(UINTN
)SmbiosTableAddress
);
554 if (TableAddress
== NULL
) {
558 FilterSmbiosTable (TableAddress
, TableLength
);
560 DEBUG ((DEBUG_INFO
, "The final Smbios Table starts at: 0x%x\n", TableAddress
));
561 DEBUG ((DEBUG_INFO
, "The final Smbios Table size: 0x%x\n", TableLength
));
562 DEBUG_CODE (InternalDumpHex (TableAddress
, TableLength
););
564 HandoffTables
.NumberOfTables
= 1;
565 if (Smbios3Table
!= NULL
) {
566 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbios3TableGuid
);
567 HandoffTables
.TableEntry
[0].VendorTable
= Smbios3Table
;
569 CopyGuid (&(HandoffTables
.TableEntry
[0].VendorGuid
), &gEfiSmbiosTableGuid
);
570 HandoffTables
.TableEntry
[0].VendorTable
= SmbiosTable
;
572 Status
= TpmMeasureAndLogData (
574 EV_EFI_HANDOFF_TABLES
, // EventType
575 &HandoffTables
, // EventLog
576 sizeof (HandoffTables
), // LogLen
577 TableAddress
, // HashData
578 TableLength
// HashDataLen
580 if (EFI_ERROR (Status
)) {
590 Driver to produce Smbios measurement.
592 @param ImageHandle Module's image handle
593 @param SystemTable Pointer of EFI_SYSTEM_TABLE
595 @return Status returned from EfiCreateEventReadyToBootEx().
600 SmbiosMeasurementDriverEntryPoint (
601 IN EFI_HANDLE ImageHandle
,
602 IN EFI_SYSTEM_TABLE
*SystemTable
608 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**) &mSmbios
);
609 ASSERT_EFI_ERROR (Status
);
610 DEBUG ((DEBUG_INFO
, "The Smbios Table Version: %x.%x\n", mSmbios
->MajorVersion
, mSmbios
->MinorVersion
));
612 if (mSmbios
->MajorVersion
< 2 || (mSmbios
->MajorVersion
== 2 && mSmbios
->MinorVersion
< 7)){
613 mMaxLen
= SMBIOS_STRING_MAX_LENGTH
;
614 } else if (mSmbios
->MajorVersion
< 3) {
616 // Reference SMBIOS 2.7, chapter 6.1.3, it will have no limit on the length of each individual text string.
617 // However, the length of the entire structure table (including all strings) must be reported
618 // in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
619 // which is a WORD field limited to 65,535 bytes.
621 mMaxLen
= SMBIOS_TABLE_MAX_LENGTH
;
624 // SMBIOS 3.0 defines the Structure table maximum size as DWORD field limited to 0xFFFFFFFF bytes.
625 // Locate the end of string as long as possible.
627 mMaxLen
= SMBIOS_3_0_TABLE_MAX_LENGTH
;
631 // Measure Smbios tables
633 Status
= EfiCreateEventReadyToBootEx (