[edk2-devel] [PATCH 3/5] OvmfPkg: Retrieve SMBIOS from Cloud Hypervisor

sebastien.boeuf at intel.com sebastien.boeuf at intel.com
Wed Dec 1 12:01:46 UTC 2021


From: Sebastien Boeuf <sebastien.boeuf at intel.com>

Add a fallback on the SMBIOS code to find the SMBIOS table for Cloud
Hypervisor if it couldn't be found for Qemu through fw_cfg.

Signed-off-by: Rob Bradford <robert.bradford at intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf at intel.com>
---
 OvmfPkg/Include/IndustryStandard/CloudHv.h    |  5 +++
 OvmfPkg/SmbiosPlatformDxe/CloudHv.c           | 32 +++++++++++++++++++
 OvmfPkg/SmbiosPlatformDxe/EntryPoint.c        | 23 +++++++++++--
 .../SmbiosPlatformDxe/SmbiosPlatformDxe.inf   |  1 +
 4 files changed, 59 insertions(+), 2 deletions(-)
 create mode 100644 OvmfPkg/SmbiosPlatformDxe/CloudHv.c

diff --git a/OvmfPkg/Include/IndustryStandard/CloudHv.h b/OvmfPkg/Include/IndustryStandard/CloudHv.h
index 6ab18ad50d..ad0e170795 100644
--- a/OvmfPkg/Include/IndustryStandard/CloudHv.h
+++ b/OvmfPkg/Include/IndustryStandard/CloudHv.h
@@ -32,4 +32,9 @@
 //
 #define CLOUDHV_MMIO_HOLE_SIZE 0x38000000
 
+//
+// SMBIOS address
+//
+#define CLOUDHV_SMBIOS_ADDRESS 0xf0000
+
 #endif // __CLOUDHV_H__
diff --git a/OvmfPkg/SmbiosPlatformDxe/CloudHv.c b/OvmfPkg/SmbiosPlatformDxe/CloudHv.c
new file mode 100644
index 0000000000..f56a810684
--- /dev/null
+++ b/OvmfPkg/SmbiosPlatformDxe/CloudHv.c
@@ -0,0 +1,32 @@
+/** @file
+  Find Cloud Hypervisor SMBIOS data.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <IndustryStandard/CloudHv.h> // CLOUDHV_SMBIOS_ADDRESS
+#include <IndustryStandard/SmBios.h>  // SMBIOS_TABLE_3_0_ENTRY_POINT
+
+/**
+  Locates and extracts the QEMU SMBIOS data if present in fw_cfg
+
+  @return                 Address of extracted QEMU SMBIOS data
+
+**/
+UINT8 *
+GetCloudHvSmbiosTables (
+  VOID
+  )
+{
+  SMBIOS_TABLE_3_0_ENTRY_POINT *CloudHvTables = (VOID *)CLOUDHV_SMBIOS_ADDRESS;
+
+  if (CloudHvTables->AnchorString[0] == '_' &&
+      CloudHvTables->AnchorString[1] == 'S' &&
+      CloudHvTables->AnchorString[2] == 'M' &&
+      CloudHvTables->AnchorString[3] == '3' &&
+      CloudHvTables->AnchorString[4] == '_') {
+    return (UINT8*)(UINTN)CloudHvTables->TableAddress;
+  }
+
+  return NULL;
+}
diff --git a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
index d3b1836a04..28faabb46a 100644
--- a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
+++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
@@ -8,6 +8,11 @@
 
 #include "SmbiosPlatformDxe.h"
 
+UINT8 *
+GetCloudHvSmbiosTables (
+  VOID
+  );
+
 UINT8 *
 GetQemuSmbiosTables (
   VOID
@@ -32,14 +37,28 @@ SmbiosTablePublishEntry (
 {
   EFI_STATUS                Status;
   UINT8                     *SmbiosTables;
+  BOOLEAN                   FreeTables = FALSE;
 
   Status = EFI_NOT_FOUND;
   //
   // Add QEMU SMBIOS data if found
   //
   SmbiosTables = GetQemuSmbiosTables ();
-  if (SmbiosTables != NULL) {
-    Status = InstallAllStructures (SmbiosTables);
+  if (SmbiosTables == NULL) {
+    SmbiosTables = GetCloudHvSmbiosTables ();
+    if (SmbiosTables == NULL) {
+      return EFI_NOT_FOUND;
+    }
+  } else {
+    FreeTables = TRUE;
+  }
+
+  Status = InstallAllStructures (SmbiosTables);
+
+  //
+  // Free SmbiosTables if allocated by Qemu.
+  //
+  if (FreeTables) {
     FreePool (SmbiosTables);
   }
 
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index e239a631f2..365d96241e 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -24,6 +24,7 @@
 #
 
 [Sources]
+  CloudHv.c
   EntryPoint.c
   Qemu.c
   SmbiosPlatformDxe.c
-- 
2.30.2

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84213): https://edk2.groups.io/g/devel/message/84213
Mute This Topic: https://groups.io/mt/87429206/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list