]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: SmbiosPlatformDxe: eliminate duplicate entry point validation
authorLaszlo Ersek <lersek@redhat.com>
Thu, 6 Aug 2015 10:14:03 +0000 (10:14 +0000)
committerlersek <lersek@Edk2>
Thu, 6 Aug 2015 10:14:03 +0000 (10:14 +0000)
At this point all platforms that use OvmfPkg/SmbiosPlatformDxe in edk2,
namely ArmVirtQemu.dsc and OvmfPkg*.dsc, have been migrated to
SmbiosVersionLib. Therefore SmbiosPlatformDxe itself can forego verifying
QEMU's SMBIOS entry point; if SmbiosVersionLib's validation was
successful, it should just rely on that.

(Note that SmbiosPlatformDxe has a depex on EFI_SMBIOS_PROTOCOL, installed
by SmbiosDxe, containing SmbiosVersionLib, therefore the set/get order of
PcdQemuSmbiosValidated is ensured.)

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Wei Huang <wei@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gabriel L. Somlo <somlo@cmu.edu>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18180 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.inf
OvmfPkg/SmbiosPlatformDxe/Qemu.c
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf

index 0efe020eea4a1343b272e31df0106a484b43a811..9d5e337e1a3ac1c5777b9b9814df50e489fc70fb 100644 (file)
@@ -40,6 +40,15 @@ DetectSmbiosVersion (
   QEMU_SMBIOS_ANCHOR   QemuAnchor;\r
   UINT16               SmbiosVersion;\r
 \r
+  if (PcdGetBool (PcdQemuSmbiosValidated)) {\r
+    //\r
+    // Some other module, linked against this library, has already performed\r
+    // the task at hand. This should never happen, but it's easy to handle;\r
+    // just exit early.\r
+    //\r
+    return RETURN_SUCCESS;\r
+  }\r
+\r
   if (RETURN_ERROR (QemuFwCfgFindFile (\r
                       "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||\r
       RETURN_ERROR (QemuFwCfgFindFile (\r
@@ -72,5 +81,10 @@ DetectSmbiosVersion (
     SmbiosVersion));\r
   PcdSet16 (PcdSmbiosVersion, SmbiosVersion);\r
 \r
+  //\r
+  // SMBIOS platform drivers can now fetch and install\r
+  // "etc/smbios/smbios-tables" from QEMU.\r
+  //\r
+  PcdSetBool (PcdQemuSmbiosValidated, TRUE);\r
   return RETURN_SUCCESS;\r
 }\r
index 14c25c924e3274f0f25c4ab913d6f9a754bee7be..8487e73e4683f0c67c2458d2569519183686c07f 100644 (file)
@@ -49,3 +49,4 @@
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated\r
index f7ace4f1deb203f846830283fa3cc97d89ebfd6e..9466b950fc74eedebdf856e7c6cbc63cd6ac7d05 100644 (file)
@@ -15,6 +15,7 @@
 #include "SmbiosPlatformDxe.h"\r
 #include <Library/QemuFwCfgLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
 \r
 /**\r
   Locates and extracts the QEMU SMBIOS data if present in fw_cfg\r
@@ -27,32 +28,19 @@ GetQemuSmbiosTables (
   VOID\r
   )\r
 {\r
-  SMBIOS_TABLE_ENTRY_POINT QemuAnchor;\r
-  FIRMWARE_CONFIG_ITEM     Anchor, Tables;\r
-  UINTN                    AnchorSize, TablesSize;\r
+  EFI_STATUS               Status;\r
+  FIRMWARE_CONFIG_ITEM     Tables;\r
+  UINTN                    TablesSize;\r
   UINT8                    *QemuTables;\r
 \r
-  if (EFI_ERROR (QemuFwCfgFindFile (\r
-                   "etc/smbios/smbios-anchor", &Anchor, &AnchorSize)) ||\r
-      EFI_ERROR (QemuFwCfgFindFile (\r
-                   "etc/smbios/smbios-tables", &Tables, &TablesSize)) ||\r
-      AnchorSize != sizeof (QemuAnchor) ||\r
-      TablesSize == 0) {\r
+  if (!PcdGetBool (PcdQemuSmbiosValidated)) {\r
     return NULL;\r
   }\r
 \r
-  //\r
-  // We copy the entry point structure to perform some additional checks,\r
-  // but discard it upon return.\r
-  //\r
-  QemuFwCfgSelectItem (Anchor);\r
-  QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);\r
-\r
-  if (AsciiStrnCmp ((CHAR8 *)QemuAnchor.AnchorString, "_SM_", 4) ||\r
-      AsciiStrnCmp ((CHAR8 *)QemuAnchor.IntermediateAnchorString, "_DMI_", 5) ||\r
-      TablesSize != QemuAnchor.TableLength) {\r
-    return NULL;\r
-  }\r
+  Status = QemuFwCfgFindFile ("etc/smbios/smbios-tables", &Tables,\r
+             &TablesSize);\r
+  ASSERT_EFI_ERROR (Status);\r
+  ASSERT (TablesSize > 0);\r
 \r
   QemuTables = AllocatePool (TablesSize);\r
   if (QemuTables == NULL) {\r
index 3b90aac438e7190f95c5cd459e3cfa008cad1129..91815ecd6f1566d82def7790c6b6d500dcd3a606 100644 (file)
   HobLib\r
   QemuFwCfgLib\r
   MemoryAllocationLib\r
+  PcdLib\r
+\r
+[Pcd]\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated\r
 \r
 [Protocols]\r
   gEfiSmbiosProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r