From nobody Sat Nov 2 14:26:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1488999939675315.24135992698234; Wed, 8 Mar 2017 11:05:39 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8FDB18037A; Wed, 8 Mar 2017 11:05:35 -0800 (PST) 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 EDC358037F for ; Wed, 8 Mar 2017 11:05:33 -0800 (PST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 878DE4E359; Wed, 8 Mar 2017 19:05:34 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-47.phx2.redhat.com [10.3.117.47]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v28J5GPP014080; Wed, 8 Mar 2017 14:05:32 -0500 X-Original-To: edk2-devel@ml01.01.org From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 8 Mar 2017 20:05:10 +0100 Message-Id: <20170308190511.31195-6-lersek@redhat.com> In-Reply-To: <20170308190511.31195-1-lersek@redhat.com> References: <20170308190511.31195-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 08 Mar 2017 19:05:34 +0000 (UTC) Subject: [edk2] [PATCH 5/6] ArmVirtPkg/FdtClientDxe: don't forward DT to OS if QEMU provides ACPI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ArmVirtQemu can be built with -D PURE_ACPI_BOOT_ENABLE at the moment. We should replace that build-time setting with a dynamic one: forward the DT from QEMU to the guest kernel if and only if - the guest architecture is arm32, or - we run on Xen, or - ACPI payload is not available from QEMU. This will let QEMU's "-no-acpi" option exclusively expose DT vs. ACPI to the guest. Showing both is never needed (it is actually detrimental to the adoption of standards, such as SBSA / SBBR). Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- ArmVirtPkg/ArmVirtQemu.dsc | 5 +- ArmVirtPkg/ArmVirtQemuKernel.dsc | 5 +- ArmVirtPkg/ArmVirtXen.dsc | 5 +- ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf | 5 +- ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 67 ++++++++++++++++++-- 5 files changed, 75 insertions(+), 12 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 477dfdcfc764..863077f53edf 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -301,7 +301,10 @@ [Components.common] # Platform Driver # ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf - ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf + ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf { + + QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLibExplicitIni= t.inf + } ArmVirtPkg/HighMemDxe/HighMemDxe.inf OvmfPkg/VirtioBlkDxe/VirtioBlk.inf OvmfPkg/VirtioScsiDxe/VirtioScsi.inf diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index fd39c2802a85..08a8eafd60d0 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -290,7 +290,10 @@ [Components.common] # Platform Driver # ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf - ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf + ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf { + + QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLibExplicitIni= t.inf + } ArmVirtPkg/HighMemDxe/HighMemDxe.inf OvmfPkg/VirtioBlkDxe/VirtioBlk.inf OvmfPkg/VirtioScsiDxe/VirtioScsi.inf diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index 3422d1e5d996..4442329907ae 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -197,7 +197,10 @@ [Components.common] # Platform Driver # ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.inf - ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf + ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf { + + QemuFwCfgLib|ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLibExplicitIni= t.inf + } =20 # # FAT filesystem + GPT/MBR partitioning diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf b/ArmVirtPkg/FdtClien= tDxe/FdtClientDxe.inf index 3a0cd37040eb..832f85bacd9b 100644 --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf @@ -29,12 +29,14 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] BaseLib DebugLib FdtLib HobLib + QemuFwCfgLib UefiBootServicesTableLib UefiDriverEntryPoint =20 @@ -45,8 +47,5 @@ [Guids] gFdtHobGuid gFdtTableGuid =20 -[FeaturePcd] - gArmVirtTokenSpaceGuid.PcdPureAcpiBoot - [Depex] TRUE diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientD= xe/FdtClientDxe.c index 6082b22d35c1..8def7662a271 100644 --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c @@ -18,6 +18,7 @@ #include #include #include +#include #include =20 #include @@ -27,6 +28,15 @@ =20 STATIC VOID *mDeviceTreeBase; =20 +typedef enum { + OsExposureUnavailable, + OsExposureEnabled, + OsExposureDisabled, + OsExposureMax +} OS_EXPOSURE_STATE; + +STATIC OS_EXPOSURE_STATE mOsExposure; + STATIC EFI_STATUS EFIAPI @@ -300,7 +310,11 @@ GetOsExposure ( OUT BOOLEAN *FdtExposedToOs ) { - *FdtExposedToOs =3D !FeaturePcdGet (PcdPureAcpiBoot); + ASSERT (mOsExposure < OsExposureMax); + if (mOsExposure =3D=3D OsExposureUnavailable) { + return EFI_NOT_STARTED; + } + *FdtExposedToOs =3D (BOOLEAN)(mOsExposure =3D=3D OsExposureEnabled); return EFI_SUCCESS; } =20 @@ -317,6 +331,12 @@ STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol =3D { GetOsExposure }; =20 +RETURN_STATUS +EFIAPI +QemuFwCfgInitialize ( + VOID + ); + EFI_STATUS EFIAPI InitializeFdtClientDxe ( @@ -327,6 +347,7 @@ InitializeFdtClientDxe ( VOID *Hob; VOID *DeviceTreeBase; EFI_STATUS Status; + EFI_TPL OldTpl; =20 Hob =3D GetFirstGuidHob (&gFdtHobGuid); if (Hob =3D=3D NULL || GET_GUID_HOB_DATA_SIZE (Hob) !=3D sizeof (UINT64)= ) { @@ -344,15 +365,49 @@ InitializeFdtClientDxe ( =20 DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, mDeviceTreeBase)); =20 - if (!FeaturePcdGet (PcdPureAcpiBoot)) { + // + // Install the protocol for our QemuFwCfgLibExplicitInit instance, but + // prevent any protocol notifies at TPL_CALLBACK from firing. + // + OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); + Status =3D gBS->InstallProtocolInterface (&ImageHandle, + &gFdtClientProtocolGuid, EFI_NATIVE_INTERFACE, + &mFdtClientProtocol); + if (EFI_ERROR (Status)) { + goto RestoreTpl; + } + + // + // Install the FDT as a configuration table only if: + // - we're running on 32-bit ARM, or + // - we're running on Xen, or + // - QEMU doesn't provide us with ACPI payload (e.g. due to the -no-acpi + // option). + // + mOsExposure =3D OsExposureEnabled; + if (MAX_UINTN !=3D MAX_UINT32) { // - // Only install the FDT as a configuration table if we want to leave i= t up - // to the OS to decide whether it prefers ACPI over DT. + // Call the fw_cfg library constructor explicitly. It always succeeds; + // we'll check fw_cfg availability separately. // + QemuFwCfgInitialize (); + if (QemuFwCfgIsAvailable ()) { + FIRMWARE_CONFIG_ITEM FwCfgItem; + UINTN FwCfgSize; + + if (!RETURN_ERROR (QemuFwCfgFindFile ("etc/table-loader", &FwCfgItem, + &FwCfgSize))) { + mOsExposure =3D OsExposureDisabled; + } + } + } + + if (mOsExposure =3D=3D OsExposureEnabled) { Status =3D gBS->InstallConfigurationTable (&gFdtTableGuid, DeviceTreeB= ase); ASSERT_EFI_ERROR (Status); } =20 - return gBS->InstallProtocolInterface (&ImageHandle, &gFdtClientProtocolG= uid, - EFI_NATIVE_INTERFACE, &mFdtClientProtocol); +RestoreTpl: + gBS->RestoreTPL (OldTpl); + return Status; } --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel