* [PATCH] OvmfPkg/SmbiosPlatformDxe: Always add BIOS Information structure
@ 2022-07-30 6:17 Ammar Ratnani
0 siblings, 0 replies; only message in thread
From: Ammar Ratnani @ 2022-07-30 6:17 UTC (permalink / raw)
To: devel; +Cc: Ammar Ratnani
If OVMF is not running on Cloud Hypervisor nor QEMU, previously no SMBIOS
structures would be registered with the EFI_SMBIOS_PROTOCOL. This patch
instead registers the default BIOS Information (Type 0) structure, defined
as mOvmfDefaultType0 in SmbiosPlatformDxe.c.
This change appeases (at least) the Windows Deployment Services client,
which requires some SMBIOS data to be present.
Signed-off-by: Ammar Ratnani <ammrat13@gmail.com>
---
OvmfPkg/SmbiosPlatformDxe/EntryPoint.c | 11 ++++
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 59 +++++++++++--------
2 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
index e55d135504..4f82cf5da8 100644
--- a/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
+++ b/OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
@@ -48,5 +48,16 @@ SmbiosTablePublishEntry (
}
}
+ //
+ // If Status still reads EFI_NOT_FOUND, either there are no drivers
+ // implementing EFI_SMBIOS_PROTOCOL, or none of the above codepaths ran. In
+ // the second case, call InstallAllStructures with NULL so that the default
+ // Type 0 (BIOS Information) structure is installed. In the first case,
+ // calling InstallAllStructures is harmless because it'll fail immediately.
+ //
+ if (Status == EFI_NOT_FOUND) {
+ Status = InstallAllStructures (NULL);
+ }
+
return Status;
}
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 94249d3ff1..e575a5f141 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -93,12 +93,17 @@ SmbiosTableLength (
/**
Install all structures from the given SMBIOS structures block
+ Notice that the SMBIOS table address is optional. If it's not provided, this
+ function will function as if the first structure encountered is an
+ End-of-Table (Type 127). Importantly, in that case it will still install
+ mOvmfDefaultType0.
+
@param TableAddress SMBIOS tables starting address
**/
EFI_STATUS
InstallAllStructures (
- IN UINT8 *TableAddress
+ IN UINT8 *TableAddress OPTIONAL
)
{
EFI_SMBIOS_PROTOCOL *Smbios;
@@ -119,34 +124,36 @@ InstallAllStructures (
return Status;
}
- SmbiosTable.Raw = TableAddress;
- if (SmbiosTable.Raw == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
NeedSmbiosType0 = TRUE;
- while (SmbiosTable.Hdr->Type != 127) {
- //
- // Log the SMBIOS data for this structure
- //
- SmbiosHandle = SmbiosTable.Hdr->Handle;
- Status = Smbios->Add (
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *)SmbiosTable.Raw
- );
- ASSERT_EFI_ERROR (Status);
-
- if (SmbiosTable.Hdr->Type == 0) {
- NeedSmbiosType0 = FALSE;
+ //
+ // If the TableAddress is NULL, that's not an error. Just don't try to loop
+ // over it.
+ //
+ SmbiosTable.Raw = TableAddress;
+ if (SmbiosTable.Raw != NULL) {
+ while (SmbiosTable.Hdr->Type != 127) {
+ //
+ // Log the SMBIOS data for this structure
+ //
+ SmbiosHandle = SmbiosTable.Hdr->Handle;
+ Status = Smbios->Add (
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *)SmbiosTable.Raw
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ if (SmbiosTable.Hdr->Type == 0) {
+ NeedSmbiosType0 = FALSE;
+ }
+
+ //
+ // Get the next structure address
+ //
+ SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (SmbiosTable));
}
-
- //
- // Get the next structure address
- //
- SmbiosTable.Raw = (UINT8 *)(SmbiosTable.Raw + SmbiosTableLength (SmbiosTable));
}
if (NeedSmbiosType0) {
--
2.37.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-30 6:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-30 6:17 [PATCH] OvmfPkg/SmbiosPlatformDxe: Always add BIOS Information structure Ammar Ratnani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox