From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::241; helo=mail-io0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x241.google.com (mail-io0-x241.google.com [IPv6:2607:f8b0:4001:c06::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 60C6A220C1C5A for ; Fri, 1 Dec 2017 00:51:06 -0800 (PST) Received: by mail-io0-x241.google.com with SMTP id d21so10496987ioe.7 for ; Fri, 01 Dec 2017 00:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gWNU9zLMxaKZMrBeoy8+jq0Nujw+asaKRgYg0hYqIOs=; b=c9zrILgkQ1YWUiHf4t5UMzEz16tnRabcFOujsGD0h90zer3u1n6NoN0BupghK429rX NdKCs0oo0wyOmYgWrCufk02tcVOmiUgS4pplU1GVVBxcRHMkYOaLHcjS5rlIeTavLjaN v4lbeCMPqAMAWqeJZ95BlZEBo78x/xPi7YbuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gWNU9zLMxaKZMrBeoy8+jq0Nujw+asaKRgYg0hYqIOs=; b=IietJ2jk7WshYJDl5yz5zUYlAlg4mlDyc+fD6coq2aU7irMDYLM9/cUwJWgrt43uEu Y99PhEbtue+vxgznvOfik9Q4mot3y4sgnK0eMOZiCAugS4UWxhvsPBd898Uyg6INSZ+7 +h6PsIvH7R+hO01cK7Nv/xNLMfRkOTnOTVToYl/vpLGu6BGPyCYkf2DfXN9gJNDLWEP5 A+4IrX96ToV7CgX7B2T4u/2ArIufDOAQSYA5kcZ64T0DkyfLuexwKPmguTnKw6JUfBYY Ehzw00BAr8WZf5aKF5bYwXvhCQoFTwhoOCeSCW8/C5PG2zEZsyy1yF2O2h6eSLUR5PfX EYDw== X-Gm-Message-State: AJaThX5+tYcu3pm/JwKD4pdpIlwDWKoHjwVH/JUlOK3NKiSSFFuidMMX 1U7aNUztlCqqLiiiDnyhgxT/E65TiXV4mB4LJklDdw== X-Google-Smtp-Source: AGs4zMYptzkEhkMRmJhF44re9/0FRn12YLkoca1S4UZ24JzjYHagZTFy4PkrMu39e7Xkl27ZWUMUsArniDN6bQzPiPI= X-Received: by 10.107.59.85 with SMTP id i82mr11221266ioa.253.1512118532014; Fri, 01 Dec 2017 00:55:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.104.16 with HTTP; Fri, 1 Dec 2017 00:55:31 -0800 (PST) In-Reply-To: <20171130163029.19743-5-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> <20171130163029.19743-5-lersek@redhat.com> From: Ard Biesheuvel Date: Fri, 1 Dec 2017 08:55:31 +0000 Message-ID: To: Laszlo Ersek Cc: edk2-devel-01 , Anthony Perard , Jordan Justen , Julien Grall Subject: Re: [PATCH v2 4/8] OvmfPkg: introduce FlashNvStorageAddressLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Dec 2017 08:51:06 -0000 Content-Type: text/plain; charset="UTF-8" On 30 November 2017 at 16:30, Laszlo Ersek wrote: > An OVMF binary built with > > -D SMM_REQUIRE > > or with > > -D MEM_VARSTORE_EMU_ENABLE=FALSE > > requires flash to be present at the expected (build-time determined) > location; falling back to the emulated varstore is not possible. > > In such builds, we can replace the settings of the > - varstore, > - FTW working block, > - and FTW spare area > address PCDs in QemuFlashFvbServicesRuntimeDxe with identical settings in > a new plug-in (NULL class) library, to be linked into variable-related > PEIMs. > > This will enable such builds to access variables during the PEI phase, > without dynamic flash detection and without ordering constraints against > other PEIMs. > Why can't we set these at build time in this case? > Cc: Anthony Perard > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Julien Grall > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Laszlo Ersek > --- > OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.inf | 48 ++++++++++++++++++ > OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c | 53 ++++++++++++++++++++ > 2 files changed, 101 insertions(+) > > diff --git a/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.inf b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.inf > new file mode 100644 > index 000000000000..f79194f80de9 > --- /dev/null > +++ b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.inf > @@ -0,0 +1,48 @@ > +## @file > +# > +# A hook-in library for variable-related PEIMs, in order to set > +# - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64, > +# - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase, > +# - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase, > +# from their gUefiOvmfPkgTokenSpaceGuid counterparts, just before those PEIMs > +# consume them. > +# > +# Copyright (C) 2017, 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. > +# > +## > + > +[Defines] > + INF_VERSION = 1.25 > + BASE_NAME = FlashNvStorageAddressLib > + FILE_GUID = 5FF5A9F9-D01E-49EC-9A17-1682FC85122F > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = FlashNvStorageAddressLib|PEIM > + CONSTRUCTOR = SetFlashNvStorageAddresses > + > +[Sources] > + FlashNvStorageAddressLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + OvmfPkg/OvmfPkg.dec > + > +[LibraryClasses] > + PcdLib > + > +[Pcd] > + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase > + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase > + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 > + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase > + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase > + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase > diff --git a/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c > new file mode 100644 > index 000000000000..dc1280cc23f1 > --- /dev/null > +++ b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c > @@ -0,0 +1,53 @@ > +/** @file > + > + A hook-in library for variable-related PEIMs, in order to set > + - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64, > + - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase, > + - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase, > + from their gUefiOvmfPkgTokenSpaceGuid counterparts, just before those PEIMs > + consume them. > + > + Copyright (C) 2017, 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 > + > +RETURN_STATUS > +EFIAPI > +SetFlashNvStorageAddresses ( > + VOID > + ) > +{ > + RETURN_STATUS PcdStatus; > + > + PcdStatus = PcdSet64S ( > + PcdFlashNvStorageVariableBase64, > + PcdGet32 (PcdOvmfFlashNvStorageVariableBase) > + ); > + if (RETURN_ERROR (PcdStatus)) { > + return PcdStatus; > + } > + > + PcdStatus = PcdSet32S ( > + PcdFlashNvStorageFtwWorkingBase, > + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) > + ); > + if (RETURN_ERROR (PcdStatus)) { > + return PcdStatus; > + } > + > + PcdStatus = PcdSet32S ( > + PcdFlashNvStorageFtwSpareBase, > + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) > + ); > + return PcdStatus; > +} > -- > 2.14.1.3.gb7cf6e02401b > >