From: sebastien.boeuf@intel.com
To: devel@edk2.groups.io
Cc: jiewen.yao@intel.com, jordan.l.justen@intel.com,
kraxel@redhat.com, sebastien.boeuf@intel.com
Subject: [PATCH v3 3/5] OvmfPkg: Retrieve SMBIOS from Cloud Hypervisor
Date: Mon, 6 Dec 2021 11:12:20 +0100 [thread overview]
Message-ID: <05b4867b1e2184c2cdd7357363d72d81bf33cf2f.1638785380.git.sebastien.boeuf@intel.com> (raw)
In-Reply-To: <cover.1638785380.git.sebastien.boeuf@intel.com>
From: Sebastien Boeuf <sebastien.boeuf@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.
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
---
OvmfPkg/Include/IndustryStandard/CloudHv.h | 5 +++
OvmfPkg/SmbiosPlatformDxe/CloudHv.c | 32 +++++++++++++++++++
OvmfPkg/SmbiosPlatformDxe/EntryPoint.c | 20 +++++++++---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 11 +++++++
.../SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 2 ++
5 files changed, 65 insertions(+), 5 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..e9ce00b6eb
--- /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 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 c72ba1d14b..992ae5e2ab 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 4286a80170..c39206f151 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]
--
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.
next prev parent reply other threads:[~2021-12-06 10:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-06 10:12 [PATCH v3 0/5] Add Cloud Hypervisor support for x86 sebastien.boeuf
2021-12-06 10:12 ` [PATCH v3 1/5] OvmfPkg: Handle Cloud Hypervisor host bridge sebastien.boeuf
2021-12-06 10:41 ` Gerd Hoffmann
2021-12-06 12:10 ` Yao, Jiewen
2021-12-06 10:12 ` [PATCH v3 2/5] OvmfPkg: Create global entry point for SMBIOS parsing sebastien.boeuf
2021-12-06 10:12 ` sebastien.boeuf [this message]
2021-12-06 10:12 ` [PATCH v3 4/5] OvmfPkg: Generalize AcpiPlatformDxe sebastien.boeuf
2021-12-06 10:12 ` [PATCH v3 5/5] OvmfPkg: Install ACPI tables for Cloud Hypervisor sebastien.boeuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05b4867b1e2184c2cdd7357363d72d81bf33cf2f.1638785380.git.sebastien.boeuf@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox