summaryrefslogtreecommitdiffstats
path: root/OvmfPkg
diff options
context:
space:
mode:
authorSebastien Boeuf <sebastien.boeuf@intel.com>2021-12-10 22:41:56 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-11 14:26:05 +0000
commitd8ef774346c884658100567501cff96019a25f29 (patch)
treeb106e69f7ed6663d3bed2a39e0f76db6cab93d39 /OvmfPkg
parent2ccefa32a65164da2ec74e8a1e81f90257967c7f (diff)
downloadedk2-d8ef774346c884658100567501cff96019a25f29.tar.gz
edk2-d8ef774346c884658100567501cff96019a25f29.tar.bz2
edk2-d8ef774346c884658100567501cff96019a25f29.zip
OvmfPkg: Retrieve SMBIOS from Cloud Hypervisor
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. Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Rob Bradford <robert.bradford@intel.com> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Diffstat (limited to 'OvmfPkg')
-rw-r--r--OvmfPkg/Include/IndustryStandard/CloudHv.h5
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/CloudHv.c33
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/EntryPoint.c20
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h11
-rw-r--r--OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf2
5 files changed, 66 insertions, 5 deletions
diff --git a/OvmfPkg/Include/IndustryStandard/CloudHv.h b/OvmfPkg/Include/IndustryStandard/CloudHv.h
index 1155335690..d31ecc9eec 100644
--- a/OvmfPkg/Include/IndustryStandard/CloudHv.h
+++ b/OvmfPkg/Include/IndustryStandard/CloudHv.h
@@ -33,4 +33,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..792e4ae981
--- /dev/null
+++ b/OvmfPkg/SmbiosPlatformDxe/CloudHv.c
@@ -0,0 +1,33 @@
+/** @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 Cloud Hypervisor SMBIOS data
+
+ @return Address of extracted Cloud Hypervisor 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 f53af2b2e6..e55d135504 100644
--- a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
+++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
@@ -5,6 +5,7 @@
**/
#include <Library/MemoryAllocationLib.h> // FreePool()
+#include <OvmfPlatforms.h> // CLOUDHV_DEVICE_ID
#include "SmbiosPlatformDxe.h"
@@ -27,15 +28,24 @@ SmbiosTablePublishEntry (
{
EFI_STATUS Status;
UINT8 *SmbiosTables;
+ UINT16 HostBridgeDevId;
Status = EFI_NOT_FOUND;
//
- // Add QEMU SMBIOS data if found
+ // Add SMBIOS data if found
//
- SmbiosTables = GetQemuSmbiosTables ();
- if (SmbiosTables != NULL) {
- Status = InstallAllStructures (SmbiosTables);
- FreePool (SmbiosTables);
+ HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
+ if (HostBridgeDevId == CLOUDHV_DEVICE_ID) {
+ SmbiosTables = GetCloudHvSmbiosTables ();
+ if (SmbiosTables != NULL) {
+ Status = InstallAllStructures (SmbiosTables);
+ }
+ } else {
+ SmbiosTables = GetQemuSmbiosTables ();
+ if (SmbiosTables != NULL) {
+ Status = InstallAllStructures (SmbiosTables);
+ FreePool (SmbiosTables);
+ }
}
return Status;
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index b7bf004be9..709e096e7b 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -33,4 +33,15 @@ GetQemuSmbiosTables (
VOID
);
+/**
+ Locates and extracts Cloud Hypervisor SMBIOS data
+
+ @return Address of extracted Cloud Hypervisor SMBIOS data
+
+**/
+UINT8 *
+GetCloudHvSmbiosTables (
+ VOID
+ );
+
#endif
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index e239a631f2..0066bbc922 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -24,6 +24,7 @@
#
[Sources]
+ CloudHv.c
EntryPoint.c
Qemu.c
SmbiosPlatformDxe.c
@@ -42,6 +43,7 @@
UefiDriverEntryPoint
[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated
[Protocols]