From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 755EB21190721 for ; Sun, 25 Nov 2018 02:02:15 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F12B3C015C17; Sun, 25 Nov 2018 10:02:14 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-51.rdu2.redhat.com [10.10.120.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id B69281974D; Sun, 25 Nov 2018 10:02:10 +0000 (UTC) From: Laszlo Ersek To: edk2-devel@lists.01.org Cc: Anthony Perard , Ard Biesheuvel , Drew Jones , Igor Mammedov , Jordan Justen , Julien Grall , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Sun, 25 Nov 2018 11:01:51 +0100 Message-Id: <20181125100152.25675-4-lersek@redhat.com> In-Reply-To: <20181125100152.25675-1-lersek@redhat.com> References: <20181125100152.25675-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 25 Nov 2018 10:02:15 +0000 (UTC) Subject: [PATCH 3/4] OvmfPkg/AcpiPlatformDxe: add [Un]RegisterAcpiTestSupport() skeletons X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Nov 2018 10:02:15 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce the PcdAcpiTestSupport Feature PCD to OvmfPkg. This PCD will decide whether AcpiPlatformDxe populates the ACPI_TEST_SUPPORT structure at the first Ready-To-Boot event. (The Ready-To-Boot event is chosen because (a) it is bound to occur after AcpiPlatformDxe installs the ACPI tables, and (b) it is guaranteed to occur, namely when the boot manager launches the built-in UEFI shell.) Introduce the RegisterAcpiTestSupport() and UnregisterAcpiTestSupport() functions as skeletons, and call them dependent on the PCD, from the driver's entry point function. Refactor the entry point function so the registration can be rolled back on the failure path. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Drew Jones Cc: Igor Mammedov Cc: Jordan Justen Cc: Julien Grall Cc: Philippe Mathieu-Daudé Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek --- OvmfPkg/OvmfPkg.dec | 5 ++++ OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 4 +++ OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf | 4 +++ OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h | 10 +++++++ OvmfPkg/AcpiPlatformDxe/AcpiTestSupport.c | 30 ++++++++++++++++++++ OvmfPkg/AcpiPlatformDxe/EntryPoint.c | 24 ++++++++++++---- 6 files changed, 72 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index e8c7d9423f43..00765a7995fa 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -155,13 +155,18 @@ [PcdsDynamic, PcdsDynamicEx] [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN|0x1d ## This feature flag enables SMM/SMRAM support. Note that it also requires # such support from the underlying QEMU instance; if that support is not # present, the firmware will reject continuing after a certain point. # # The flag also acts as a general "security switch"; when TRUE, many # components will change behavior, with the goal of preventing a malicious # runtime OS from tampering with firmware structures (special memory ranges # used by OVMF, the varstore pflash chip, LockBox etc). gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e + + ## Instruct AcpiPlatformDxe to expose the RSD PTR address(es) in the + # MB-aligned ACPI_TEST_SUPPORT structure to the hypervisor. This is a + # development / unit test aid; do not enable in production builds. + gUefiOvmfPkgTokenSpaceGuid.PcdAcpiTestSupport|FALSE|BOOLEAN|3 diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf index 8440e7b343d8..9c5bfe767981 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -29,10 +29,11 @@ [Defines] [Sources] AcpiPlatform.c AcpiPlatform.h + AcpiTestSupport.c BootScript.c EntryPoint.c PciDecoding.c Qemu.c QemuFwCfgAcpi.c QemuLoader.h Xen.c @@ -75,5 +76,8 @@ [Pcd] gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress +[FeaturePcd] + gUefiOvmfPkgTokenSpaceGuid.PcdAcpiTestSupport + [Depex] gEfiAcpiTableProtocolGuid diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf index f0fb3496e700..b2501fea9ca4 100644 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf +++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf @@ -28,9 +28,10 @@ [Defines] [Sources] AcpiPlatform.h + AcpiTestSupport.c BootScript.c EntryPoint.c PciDecoding.c QemuFwCfgAcpi.c QemuFwCfgAcpiPlatform.c QemuLoader.h @@ -62,5 +63,8 @@ [Guids] [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration +[FeaturePcd] + gUefiOvmfPkgTokenSpaceGuid.PcdAcpiTestSupport + [Depex] gEfiAcpiTableProtocolGuid diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h index 83b981ee005d..4769b92621b9 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h @@ -117,6 +117,16 @@ EFI_STATUS TransferS3ContextToBootScript ( IN S3_CONTEXT *S3Context ); +VOID +RegisterAcpiTestSupport ( + VOID + ); + +VOID +UnregisterAcpiTestSupport ( + VOID + ); + #endif diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiTestSupport.c b/OvmfPkg/AcpiPlatformDxe/AcpiTestSupport.c new file mode 100644 index 000000000000..462c8e64a4fd --- /dev/null +++ b/OvmfPkg/AcpiPlatformDxe/AcpiTestSupport.c @@ -0,0 +1,30 @@ +/** @file + Register a Ready-To-Boot callback for populating the ACPI_TEST_SUPPORT + structure. + + Copyright (C) 2018, Red Hat, Inc. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ + +#include "AcpiPlatform.h" + +VOID +RegisterAcpiTestSupport ( + VOID + ) +{ +} + +VOID +UnregisterAcpiTestSupport ( + VOID + ) +{ +} diff --git a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c b/OvmfPkg/AcpiPlatformDxe/EntryPoint.c index 1bfd31a0371a..d32fba4f22f4 100644 --- a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c +++ b/OvmfPkg/AcpiPlatformDxe/EntryPoint.c @@ -61,36 +61,50 @@ EFIAPI AcpiPlatformEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_EVENT RootBridgesConnected; + if (FeaturePcdGet (PcdAcpiTestSupport)) { + RegisterAcpiTestSupport (); + } + // // If the platform doesn't support PCI, or PCI enumeration has been disabled, // install the tables at once, and let the entry point's return code reflect // the full functionality. // if (PcdGetBool (PcdPciDisableBusEnumeration)) { DEBUG ((EFI_D_INFO, "%a: PCI or its enumeration disabled, installing " "ACPI tables\n", __FUNCTION__)); - return InstallAcpiTables (FindAcpiTableProtocol ()); + Status = InstallAcpiTables (FindAcpiTableProtocol ()); + if (EFI_ERROR (Status)) { + goto RollbackAcpiTestSupport; + } + return EFI_SUCCESS; } // // Otherwise, delay installing the ACPI tables until root bridges are // connected. The entry point's return status will only reflect the callback // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked // strictly before BDS is entered and can connect the root bridges.) // Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnRootBridgesConnected, NULL /* Context */, &gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected); - if (!EFI_ERROR (Status)) { - DEBUG ((EFI_D_INFO, - "%a: waiting for root bridges to be connected, registered callback\n", - __FUNCTION__)); + if (EFI_ERROR (Status)) { + goto RollbackAcpiTestSupport; } + DEBUG ((DEBUG_INFO, + "%a: waiting for root bridges to be connected, registered callback\n", + __FUNCTION__)); + return EFI_SUCCESS; +RollbackAcpiTestSupport: + if (FeaturePcdGet (PcdAcpiTestSupport)) { + UnregisterAcpiTestSupport (); + } return Status; } -- 2.19.1.3.g30247aa5d201