public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg SmbiosMeasurementDxe: Skip measurement for OEM type
@ 2017-09-14 11:29 Star Zeng
  2017-09-18  1:45 ` Chiu, Chasel
  0 siblings, 1 reply; 2+ messages in thread
From: Star Zeng @ 2017-09-14 11:29 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Chasel Chiu

The generic driver has no way to know whether an OEM type should
be filtered or not.
This patch is to update the code to skip measurement for OEM type
and platform code can measure it by self if required.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.c    | 54 +++++++++++++---------
 .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf  |  5 +-
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
index bc5e7464e133..4a3e99aefd0f 100644
--- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
@@ -1,7 +1,7 @@
 /** @file
   This driver measures SMBIOS table to TPM.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -277,30 +277,38 @@ FilterSmbiosEntry (
   DEBUG ((EFI_D_INFO, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type));
   DEBUG_CODE (InternalDumpHex (TableEntry, TableEntrySize););
 
-  FilterStruct = GetFilterStructByType (((SMBIOS_STRUCTURE *)TableEntry)->Type);
-  if (FilterStruct != NULL) {
-    if (FilterStruct->Filter == NULL || FilterStruct->FilterCount == 0) {
-      // zero all table entries, except header
-      ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
-    } else {
-      Filter = FilterStruct->Filter;
-      for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
-        if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
-          //
-          // The field is present in the SMBIOS entry.
-          //
-          if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
-            CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
-            if (StringId != 0) {
-              // set ' ' for string field
-              String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
-              ASSERT (String != NULL);
-              //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
-              SetMem (String, StringLen, ' ');
+  //
+  // Skip measurement for OEM types.
+  //
+  if (((SMBIOS_STRUCTURE *)TableEntry)->Type >= SMBIOS_OEM_BEGIN) {
+    // zero all table fields, except header
+    ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
+  } else {
+    FilterStruct = GetFilterStructByType (((SMBIOS_STRUCTURE *)TableEntry)->Type);
+    if (FilterStruct != NULL) {
+      if (FilterStruct->Filter == NULL || FilterStruct->FilterCount == 0) {
+        // zero all table fields, except header
+        ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
+      } else {
+        Filter = FilterStruct->Filter;
+        for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
+          if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
+            //
+            // The field is present in the SMBIOS entry.
+            //
+            if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
+              CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
+              if (StringId != 0) {
+                // set ' ' for string field
+                String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
+                ASSERT (String != NULL);
+                //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
+                SetMem (String, StringLen, ' ');
+              }
             }
+            // zero non-string field
+            ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
           }
-          // zero non-string field
-          ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
         }
       }
     }
diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
index c5a779cca7fe..5d3aa67f7c8b 100644
--- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
@@ -7,10 +7,11 @@
 #     such as clock registers, and system unique information, such as
 #     asset numbers or serial numbers, MUST NOT be measured into PCR [1],
 #     or any other PCR.
-#
+# The OEM types are skipped and platform code can measure them by self if required.
+# 
 # A platform may use its own policy to filter some fields in SMBIOS table.
 #
-# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MdeModulePkg SmbiosMeasurementDxe: Skip measurement for OEM type
  2017-09-14 11:29 [PATCH] MdeModulePkg SmbiosMeasurementDxe: Skip measurement for OEM type Star Zeng
@ 2017-09-18  1:45 ` Chiu, Chasel
  0 siblings, 0 replies; 2+ messages in thread
From: Chiu, Chasel @ 2017-09-18  1:45 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

-----Original Message-----
From: Zeng, Star 
Sent: Thursday, September 14, 2017 7:29 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: [PATCH] MdeModulePkg SmbiosMeasurementDxe: Skip measurement for OEM type

The generic driver has no way to know whether an OEM type should be filtered or not.
This patch is to update the code to skip measurement for OEM type and platform code can measure it by self if required.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.c    | 54 +++++++++++++---------
 .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf  |  5 +-
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
index bc5e7464e133..4a3e99aefd0f 100644
--- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
@@ -1,7 +1,7 @@
 /** @file
   This driver measures SMBIOS table to TPM.
 
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License  which accompanies this distribution.  The full text of the license may be found at @@ -277,30 +277,38 @@ FilterSmbiosEntry (
   DEBUG ((EFI_D_INFO, "Smbios Table (Type - %d):\n", ((SMBIOS_STRUCTURE *)TableEntry)->Type));
   DEBUG_CODE (InternalDumpHex (TableEntry, TableEntrySize););
 
-  FilterStruct = GetFilterStructByType (((SMBIOS_STRUCTURE *)TableEntry)->Type);
-  if (FilterStruct != NULL) {
-    if (FilterStruct->Filter == NULL || FilterStruct->FilterCount == 0) {
-      // zero all table entries, except header
-      ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
-    } else {
-      Filter = FilterStruct->Filter;
-      for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
-        if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
-          //
-          // The field is present in the SMBIOS entry.
-          //
-          if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
-            CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
-            if (StringId != 0) {
-              // set ' ' for string field
-              String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
-              ASSERT (String != NULL);
-              //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
-              SetMem (String, StringLen, ' ');
+  //
+  // Skip measurement for OEM types.
+  //
+  if (((SMBIOS_STRUCTURE *)TableEntry)->Type >= SMBIOS_OEM_BEGIN) {
+    // zero all table fields, except header
+    ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), 
+ TableEntrySize - sizeof(SMBIOS_STRUCTURE));  } else {
+    FilterStruct = GetFilterStructByType (((SMBIOS_STRUCTURE *)TableEntry)->Type);
+    if (FilterStruct != NULL) {
+      if (FilterStruct->Filter == NULL || FilterStruct->FilterCount == 0) {
+        // zero all table fields, except header
+        ZeroMem ((UINT8 *)TableEntry + sizeof(SMBIOS_STRUCTURE), TableEntrySize - sizeof(SMBIOS_STRUCTURE));
+      } else {
+        Filter = FilterStruct->Filter;
+        for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
+          if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
+            //
+            // The field is present in the SMBIOS entry.
+            //
+            if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
+              CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
+              if (StringId != 0) {
+                // set ' ' for string field
+                String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
+                ASSERT (String != NULL);
+                //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
+                SetMem (String, StringLen, ' ');
+              }
             }
+            // zero non-string field
+            ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, 
+ Filter[Index].Size);
           }
-          // zero non-string field
-          ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
         }
       }
     }
diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
index c5a779cca7fe..5d3aa67f7c8b 100644
--- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.inf
+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.i
+++ nf
@@ -7,10 +7,11 @@
 #     such as clock registers, and system unique information, such as
 #     asset numbers or serial numbers, MUST NOT be measured into PCR [1],
 #     or any other PCR.
-#
+# The OEM types are skipped and platform code can measure them by self if required.
+#
 # A platform may use its own policy to filter some fields in SMBIOS table.
 #
-# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2015 - 2017, Intel Corporation. All rights 
+reserved.<BR>
 #
 #  This program and the accompanying materials  #  are licensed and made available under the terms and conditions of the BSD License
--
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-18  1:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-14 11:29 [PATCH] MdeModulePkg SmbiosMeasurementDxe: Skip measurement for OEM type Star Zeng
2017-09-18  1:45 ` Chiu, Chasel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox