tests/uefi-test-tools: report the SMBIOS entry point structures

On UEFI systems, the SMBIOS entry point (a.k.a. anchor) structures are
found similarly to the ACPI RSD PTR table(s): by scanning the
ConfigurationTable array in the EFI system table for well-known GUIDs.

Locate the SMBIOS 2.1 (32-bit) and 3.0 (64-bit) anchors in the
BiosTablesTest UEFI application, and report the addresses in new fields
appended to the BIOS_TABLES_TEST structure.

Cc: "Philippe Mathieu-Daud" <philmd@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Launchpad: https://bugs.launchpad.net/qemu/+bug/1821884
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daud <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Philippe Mathieu-Daud <philmd@redhat.com>
Tested-by: Igor Mammedov <imammedo@redhat.com>
This commit is contained in:
Laszlo Ersek 2019-04-25 11:44:15 +02:00
parent 8482ff2eb3
commit b097ba371a
3 changed files with 40 additions and 10 deletions

View File

@ -14,6 +14,7 @@
#include <Guid/Acpi.h> #include <Guid/Acpi.h>
#include <Guid/BiosTablesTest.h> #include <Guid/BiosTablesTest.h>
#include <Guid/SmBios.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
@ -55,6 +56,8 @@ BiosTablesTestMain (
volatile BIOS_TABLES_TEST *BiosTablesTest; volatile BIOS_TABLES_TEST *BiosTablesTest;
CONST VOID *Rsdp10; CONST VOID *Rsdp10;
CONST VOID *Rsdp20; CONST VOID *Rsdp20;
CONST VOID *Smbios21;
CONST VOID *Smbios30;
CONST EFI_CONFIGURATION_TABLE *ConfigTable; CONST EFI_CONFIGURATION_TABLE *ConfigTable;
CONST EFI_CONFIGURATION_TABLE *ConfigTablesEnd; CONST EFI_CONFIGURATION_TABLE *ConfigTablesEnd;
volatile EFI_GUID *InverseSignature; volatile EFI_GUID *InverseSignature;
@ -77,31 +80,43 @@ BiosTablesTestMain (
} }
// //
// Locate both gEfiAcpi10TableGuid and gEfiAcpi20TableGuid config tables in // Locate all the gEfiAcpi10TableGuid, gEfiAcpi20TableGuid,
// one go. // gEfiSmbiosTableGuid, gEfiSmbios3TableGuid config tables in one go.
// //
Rsdp10 = NULL; Rsdp10 = NULL;
Rsdp20 = NULL; Rsdp20 = NULL;
Smbios21 = NULL;
Smbios30 = NULL;
ConfigTable = gST->ConfigurationTable; ConfigTable = gST->ConfigurationTable;
ConfigTablesEnd = gST->ConfigurationTable + gST->NumberOfTableEntries; ConfigTablesEnd = gST->ConfigurationTable + gST->NumberOfTableEntries;
while ((Rsdp10 == NULL || Rsdp20 == NULL) && ConfigTable < ConfigTablesEnd) { while ((Rsdp10 == NULL || Rsdp20 == NULL ||
Smbios21 == NULL || Smbios30 == NULL) &&
ConfigTable < ConfigTablesEnd) {
if (CompareGuid (&ConfigTable->VendorGuid, &gEfiAcpi10TableGuid)) { if (CompareGuid (&ConfigTable->VendorGuid, &gEfiAcpi10TableGuid)) {
Rsdp10 = ConfigTable->VendorTable; Rsdp10 = ConfigTable->VendorTable;
} else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiAcpi20TableGuid)) { } else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiAcpi20TableGuid)) {
Rsdp20 = ConfigTable->VendorTable; Rsdp20 = ConfigTable->VendorTable;
} else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiSmbiosTableGuid)) {
Smbios21 = ConfigTable->VendorTable;
} else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiSmbios3TableGuid)) {
Smbios30 = ConfigTable->VendorTable;
} }
++ConfigTable; ++ConfigTable;
} }
AsciiPrint ("%a: BiosTablesTest=%p Rsdp10=%p Rsdp20=%p\n", AsciiPrint ("%a: BiosTablesTest=%p Rsdp10=%p Rsdp20=%p\n",
gEfiCallerBaseName, Pages, Rsdp10, Rsdp20); gEfiCallerBaseName, Pages, Rsdp10, Rsdp20);
AsciiPrint ("%a: Smbios21=%p Smbios30=%p\n", gEfiCallerBaseName, Smbios21,
Smbios30);
// //
// Store the RSD PTR address(es) first, then the signature second. // Store the config table addresses first, then the signature second.
// //
BiosTablesTest = Pages; BiosTablesTest = Pages;
BiosTablesTest->Rsdp10 = (UINTN)Rsdp10; BiosTablesTest->Rsdp10 = (UINTN)Rsdp10;
BiosTablesTest->Rsdp20 = (UINTN)Rsdp20; BiosTablesTest->Rsdp20 = (UINTN)Rsdp20;
BiosTablesTest->Smbios21 = (UINTN)Smbios21;
BiosTablesTest->Smbios30 = (UINTN)Smbios30;
MemoryFence(); MemoryFence();

View File

@ -35,6 +35,8 @@
gBiosTablesTestGuid gBiosTablesTestGuid
gEfiAcpi10TableGuid gEfiAcpi10TableGuid
gEfiAcpi20TableGuid gEfiAcpi20TableGuid
gEfiSmbios3TableGuid
gEfiSmbiosTableGuid
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec

View File

@ -1,13 +1,14 @@
/** @file /** @file
Expose the address(es) of the ACPI RSD PTR table(s) in a MB-aligned structure Expose the address(es) of the ACPI RSD PTR table(s) and the SMBIOS entry
to the hypervisor. point(s) in a MB-aligned structure to the hypervisor.
The hypervisor locates the MB-aligned structure based on the signature GUID The hypervisor locates the MB-aligned structure based on the signature GUID
that is at offset 0 in the structure. Once the RSD PTR address(es) are that is at offset 0 in the structure. Once the RSD PTR and SMBIOS anchor
retrieved, the hypervisor may perform various ACPI checks. address(es) are retrieved, the hypervisor may perform various ACPI and SMBIOS
checks.
This feature is a development aid, for supporting ACPI table unit tests in This feature is a development aid, for supporting ACPI and SMBIOS table unit
hypervisors. Do not enable in production builds. tests in hypervisors. Do not enable in production builds.
Copyright (C) 2019, Red Hat, Inc. Copyright (C) 2019, Red Hat, Inc.
@ -61,6 +62,18 @@ typedef struct {
// //
EFI_PHYSICAL_ADDRESS Rsdp10; EFI_PHYSICAL_ADDRESS Rsdp10;
EFI_PHYSICAL_ADDRESS Rsdp20; EFI_PHYSICAL_ADDRESS Rsdp20;
//
// The Smbios21 and Smbios30 fields may be read when the signature GUID
// matches. Smbios21 is the guest-physical address of the SMBIOS 2.1 (32-bit)
// Entry Point Structure from the SMBIOS v3.2.0 specification, in 8-byte
// little endian representation. Smbios30 is the guest-physical address of
// the SMBIOS 3.0 (64-bit) Entry Point Structure from the same specification,
// in the same representation. Each of these fields may be zero
// (independently of the other) if the UEFI System Table does not provide the
// corresponding UEFI Configuration Table.
//
EFI_PHYSICAL_ADDRESS Smbios21;
EFI_PHYSICAL_ADDRESS Smbios30;
} BIOS_TABLES_TEST; } BIOS_TABLES_TEST;
#pragma pack () #pragma pack ()