]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: PlatformPei: set SMBIOS entry point version dynamically
authorLaszlo Ersek <lersek@redhat.com>
Mon, 22 Jun 2015 17:11:05 +0000 (17:11 +0000)
committerlersek <lersek@Edk2>
Mon, 22 Jun 2015 17:11:05 +0000 (17:11 +0000)
Git commit 54753b60 (SVN r16870), "MdeModulePkg: Update SMBIOS revision to
3.0." changed PcdSmbiosVersion from 0x0208 to 0x0300. This controls the
version number of the SMBIOS entry point table (and other things) that
"MdeModulePkg/Universal/SmbiosDxe" installs.

Alas, this change breaks older Linux guests, like RHEL-6 (up to RHEL-6.7);
those are limited to 2.x (both in the guest kernel firmware driver, and in
the dmidecode utility). The SMBIOS 3.0 entry point has a different GUID --
defined in UEFI 2.5 -- pointing to it in the UEFI Configuration Table, and
guest kernels that lack upstream kernel commit e1ccbbc9d5 don't recognize
it.

The v2.1.0+ machine types of QEMU generate SMBIOS payload for the firmware
to install. The payload includes the entry point table ("anchor" table).
OvmfPkg/SmbiosPlatformDxe cannot install the anchor table (because that is
the jurisdiction of the generic "MdeModulePkg/Universal/SmbiosDxe"
driver); however, we can parse the entry point version from QEMU's anchor
table, and instruct "MdeModulePkg/Universal/SmbiosDxe" to adhere to that
version.

On machine types older than v2.1.0, the feature is not available, but
then, should anything in OVMF install SMBIOS tables, version 2.8 is simply
safer / more widely supported than 3.0 -- hence the default 2.8 value for
the dynamic PCD.

We set the PCD in PlatformPei (when not on the S3 resume path), because
that's an easy and certain way to set the PCD before a DXE driver reads
it. This follows the example of PcdEmuVariableNvStoreReserved (which is
read by EmuVariableFvbRuntimeDxe).

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1232876
Cc: Gabriel Somlo <somlo@cmu.edu>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Acked-by: Gabriel Somlo <somlo@cmu.edu>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17676 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc
OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/PlatformPei.inf

index 9f015f1aaec558e1120704432c315c944ee108cd..6342b5c306c044b77d048913366903db5d6f9af3 100644 (file)
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480\r
 \r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208\r
+\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform.\r
index 2dc92047eff828dc4ba78b63db3f0f548e4a9d1f..f1230bf5a7ab3523955f8a1a62f2fc966a304de8 100644 (file)
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480\r
 \r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208\r
+\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform.\r
index 48a7a8d2e9dec35db8c00ec82887af7b2e239e47..e5fc90d2e610c754536481d791c8d80988122604 100644 (file)
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480\r
 \r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0208\r
+\r
 ################################################################################\r
 #\r
 # Components Section - list of all EDK II Modules needed by this Platform.\r
index 1ad5bfc26a09a1d6fb09784609d7dc005bacaaa4..210578796129925f54a8dccd27dafd56ebdbef1a 100644 (file)
 #include <Library/PeiServicesLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
 #include <Library/ResourcePublicationLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 #include <Guid/MemoryTypeInformation.h>\r
 #include <Ppi/MasterBootMode.h>\r
 #include <IndustryStandard/Pci22.h>\r
+#include <IndustryStandard/SmBios.h>\r
 #include <OvmfPlatforms.h>\r
 \r
 #include "Platform.h"\r
@@ -377,6 +379,41 @@ DebugDumpCmos (
 }\r
 \r
 \r
+/**\r
+  Set the SMBIOS entry point version for the generic SmbiosDxe driver.\r
+**/\r
+STATIC\r
+VOID\r
+SmbiosVersionInitialization (\r
+  VOID\r
+  )\r
+{\r
+  FIRMWARE_CONFIG_ITEM     Anchor;\r
+  UINTN                    AnchorSize;\r
+  SMBIOS_TABLE_ENTRY_POINT QemuAnchor;\r
+  UINT16                   SmbiosVersion;\r
+\r
+  if (RETURN_ERROR (QemuFwCfgFindFile ("etc/smbios/smbios-anchor", &Anchor,\r
+                      &AnchorSize)) ||\r
+      AnchorSize != sizeof QemuAnchor) {\r
+    return;\r
+  }\r
+\r
+  QemuFwCfgSelectItem (Anchor);\r
+  QemuFwCfgReadBytes (AnchorSize, &QemuAnchor);\r
+  if (CompareMem (QemuAnchor.AnchorString, "_SM_", 4) != 0 ||\r
+      CompareMem (QemuAnchor.IntermediateAnchorString, "_DMI_", 5) != 0) {\r
+    return;\r
+  }\r
+\r
+  SmbiosVersion = (UINT16)(QemuAnchor.MajorVersion << 8 |\r
+                           QemuAnchor.MinorVersion);\r
+  DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,\r
+    SmbiosVersion));\r
+  PcdSet16 (PcdSmbiosVersion, SmbiosVersion);\r
+}\r
+\r
+\r
 /**\r
   Perform Platform PEI initialization.\r
 \r
@@ -426,6 +463,8 @@ InitializePlatform (
     PeiFvInitialization ();\r
 \r
     MemMapInitialization ();\r
+\r
+    SmbiosVersionInitialization ();\r
   }\r
 \r
   MiscInitialization ();\r
index 0307bca913c15aeec1300753a99281dd25c9dc44..721495b8743acb613d6bfe1b7e1ab5e00ff98001 100644 (file)
@@ -58,6 +58,7 @@
   QemuFwCfgLib\r
   MtrrLib\r
   PcdLib\r
+  BaseMemoryLib\r
 \r
 [Pcd]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase\r
@@ -81,6 +82,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress\r
 \r
 [Ppis]\r