From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Laszlo Ersek <lersek@redhat.com>
Cc: edk2-devel-01 <edk2-devel@lists.01.org>,
Anthony Perard <anthony.perard@citrix.com>,
Jordan Justen <jordan.l.justen@intel.com>,
Julien Grall <julien.grall@linaro.org>
Subject: Re: [PATCH v2 3/8] OvmfPkg: conditionally disable reserved memory varstore emulation at build
Date: Fri, 1 Dec 2017 08:51:54 +0000 [thread overview]
Message-ID: <CAKv+Gu-HaJktxB-1z=_RCy=W5BL-z7B8uOB6teakZ=mG3R=hpA@mail.gmail.com> (raw)
In-Reply-To: <20171130163029.19743-4-lersek@redhat.com>
On 30 November 2017 at 16:30, Laszlo Ersek <lersek@redhat.com> wrote:
> (All of the below is only relevant for SMM_REQUIRE=FALSE.)
>
> For the emulated variable store, PlatformPei allocates reserved memory (as
> early as possible, so that the address remains the same during reboot),
> and PcdEmuVariableNvStoreReserved carries the address to
> EmuVariableFvbRuntimeDxe.
>
> In addition, QemuFlashFvbServicesRuntimeDxe is always launched before
> EmuVariableFvbRuntimeDxe, so that if flash variables are available,
> QemuFlashFvbServicesRuntimeDxe can set PcdFlashNvStorageVariableBase64
> first, and EmuVariableFvbRuntimeDxe can exit early. This ordering is
> currently enforced by adding QemuFlashFvbServicesRuntimeDxe to the APRIORI
> DXE file.
>
> All of this is unnecessary when MEM_VARSTORE_EMU_ENABLE is set to FALSE.
> In such a build,
>
> - (almost) remove the dynamic default for PcdEmuVariableNvStoreReserved
> (we can't really do this because the PcdSet64() in
> ReserveEmuVariableNvStore() wouldn't compile),
>
If that is the only concern, and the value is irrelevant, you could
make it a patchable PCD instead
> - prevent the reserved memory allocation and PCD setting in PlatformPei,
>
> - exclude EmuVariableFvbRuntimeDxe,
>
> - and drop QemuFlashFvbServicesRuntimeDxe from the APRIORI DXE file (since
> it doesn't have to beat EmuVariableFvbRuntimeDxe in setting
> PcdFlashNvStorageVariableBase64 any longer).
>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Julien Grall <julien.grall@linaro.org>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> OvmfPkg/OvmfPkgIa32.dsc | 4 +++-
> OvmfPkg/OvmfPkgIa32X64.dsc | 4 +++-
> OvmfPkg/OvmfPkgX64.dsc | 4 +++-
> OvmfPkg/OvmfPkgIa32.fdf | 4 +++-
> OvmfPkg/OvmfPkgIa32X64.fdf | 4 +++-
> OvmfPkg/OvmfPkgX64.fdf | 4 +++-
> OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> OvmfPkg/PlatformPei/Platform.c | 3 ++-
> 8 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 443da553d0a3..dd6be0de0445 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -502,7 +502,7 @@ [PcdsFixedAtBuild]
>
> [PcdsDynamicDefault]
> # only set when
> - # ($(SMM_REQUIRE) == FALSE)
> + # (($(SMM_REQUIRE) == FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) == TRUE))
> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
> @@ -871,10 +871,12 @@ [Components]
> # Variable driver stack (non-SMM)
> #
> OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> +!if $(MEM_VARSTORE_EMU_ENABLE) == TRUE
> OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
> <LibraryClasses>
> PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
> }
> +!endif
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
> <LibraryClasses>
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 0fc81743bac4..84c578ac22a4 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -508,7 +508,7 @@ [PcdsFixedAtBuild.X64]
>
> [PcdsDynamicDefault]
> # only set when
> - # ($(SMM_REQUIRE) == FALSE)
> + # (($(SMM_REQUIRE) == FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) == TRUE))
> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
> @@ -881,10 +881,12 @@ [Components.X64]
> # Variable driver stack (non-SMM)
> #
> OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> +!if $(MEM_VARSTORE_EMU_ENABLE) == TRUE
> OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
> <LibraryClasses>
> PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
> }
> +!endif
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
> <LibraryClasses>
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index db33be4bc0b7..b5d385101411 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -507,7 +507,7 @@ [PcdsFixedAtBuild]
>
> [PcdsDynamicDefault]
> # only set when
> - # ($(SMM_REQUIRE) == FALSE)
> + # (($(SMM_REQUIRE) == FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) == TRUE))
> gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
> @@ -879,10 +879,12 @@ [Components]
> # Variable driver stack (non-SMM)
> #
> OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> +!if $(MEM_VARSTORE_EMU_ENABLE) == TRUE
> OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
> <LibraryClasses>
> PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
> }
> +!endif
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
> <LibraryClasses>
> diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
> index ba980834d720..50a2db897bbb 100644
> --- a/OvmfPkg/OvmfPkgIa32.fdf
> +++ b/OvmfPkg/OvmfPkgIa32.fdf
> @@ -191,7 +191,7 @@ [FV.DXEFV]
> APRIORI DXE {
> INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
> -!if $(SMM_REQUIRE) == FALSE
> +!if ($(SMM_REQUIRE) == FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) == TRUE)
> INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> !endif
> }
> @@ -375,7 +375,9 @@ [FV.DXEFV]
> # Variable driver stack (non-SMM)
> #
> INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> +!if $(MEM_VARSTORE_EMU_ENABLE) == TRUE
> INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
> +!endif
> INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> !endif
> diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
> index 72ac82e76b7b..efa01734b576 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.fdf
> +++ b/OvmfPkg/OvmfPkgIa32X64.fdf
> @@ -192,7 +192,7 @@ [FV.DXEFV]
> INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
> INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf
> -!if $(SMM_REQUIRE) == FALSE
> +!if ($(SMM_REQUIRE) == FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) == TRUE)
> INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> !endif
> }
> @@ -382,7 +382,9 @@ [FV.DXEFV]
> # Variable driver stack (non-SMM)
> #
> INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> +!if $(MEM_VARSTORE_EMU_ENABLE) == TRUE
> INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
> +!endif
> INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> !endif
> diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
> index 2fc17810eb23..d7a5ea97bda8 100644
> --- a/OvmfPkg/OvmfPkgX64.fdf
> +++ b/OvmfPkg/OvmfPkgX64.fdf
> @@ -192,7 +192,7 @@ [FV.DXEFV]
> INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
> INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf
> -!if $(SMM_REQUIRE) == FALSE
> +!if ($(SMM_REQUIRE) == FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) == TRUE)
> INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> !endif
> }
> @@ -382,7 +382,9 @@ [FV.DXEFV]
> # Variable driver stack (non-SMM)
> #
> INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
> +!if $(MEM_VARSTORE_EMU_ENABLE) == TRUE
> INF OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
> +!endif
> INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
> INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> !endif
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index de7434d93dc0..4b8626cb2a27 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -108,6 +108,7 @@ [FixedPcd]
>
> [FeaturePcd]
> gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
> + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable
>
> [Ppis]
> gEfiPeiMasterBootModePpiGuid
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 5a78668126b4..34e7e903fc70 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -664,7 +664,8 @@ InitializePlatform (
> }
>
> if (mBootMode != BOOT_ON_S3_RESUME) {
> - if (!FeaturePcdGet (PcdSmmSmramRequire)) {
> + if (!FeaturePcdGet (PcdSmmSmramRequire) &&
> + FeaturePcdGet (PcdMemVarstoreEmuEnable)) {
> ReserveEmuVariableNvStore ();
> }
> PeiFvInitialization ();
> --
> 2.14.1.3.gb7cf6e02401b
>
>
next prev parent reply other threads:[~2017-12-01 8:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 16:30 [PATCH v2 0/8] OvmfPkg: add the Variable PEIM, defragment the UEFI memmap Laszlo Ersek
2017-11-30 16:30 ` [PATCH v2 1/8] OvmfPkg: introduce PcdMemVarstoreEmuEnable feature flag Laszlo Ersek
2017-12-01 8:44 ` Ard Biesheuvel
2017-11-30 16:30 ` [PATCH v2 2/8] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: check PcdMemVarstoreEmuEnable Laszlo Ersek
2017-12-01 8:44 ` Ard Biesheuvel
2017-11-30 16:30 ` [PATCH v2 3/8] OvmfPkg: conditionally disable reserved memory varstore emulation at build Laszlo Ersek
2017-12-01 8:51 ` Ard Biesheuvel [this message]
2017-12-01 10:52 ` Laszlo Ersek
2017-12-01 10:53 ` Ard Biesheuvel
2017-12-01 11:41 ` Laszlo Ersek
2017-12-02 8:53 ` Ard Biesheuvel
2017-11-30 16:30 ` [PATCH v2 4/8] OvmfPkg: introduce FlashNvStorageAddressLib Laszlo Ersek
2017-12-01 8:55 ` Ard Biesheuvel
2017-12-01 11:03 ` Laszlo Ersek
2017-12-01 11:28 ` Laszlo Ersek
2017-11-30 16:30 ` [PATCH v2 5/8] OvmfPkg: include FaultTolerantWritePei and VariablePei Laszlo Ersek
2017-11-30 16:30 ` [PATCH v2 6/8] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: don't set flash PCDs if SMM or no-emu Laszlo Ersek
2017-11-30 16:30 ` [PATCH v2 7/8] OvmfPkg/PlatformPei: remedy UEFI memory map fragmentation Laszlo Ersek
2017-11-30 16:30 ` [PATCH v2 8/8] OvmfPkg/README: document MEM_VARSTORE_EMU_ENABLE and memmap defrag Laszlo Ersek
2017-11-30 19:00 ` [PATCH v2 0/8] OvmfPkg: add the Variable PEIM, defragment the UEFI memmap Jordan Justen
2017-12-01 8:42 ` Ard Biesheuvel
2017-12-01 10:48 ` Laszlo Ersek
2017-12-01 10:44 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKv+Gu-HaJktxB-1z=_RCy=W5BL-z7B8uOB6teakZ=mG3R=hpA@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox