From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059440833827.5193180493214; Thu, 30 Nov 2017 08:30:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 82351220F3C57; Thu, 30 Nov 2017 08:26:14 -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 8FB2E220C1C5B for ; Thu, 30 Nov 2017 08:26:11 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAD078553F; Thu, 30 Nov 2017 16:30:36 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37BA25D9C8; Thu, 30 Nov 2017 16:30:35 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:22 +0100 Message-Id: <20171130163029.19743-2-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 30 Nov 2017 16:30:36 +0000 (UTC) Subject: [edk2] [PATCH v2 1/8] OvmfPkg: introduce PcdMemVarstoreEmuEnable feature flag 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: , Cc: Anthony Perard , Jordan Justen , 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" ... and the corresponding MEM_VARSTORE_EMU_ENABLE build define, which defaults to TRUE. Setting the build flag to FALSE will later enable the exclusion of the dynamically allocated, emulated, in-memory varstore. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Julien Grall Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel --- OvmfPkg/OvmfPkg.dec | 6 ++++++ OvmfPkg/OvmfPkgIa32.dsc | 4 ++++ OvmfPkg/OvmfPkgIa32X64.dsc | 4 ++++ OvmfPkg/OvmfPkgX64.dsc | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 27bcfc141e5a..f03dd7e27d6b 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -150,3 +150,9 @@ [PcdsFeatureFlag] # runtime OS from tampering with firmware structures (special memory ra= nges # used by OVMF, the varstore pflash chip, LockBox etc). gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e + + ## This feature flag reports whether in-memory (that is, non-flash) vari= able + # emulation is enabled. Note that with PcdSmmSmramRequire set to TRUE, = this + # setting is irrelevant, as SMM/SMRAM support always requires flash + # variables. + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable|TRUE|BOOLEAN|3 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 9d23f8c162e4..443da553d0a3 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -39,6 +39,7 @@ [Defines] DEFINE HTTP_BOOT_ENABLE =3D FALSE DEFINE SMM_REQUIRE =3D FALSE DEFINE TLS_ENABLE =3D FALSE + DEFINE MEM_VARSTORE_EMU_ENABLE =3D TRUE =20 # # Flash size selection. Setting FD_SIZE_IN_KB on the command line direct= ly to @@ -410,6 +411,9 @@ [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE !endif +!if $(MEM_VARSTORE_EMU_ENABLE) =3D=3D FALSE + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable|FALSE +!endif =20 [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index a9c667fed8b0..0fc81743bac4 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -39,6 +39,7 @@ [Defines] DEFINE HTTP_BOOT_ENABLE =3D FALSE DEFINE SMM_REQUIRE =3D FALSE DEFINE TLS_ENABLE =3D FALSE + DEFINE MEM_VARSTORE_EMU_ENABLE =3D TRUE =20 # # Flash size selection. Setting FD_SIZE_IN_KB on the command line direct= ly to @@ -415,6 +416,9 @@ [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE !endif +!if $(MEM_VARSTORE_EMU_ENABLE) =3D=3D FALSE + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable|FALSE +!endif =20 [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index abf570512a38..db33be4bc0b7 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -39,6 +39,7 @@ [Defines] DEFINE HTTP_BOOT_ENABLE =3D FALSE DEFINE SMM_REQUIRE =3D FALSE DEFINE TLS_ENABLE =3D FALSE + DEFINE MEM_VARSTORE_EMU_ENABLE =3D TRUE =20 # # Flash size selection. Setting FD_SIZE_IN_KB on the command line direct= ly to @@ -415,6 +416,9 @@ [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE !endif +!if $(MEM_VARSTORE_EMU_ENABLE) =3D=3D FALSE + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable|FALSE +!endif =20 [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 15120594428391005.8923479930917; Thu, 30 Nov 2017 08:30:42 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BD251220F3C5B; Thu, 30 Nov 2017 08:26:14 -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 746A0220C1C3A for ; Thu, 30 Nov 2017 08:26:13 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8708AA84E; Thu, 30 Nov 2017 16:30:38 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 144F45D9C8; Thu, 30 Nov 2017 16:30:36 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:23 +0100 Message-Id: <20171130163029.19743-3-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 30 Nov 2017 16:30:38 +0000 (UTC) Subject: [edk2] [PATCH v2 2/8] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: check PcdMemVarstoreEmuEnable 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: , Cc: Anthony Perard , Jordan Justen , 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" This patch parallels commit b963ec494c48 ("OvmfPkg: QemuFlashFvbServicesRuntimeDxe: adhere to -D SMM_REQUIRE", 2015-11-30) in that if QemuFlashDetected() fails -- because flash is not found --, not only SMM_REQUIRE=3DTRUE is a wrong build to execute, but MEM_VARSTORE_EMU_ENABLE=3DFALSE as well. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Julien Grall Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel --- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf | 1 + OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf | 1 + OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 1 + 3 files changed, 3 insertions(+) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.i= nf b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf index c0dda75bf75f..cf30d5c8f021 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf @@ -87,6 +87,7 @@ [Pcd] =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable =20 [Depex] TRUE diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf b/Ov= mfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf index ba2d3679a46d..d5aa393dbc0b 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesSmm.inf @@ -86,6 +86,7 @@ [Pcd] =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable =20 [Depex] TRUE diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/Q= emuFlashFvbServicesRuntimeDxe/QemuFlash.c index 5677b5ee119c..60bc7a84bd6b 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c @@ -246,6 +246,7 @@ QemuFlashInitialize ( =20 if (!QemuFlashDetected ()) { ASSERT (!FeaturePcdGet (PcdSmmSmramRequire)); + ASSERT (FeaturePcdGet (PcdMemVarstoreEmuEnable)); return EFI_WRITE_PROTECTED; } =20 --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059445752703.4104398758861; Thu, 30 Nov 2017 08:30:45 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0AF03220F3C4F; Thu, 30 Nov 2017 08:26:18 -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 6DD92220C1C5B for ; Thu, 30 Nov 2017 08:26:15 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64E616A7D9; Thu, 30 Nov 2017 16:30:40 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id E597E5D9C7; Thu, 30 Nov 2017 16:30:38 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:24 +0100 Message-Id: <20171130163029.19743-4-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 30 Nov 2017 16:30:40 +0000 (UTC) Subject: [edk2] [PATCH v2 3/8] OvmfPkg: conditionally disable reserved memory varstore emulation at build 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: , Cc: Anthony Perard , Jordan Justen , 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" (All of the below is only relevant for SMM_REQUIRE=3DFALSE.) 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), - 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 Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Julien Grall Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel --- 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] =20 [PcdsDynamicDefault] # only set when - # ($(SMM_REQUIRE) =3D=3D FALSE) + # (($(SMM_REQUIRE) =3D=3D FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D= TRUE)) gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 @@ -871,10 +871,12 @@ [Components] # Variable driver stack (non-SMM) # OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf +!if $(MEM_VARSTORE_EMU_ENABLE) =3D=3D TRUE OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.i= nf } +!endif MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { 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] =20 [PcdsDynamicDefault] # only set when - # ($(SMM_REQUIRE) =3D=3D FALSE) + # (($(SMM_REQUIRE) =3D=3D FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D= TRUE)) gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 @@ -881,10 +881,12 @@ [Components.X64] # Variable driver stack (non-SMM) # OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf +!if $(MEM_VARSTORE_EMU_ENABLE) =3D=3D TRUE OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.i= nf } +!endif MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { 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] =20 [PcdsDynamicDefault] # only set when - # ($(SMM_REQUIRE) =3D=3D FALSE) + # (($(SMM_REQUIRE) =3D=3D FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D= TRUE)) gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0 =20 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0 @@ -879,10 +879,12 @@ [Components] # Variable driver stack (non-SMM) # OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf +!if $(MEM_VARSTORE_EMU_ENABLE) =3D=3D TRUE OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.i= nf } +!endif MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf { 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) =3D=3D FALSE +!if ($(SMM_REQUIRE) =3D=3D FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D TR= UE) 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) =3D=3D 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) =3D=3D FALSE +!if ($(SMM_REQUIRE) =3D=3D FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D TR= UE) 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) =3D=3D 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) =3D=3D FALSE +!if ($(SMM_REQUIRE) =3D=3D FALSE) && ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D TR= UE) 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) =3D=3D 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/Plat= formPei.inf index de7434d93dc0..4b8626cb2a27 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -108,6 +108,7 @@ [FixedPcd] =20 [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire + gUefiOvmfPkgTokenSpaceGuid.PcdMemVarstoreEmuEnable =20 [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 ( } =20 if (mBootMode !=3D BOOT_ON_S3_RESUME) { - if (!FeaturePcdGet (PcdSmmSmramRequire)) { + if (!FeaturePcdGet (PcdSmmSmramRequire) && + FeaturePcdGet (PcdMemVarstoreEmuEnable)) { ReserveEmuVariableNvStore (); } PeiFvInitialization (); --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059448330130.7959904005951; Thu, 30 Nov 2017 08:30:48 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3BF092211B42D; Thu, 30 Nov 2017 08:26:18 -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 86438220C1C3A for ; Thu, 30 Nov 2017 08:26:17 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5EC4743; Thu, 30 Nov 2017 16:30:42 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2D155D9C7; Thu, 30 Nov 2017 16:30:40 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:25 +0100 Message-Id: <20171130163029.19743-5-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 30 Nov 2017 16:30:42 +0000 (UTC) Subject: [edk2] [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: , Cc: Anthony Perard , Jordan Justen , 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" An OVMF binary built with -D SMM_REQUIRE or with -D MEM_VARSTORE_EMU_ENABLE=3DFALSE 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. 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/FlashNvStorageAddress= Lib.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 PE= IMs +# consume them. +# +# Copyright (C) 2017, Red Hat, Inc. +# +# This program and the accompanying materials are licensed and made availa= ble +# 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, WI= THOUT +# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION =3D 1.25 + BASE_NAME =3D FlashNvStorageAddressLib + FILE_GUID =3D 5FF5A9F9-D01E-49EC-9A17-1682FC85122F + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FlashNvStorageAddressLib|PEIM + CONSTRUCTOR =3D 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/FlashNvStorageAddress= Lib.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 PE= IMs + consume them. + + Copyright (C) 2017, Red Hat, Inc. + + This program and the accompanying materials are licensed and made availa= ble + 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, WI= THOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +RETURN_STATUS +EFIAPI +SetFlashNvStorageAddresses ( + VOID + ) +{ + RETURN_STATUS PcdStatus; + + PcdStatus =3D PcdSet64S ( + PcdFlashNvStorageVariableBase64, + PcdGet32 (PcdOvmfFlashNvStorageVariableBase) + ); + if (RETURN_ERROR (PcdStatus)) { + return PcdStatus; + } + + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwWorkingBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) + ); + if (RETURN_ERROR (PcdStatus)) { + return PcdStatus; + } + + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwSpareBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) + ); + return PcdStatus; +} --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059451754625.6053651641532; Thu, 30 Nov 2017 08:30:51 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7339C2211B436; Thu, 30 Nov 2017 08:26:21 -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 6CB87220C1C5B for ; Thu, 30 Nov 2017 08:26:19 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 837747EA80; Thu, 30 Nov 2017 16:30:44 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 109595D9C7; Thu, 30 Nov 2017 16:30:42 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:26 +0100 Message-Id: <20171130163029.19743-6-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 30 Nov 2017 16:30:44 +0000 (UTC) Subject: [edk2] [PATCH v2 5/8] OvmfPkg: include FaultTolerantWritePei and VariablePei 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: , Cc: Anthony Perard , Jordan Justen , 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" ... but only for the -D SMM_REQUIRE and -D MEM_VARSTORE_EMU_ENABLE=3DFALSE builds, where - FaultTolerantWritePei can immediately consume PcdFlashNvStorageFtwWorkingBase and PcdFlashNvStorageFtwSpareBase, - and VariablePei can immediately consume PcdFlashNvStorageVariableBase64, with the help of FlashNvStorageAddressLib, plus variables can actually be read from some variable store (namely, the pflash chip). FaultTolerantWritePei produces a GUID data HOB with FAULT_TOLERANT_WRITE_LAST_WRITE_DATA as contents. It also installs a Null PPI that carries, as GUID, the same gEdkiiFaultTolerantWriteGuid as the GUID data HOB. VariablePei depends on the Null PPI mentioned above with a DEPEX, consumes the HOB (which is safe due to the DEPEX), and produces EFI_PEI_READ_ONLY_VARIABLE2_PPI. Because of the above serialization via the Null PPI, it suffices to link FlashNvStorageAddressLib into FaultTolerantWritePei only. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Julien Grall Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D386 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/OvmfPkgIa32.dsc | 7 +++++++ OvmfPkg/OvmfPkgIa32X64.dsc | 7 +++++++ OvmfPkg/OvmfPkgX64.dsc | 7 +++++++ OvmfPkg/OvmfPkgIa32.fdf | 4 ++++ OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++++ OvmfPkg/OvmfPkgX64.fdf | 4 ++++ 6 files changed, 33 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index dd6be0de0445..e5268f64f381 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -592,6 +592,13 @@ [Components] OvmfPkg/SmmAccess/SmmAccessPei.inf !endif UefiCpuPkg/CpuMpPei/CpuMpPei.inf +!if ($(SMM_REQUIRE) =3D=3D TRUE) || ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D FAL= SE) + MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf { + + NULL|OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressL= ib.inf + } + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf +!endif =20 # # DXE Phase modules diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 84c578ac22a4..2ba567f45306 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -600,6 +600,13 @@ [Components.IA32] OvmfPkg/SmmAccess/SmmAccessPei.inf !endif UefiCpuPkg/CpuMpPei/CpuMpPei.inf +!if ($(SMM_REQUIRE) =3D=3D TRUE) || ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D FAL= SE) + MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf { + + NULL|OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressL= ib.inf + } + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf +!endif =20 [Components.X64] # diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index b5d385101411..28db76c630d7 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -599,6 +599,13 @@ [Components] OvmfPkg/SmmAccess/SmmAccessPei.inf !endif UefiCpuPkg/CpuMpPei/CpuMpPei.inf +!if ($(SMM_REQUIRE) =3D=3D TRUE) || ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D FAL= SE) + MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf { + + NULL|OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressL= ib.inf + } + MdeModulePkg/Universal/Variable/Pei/VariablePei.inf +!endif =20 # # DXE Phase modules diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf index 50a2db897bbb..d697d9151f8e 100644 --- a/OvmfPkg/OvmfPkgIa32.fdf +++ b/OvmfPkg/OvmfPkgIa32.fdf @@ -164,6 +164,10 @@ [FV.PEIFV] INF OvmfPkg/SmmAccess/SmmAccessPei.inf !endif INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf +!if ($(SMM_REQUIRE) =3D=3D TRUE) || ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D FAL= SE) +INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf +INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf +!endif =20 ##########################################################################= ###### =20 diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index efa01734b576..d70b43198ab8 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -164,6 +164,10 @@ [FV.PEIFV] INF OvmfPkg/SmmAccess/SmmAccessPei.inf !endif INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf +!if ($(SMM_REQUIRE) =3D=3D TRUE) || ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D FAL= SE) +INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf +INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf +!endif =20 ##########################################################################= ###### =20 diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index d7a5ea97bda8..bb46a409d9d8 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -164,6 +164,10 @@ [FV.PEIFV] INF OvmfPkg/SmmAccess/SmmAccessPei.inf !endif INF UefiCpuPkg/CpuMpPei/CpuMpPei.inf +!if ($(SMM_REQUIRE) =3D=3D TRUE) || ($(MEM_VARSTORE_EMU_ENABLE) =3D=3D FAL= SE) +INF MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf +INF MdeModulePkg/Universal/Variable/Pei/VariablePei.inf +!endif =20 ##########################################################################= ###### =20 --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059454530705.7092461118607; Thu, 30 Nov 2017 08:30:54 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AE5BC2211B43C; Thu, 30 Nov 2017 08:26:24 -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 3FB0C220C1C5B for ; Thu, 30 Nov 2017 08:26:21 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E1E86A7E8; Thu, 30 Nov 2017 16:30:46 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0F7A5D9C7; Thu, 30 Nov 2017 16:30:44 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:27 +0100 Message-Id: <20171130163029.19743-7-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 30 Nov 2017 16:30:46 +0000 (UTC) Subject: [edk2] [PATCH v2 6/8] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: don't set flash PCDs if SMM or no-emu 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: , Cc: Anthony Perard , Jordan Justen , 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" ... only check them. When OVMF is built with -D SMM_REQUIRE or with -D MEM_VARSTORE_EMU_ENABLE=3DFALSE then the PCDs are set during the PEI phase, as part of FaultTolerantWritePei's startup (in FlashNvStorageAddressLib's constructor). 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/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c | 58 +++++++++++++= +------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c b/Ovmf= Pkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index 558b395dff4a..5d5a7580454a 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c @@ -1093,24 +1093,46 @@ FvbInitialize ( =20 MarkMemoryRangeForRuntimeAccess (BaseAddress, Length); =20 - // - // Set several PCD values to point to flash - // - PcdStatus =3D PcdSet64S ( - PcdFlashNvStorageVariableBase64, - (UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus =3D PcdSet32S ( - PcdFlashNvStorageFtwWorkingBase, - PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus =3D PcdSet32S ( - PcdFlashNvStorageFtwSpareBase, - PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); + if (!FeaturePcdGet (PcdSmmSmramRequire) && + FeaturePcdGet (PcdMemVarstoreEmuEnable)) { + // + // This build is suitable for both flash and in-memory emulated variab= les, + // and we happen to have found flash. Set several PCD values to point = to + // flash. + // + PcdStatus =3D PcdSet64S ( + PcdFlashNvStorageVariableBase64, + PcdGet32 (PcdOvmfFlashNvStorageVariableBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwWorkingBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwSpareBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + } else { + // + // This build is suitable for flash variables only. Double-check sever= al + // PCDs that point to the flash. + // + ASSERT ( + (PcdGet64 (PcdFlashNvStorageVariableBase64) =3D=3D + PcdGet32 (PcdOvmfFlashNvStorageVariableBase)) + ); + ASSERT ( + (PcdGet32 (PcdFlashNvStorageFtwWorkingBase) =3D=3D + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase)) + ); + ASSERT ( + (PcdGet32 (PcdFlashNvStorageFtwSpareBase) =3D=3D + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase)) + ); + } =20 FwhInstance =3D (EFI_FW_VOL_INSTANCE *) ( --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059457755928.2725271356067; Thu, 30 Nov 2017 08:30:57 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EBA052211B43F; Thu, 30 Nov 2017 08:26:24 -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 1B428220C1C3A for ; Thu, 30 Nov 2017 08:26:23 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A7E24900C; Thu, 30 Nov 2017 16:30:48 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC3BF5D9C7; Thu, 30 Nov 2017 16:30:46 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:28 +0100 Message-Id: <20171130163029.19743-8-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 30 Nov 2017 16:30:48 +0000 (UTC) Subject: [edk2] [PATCH v2 7/8] OvmfPkg/PlatformPei: remedy UEFI memory map fragmentation 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: , Cc: Anthony Perard , Jordan Justen , 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" The Memory Type Information HOB is used for sizing the allocation bins for the various memory types. If the PEI phase does not produce the HOB, and it includes the VariablePei driver, then the DXE IPL PEIM will itself build the HOB, from the "MemoryTypeInformation" non-volatile variable. (The HOB is consumed in the DxeLoadCore() function, and it is ignored if the boot mode is BOOT_ON_S3_RESUME. Accordingly, we already don't build the HOB in InitializePlatform() during S3 resume; MemMapInitialization() isn't called.) In the BDS phase, BmSetMemoryTypeInformationVariable() reads the variable (if it exists) under all boot modes different from BOOT_WITH_DEFAULT_SETTINGS, and (re-)sets the variable if it doesn't exist, or the counts of the pages allocated during boot have changed, relative to what the variable predicted. In effect this creates a feedback loop between BDS and the next boot's PEI, making sure the memory allocation bins are sized large enough in advance. Ultimately, for BOOT_WITH_FULL_CONFIGURATION, as a special case of the above, this measures the maximum boot memory requirement per UEFI memory type, and over time decreases fragmentation in the UEFI memory map. We continue creating our (constant) Memory Type Information HOB in OvmfPkg/PlatformPei -- which prevents the above feedback loop -- except in one case: when OVMF is built with SMM_REQUIRE=3DTRUE or MEM_VARSTORE_EMU_ENABLE=3DFALSE (that is, when a flash-based varstore is guaranteed), and the "MemoryTypeInformation" variable exists (that is, when the virtual machine has been booted at least once). This lets the OS installer see a somewhat fragmented memory map at first boot, but further boots should witness defragmented maps. In practice the difference seems to be 20-24 entries in the UEFI memory map. In the longer term this should also serve as basis for S4 enablement. For now, we keep the PcdResetOnMemoryTypeInformationChange|FALSE setting in the OVMF DSC files, dating back to commit 7709cf48e432 ("DuetPkg, OvmfPkg, UnixPkg: Remove unnecessary reset during boot", 2010-12-06). 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/PlatformPei/PlatformPei.inf | 2 + OvmfPkg/PlatformPei/Platform.h | 5 + OvmfPkg/PlatformPei/MemTypeInfo.c | 151 ++++++++++++++++++++ OvmfPkg/PlatformPei/Platform.c | 23 +-- 4 files changed, 159 insertions(+), 22 deletions(-) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 4b8626cb2a27..062cc083c698 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -34,6 +34,7 @@ [Sources] FeatureControl.c Fv.c MemDetect.c + MemTypeInfo.c Platform.c Xen.c =20 @@ -113,6 +114,7 @@ [FeaturePcd] [Ppis] gEfiPeiMasterBootModePpiGuid gEfiPeiMpServicesPpiGuid + gEfiPeiReadOnlyVariable2PpiGuid =20 [Depex] TRUE diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index f942e61bb4f9..5847b46a308d 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -78,6 +78,11 @@ PeiFvInitialization ( VOID ); =20 +VOID +MemTypeInfoInitialization ( + VOID + ); + VOID InstallFeatureControlCallback ( VOID diff --git a/OvmfPkg/PlatformPei/MemTypeInfo.c b/OvmfPkg/PlatformPei/MemTyp= eInfo.c new file mode 100644 index 000000000000..46ed9aaf8f31 --- /dev/null +++ b/OvmfPkg/PlatformPei/MemTypeInfo.c @@ -0,0 +1,151 @@ +/**@file + Produce a default memory type information HOB unless we can determine, f= rom + the existence of the "MemoryTypeInformation" variable, that the DXE IPL = PEIM + will produce the HOB. + + Copyright (C) 2017, Red Hat, Inc. + + This program and the accompanying materials are licensed and made availa= ble + 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, WI= THOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include "Platform.h" + +STATIC EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] =3D { + { EfiACPIMemoryNVS, 0x004 }, + { EfiACPIReclaimMemory, 0x008 }, + { EfiReservedMemoryType, 0x004 }, + { EfiRuntimeServicesData, 0x024 }, + { EfiRuntimeServicesCode, 0x030 }, + { EfiBootServicesCode, 0x180 }, + { EfiBootServicesData, 0xF00 }, + { EfiMaxMemoryType, 0x000 } +}; + +STATIC +VOID +BuildMemTypeInfoHob ( + VOID + ) +{ + BuildGuidDataHob ( + &gEfiMemoryTypeInformationGuid, + mDefaultMemoryTypeInformation, + sizeof mDefaultMemoryTypeInformation + ); + DEBUG (( + DEBUG_INFO, + "%a: default memory type information HOB built\n", + __FUNCTION__ + )); +} + +/** + Notification function called when EFI_PEI_READ_ONLY_VARIABLE2_PPI becomes + available. + + @param[in] PeiServices Indirect reference to the PEI Services Table. + @param[in] NotifyDescriptor Address of the notification descriptor data + structure. + @param[in] Ppi Address of the PPI that was installed. + + @return Status of the notification. The status code returned from this + function is ignored. +**/ +STATIC +EFI_STATUS +EFIAPI +OnReadOnlyVariable2Available ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, + IN VOID *Ppi + ) +{ + EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2; + UINTN DataSize; + EFI_STATUS Status; + + DEBUG ((DEBUG_VERBOSE, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__)); + + // + // Check if the "MemoryTypeInformation" variable exists, in the + // gEfiMemoryTypeInformationGuid namespace. + // + ReadOnlyVariable2 =3D Ppi; + DataSize =3D 0; + Status =3D ReadOnlyVariable2->GetVariable ( + ReadOnlyVariable2, + EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME, + &gEfiMemoryTypeInformationGuid, + NULL, + &DataSize, + NULL + ); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + // + // The variable exists; the DXE IPL PEIM will build the HOB from it. + // + return EFI_SUCCESS; + } + // + // Install the default memory type information HOB. + // + BuildMemTypeInfoHob (); + return EFI_SUCCESS; +} + +// +// Notification object for registering the callback, for when +// EFI_PEI_READ_ONLY_VARIABLE2_PPI becomes available. +// +STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mReadOnlyVariable2Notify =3D { + (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | + EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), // Flags + &gEfiPeiReadOnlyVariable2PpiGuid, // Guid + OnReadOnlyVariable2Available // Notify +}; + +VOID +MemTypeInfoInitialization ( + VOID + ) +{ + EFI_STATUS Status; + + if (!FeaturePcdGet (PcdSmmSmramRequire) && + FeaturePcdGet (PcdMemVarstoreEmuEnable)) { + // + // EFI_PEI_READ_ONLY_VARIABLE2_PPI will never be available; install + // the default memory type information HOB right away. + // + BuildMemTypeInfoHob (); + return; + } + + Status =3D PeiServicesNotifyPpi (&mReadOnlyVariable2Notify); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: failed to set up R/O Variable 2 callback: %r\n", + __FUNCTION__, + Status + )); + // + // Install the default HOB as a last resort. + // + BuildMemTypeInfoHob (); + } +} diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 34e7e903fc70..1a45531359a6 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -42,18 +41,6 @@ #include "Platform.h" #include "Cmos.h" =20 -EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] =3D { - { EfiACPIMemoryNVS, 0x004 }, - { EfiACPIReclaimMemory, 0x008 }, - { EfiReservedMemoryType, 0x004 }, - { EfiRuntimeServicesData, 0x024 }, - { EfiRuntimeServicesCode, 0x030 }, - { EfiBootServicesCode, 0x180 }, - { EfiBootServicesData, 0xF00 }, - { EfiMaxMemoryType, 0x000 } -}; - - EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] =3D { { EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, @@ -165,15 +152,6 @@ MemMapInitialization ( PciIoBase =3D 0xC000; PciIoSize =3D 0x4000; =20 - // - // Create Memory Type Information HOB - // - BuildGuidDataHob ( - &gEfiMemoryTypeInformationGuid, - mDefaultMemoryTypeInformation, - sizeof(mDefaultMemoryTypeInformation) - ); - // // Video memory + Legacy BIOS region // @@ -669,6 +647,7 @@ InitializePlatform ( ReserveEmuVariableNvStore (); } PeiFvInitialization (); + MemTypeInfoInitialization (); MemMapInitialization (); NoexecDxeInitialization (); } --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 18:42:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1512059461222220.16367361643597; Thu, 30 Nov 2017 08:31:01 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 30B6B221786A4; Thu, 30 Nov 2017 08:26:28 -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 83F14221786A3 for ; Thu, 30 Nov 2017 08:26:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A729C04DBF3; Thu, 30 Nov 2017 16:30:50 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-19.rdu2.redhat.com [10.10.120.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 986035D9C7; Thu, 30 Nov 2017 16:30:48 +0000 (UTC) X-Original-To: edk2-devel@lists.01.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; 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 From: Laszlo Ersek To: edk2-devel-01 Date: Thu, 30 Nov 2017 17:30:29 +0100 Message-Id: <20171130163029.19743-9-lersek@redhat.com> In-Reply-To: <20171130163029.19743-1-lersek@redhat.com> References: <20171130163029.19743-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 30 Nov 2017 16:30:50 +0000 (UTC) Subject: [edk2] [PATCH v2 8/8] OvmfPkg/README: document MEM_VARSTORE_EMU_ENABLE and memmap defrag 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: , Cc: Anthony Perard , Jordan Justen , 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" 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/README | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OvmfPkg/README b/OvmfPkg/README index 00fb71848200..cdd8dbea7f18 100644 --- a/OvmfPkg/README +++ b/OvmfPkg/README @@ -68,13 +68,21 @@ https://github.com/tianocore/tianocore.github.io/wiki/H= ow%20to%20build%20OVMF * Run qemu with: -pflash path/to/OVMF.fd * Note that this option is required for running SecureBoot-enabled bui= lds (-D SECURE_BOOT_ENABLE). + * When a commitment to this option (i.e., -pflash) can be made, it is + recommended to build OVMF with -D MEM_VARSTORE_EMU_ENABLE=3DFALSE. S= aid + build setting enables UEFI memory map defragmentation across boots o= f the + virtual machine. - Option 2: Use QEMU -bios parameter * Note that UEFI variables will be partially emulated, and non-volatile variables may lose their contents after a reboot + * The build option -D MEM_VARSTORE_EMU_ENABLE=3DFALSE is incompatible = with + the QEMU -bios option. * Run qemu with: -bios path/to/OVMF.fd - Option 3: Use QEMU -L parameter * Note that UEFI variables will be partially emulated, and non-volatile variables may lose their contents after a reboot + * The build option -D MEM_VARSTORE_EMU_ENABLE=3DFALSE is incompatible = with + the QEMU -L option. * Either copy, rename or symlink OVMF.fd =3D> bios.bin * Use the QEMU -L parameter to specify the directory where the bios.bin file is located. @@ -139,6 +147,8 @@ during boot (even in RELEASE builds). Both the naming o= f the flag (SMM_REQUIRE, instead of SMM_ENABLE), and this behavior are consistent with the goal described above: this is supposed to be a security feature, and fallbacks = are not allowed. Similarly, a pflash-backed variable store is a requirement. +(Accordingly, SMM_REQUIRE automatically enables all benefits of +MEM_VARSTORE_EMU_ENABLE=3DFALSE). =20 QEMU should be started with the options listed below (in addition to any o= ther guest-specific flags). The command line should be gradually composed from = the --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel