From patchwork Fri May 3 09:31:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 10928139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0286933 for ; Fri, 3 May 2019 09:34:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDA512842E for ; Fri, 3 May 2019 09:34:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C190A284BF; Fri, 3 May 2019 09:34:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1AEA22842E for ; Fri, 3 May 2019 09:34:11 +0000 (UTC) Received: from localhost ([127.0.0.1]:37198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMUa2-0008Rk-CO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 May 2019 05:34:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMUXR-0006a0-2c for qemu-devel@nongnu.org; Fri, 03 May 2019 05:31:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hMUXP-0006sj-DR for qemu-devel@nongnu.org; Fri, 03 May 2019 05:31:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hMUXP-0006la-5C for qemu-devel@nongnu.org; Fri, 03 May 2019 05:31:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E65BC8665F for ; Fri, 3 May 2019 09:31:25 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-45.rdu2.redhat.com [10.10.120.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id C86476055B; Fri, 3 May 2019 09:31:24 +0000 (UTC) From: Laszlo Ersek To: qemu devel list Date: Fri, 3 May 2019 11:31:17 +0200 Message-Id: <20190503093118.15700-2-lersek@redhat.com> In-Reply-To: <20190503093118.15700-1-lersek@redhat.com> References: <20190503093118.15700-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 03 May 2019 09:31:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/2] tests/uefi-test-tools: report the SMBIOS entry point structures X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é" Cc: Igor Mammedov Launchpad: https://bugs.launchpad.net/qemu/+bug/1821884 Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Tested-by: Philippe Mathieu-Daudé Tested-by: Igor Mammedov --- Notes: pull: - pick up T-b/R-b from Igor & Phil tests/uefi-test-tools/UefiTestToolsPkg/Include/Guid/BiosTablesTest.h | 25 +++++++++++++++----- tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.inf | 2 ++ tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c | 23 ++++++++++++++---- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/tests/uefi-test-tools/UefiTestToolsPkg/Include/Guid/BiosTablesTest.h b/tests/uefi-test-tools/UefiTestToolsPkg/Include/Guid/BiosTablesTest.h index 0b72c61254af..7a74c121d596 100644 --- a/tests/uefi-test-tools/UefiTestToolsPkg/Include/Guid/BiosTablesTest.h +++ b/tests/uefi-test-tools/UefiTestToolsPkg/Include/Guid/BiosTablesTest.h @@ -1,13 +1,14 @@ /** @file - Expose the address(es) of the ACPI RSD PTR table(s) in a MB-aligned structure - to the hypervisor. + Expose the address(es) of the ACPI RSD PTR table(s) and the SMBIOS entry + point(s) in a MB-aligned structure to the hypervisor. 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 - retrieved, the hypervisor may perform various ACPI checks. + that is at offset 0 in the structure. Once the RSD PTR and SMBIOS anchor + 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 - hypervisors. Do not enable in production builds. + This feature is a development aid, for supporting ACPI and SMBIOS table unit + tests in hypervisors. Do not enable in production builds. Copyright (C) 2019, Red Hat, Inc. @@ -61,6 +62,18 @@ typedef struct { // EFI_PHYSICAL_ADDRESS Rsdp10; 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; #pragma pack () diff --git a/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.inf b/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.inf index 924d8a80d00b..708bc1e7982b 100644 --- a/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.inf +++ b/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.inf @@ -35,6 +35,8 @@ gBiosTablesTestGuid gEfiAcpi10TableGuid gEfiAcpi20TableGuid + gEfiSmbios3TableGuid + gEfiSmbiosTableGuid [Packages] MdePkg/MdePkg.dec diff --git a/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c b/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c index b208e17fb00f..75891e68ec20 100644 --- a/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c +++ b/tests/uefi-test-tools/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -55,6 +56,8 @@ BiosTablesTestMain ( volatile BIOS_TABLES_TEST *BiosTablesTest; CONST VOID *Rsdp10; CONST VOID *Rsdp20; + CONST VOID *Smbios21; + CONST VOID *Smbios30; CONST EFI_CONFIGURATION_TABLE *ConfigTable; CONST EFI_CONFIGURATION_TABLE *ConfigTablesEnd; volatile EFI_GUID *InverseSignature; @@ -77,31 +80,43 @@ BiosTablesTestMain ( } // - // Locate both gEfiAcpi10TableGuid and gEfiAcpi20TableGuid config tables in - // one go. + // Locate all the gEfiAcpi10TableGuid, gEfiAcpi20TableGuid, + // gEfiSmbiosTableGuid, gEfiSmbios3TableGuid config tables in one go. // Rsdp10 = NULL; Rsdp20 = NULL; + Smbios21 = NULL; + Smbios30 = NULL; ConfigTable = gST->ConfigurationTable; 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)) { Rsdp10 = ConfigTable->VendorTable; } else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiAcpi20TableGuid)) { Rsdp20 = ConfigTable->VendorTable; + } else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiSmbiosTableGuid)) { + Smbios21 = ConfigTable->VendorTable; + } else if (CompareGuid (&ConfigTable->VendorGuid, &gEfiSmbios3TableGuid)) { + Smbios30 = ConfigTable->VendorTable; } ++ConfigTable; } AsciiPrint ("%a: BiosTablesTest=%p Rsdp10=%p Rsdp20=%p\n", 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->Rsdp10 = (UINTN)Rsdp10; BiosTablesTest->Rsdp20 = (UINTN)Rsdp20; + BiosTablesTest->Smbios21 = (UINTN)Smbios21; + BiosTablesTest->Smbios30 = (UINTN)Smbios30; MemoryFence();