Skip to content

Commit

Permalink
Add smbios support
Browse files Browse the repository at this point in the history
Adding support for smbios, besides updating .DSC and .FDF
files. It replaces the `SmbiosTablePublishEntry()` function
to search for the SMBIOS tables at address 0x4000F000.

WARNING: This is an ugly hack, it removes the code for
QEMU and Cloud-Hypervisor support.

Signed-off-by: German Maglione <gmaglione@redhat.com>
  • Loading branch information
germag committed May 23, 2024
1 parent 1e7a16b commit 3652c26
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
6 changes: 6 additions & 0 deletions ArmVirtPkg/ArmVirtKrun.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@
NULL|OvmfPkg/Library/BlobVerifierLibNull/BlobVerifierLibNull.inf
}

#
# SMBIOS Support
#
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf

#
# ACPI Support
#
Expand Down
6 changes: 6 additions & 0 deletions ArmVirtPkg/ArmVirtKrun.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Application/UiApp/UiApp.inf
INF OvmfPkg/QemuKernelLoaderFsDxe/QemuKernelLoaderFsDxe.inf

#
# SMBIOS Support
#
INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf

#
# ACPI Support
#
Expand Down
48 changes: 35 additions & 13 deletions OvmfPkg/SmbiosPlatformDxe/EntryPoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <Library/MemoryAllocationLib.h> // FreePool()
#include <OvmfPlatforms.h> // CLOUDHV_DEVICE_ID
#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_3_0_ENTRY_POINT
#include <Library/DebugLib.h>

#include "SmbiosPlatformDxe.h"

Expand All @@ -28,25 +30,45 @@ SmbiosTablePublishEntry (
{
EFI_STATUS Status;
UINT8 *SmbiosTables;
UINT16 HostBridgeDevId;

Status = EFI_NOT_FOUND;

#define KRUN_SMBIOS_ADDRESS 0x4000F000

//
// Add SMBIOS data if found
//
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);
}
DEBUG ((
DEBUG_VERBOSE,
"%a: Installing libkrun SMBIOS: addr 0x%lx\n",
__func__,
KRUN_SMBIOS_ADDRESS
));

SMBIOS_TABLE_3_0_ENTRY_POINT *KrunTables = (VOID *)KRUN_SMBIOS_ADDRESS;

if ((KrunTables->AnchorString[0] == '_') &&
(KrunTables->AnchorString[1] == 'S') &&
(KrunTables->AnchorString[2] == 'M') &&
(KrunTables->AnchorString[3] == '3') &&
(KrunTables->AnchorString[4] == '_'))
{
DEBUG ((
DEBUG_VERBOSE,
"%a: Found libkrun SMBIOS\n",
__func__
));

SmbiosTables = (UINT8 *)(UINTN)KrunTables->TableAddress;
Status = InstallAllStructures (SmbiosTables);
}

DEBUG ((
DEBUG_VERBOSE,
"%a: libkrun SMBIOS install status: %d\n",
__func__,
Status
));

return Status;
}

0 comments on commit 3652c26

Please sign in to comment.