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 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) From: Laszlo Ersek To: edk2-devel-01 Cc: Anthony Perard , Ard Biesheuvel , Jordan Justen , Julien Grall 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: [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: , X-List-Received-Date: Thu, 30 Nov 2017 16:26:21 -0000 ... only check them. When OVMF is built with -D SMM_REQUIRE or with -D MEM_VARSTORE_EMU_ENABLE=FALSE 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/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c index 558b395dff4a..5d5a7580454a 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c @@ -1093,24 +1093,46 @@ FvbInitialize ( MarkMemoryRangeForRuntimeAccess (BaseAddress, Length); - // - // Set several PCD values to point to flash - // - PcdStatus = PcdSet64S ( - PcdFlashNvStorageVariableBase64, - (UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet32S ( - PcdFlashNvStorageFtwWorkingBase, - PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus = PcdSet32S ( - PcdFlashNvStorageFtwSpareBase, - PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) - ); - ASSERT_RETURN_ERROR (PcdStatus); + if (!FeaturePcdGet (PcdSmmSmramRequire) && + FeaturePcdGet (PcdMemVarstoreEmuEnable)) { + // + // This build is suitable for both flash and in-memory emulated variables, + // and we happen to have found flash. Set several PCD values to point to + // flash. + // + PcdStatus = PcdSet64S ( + PcdFlashNvStorageVariableBase64, + PcdGet32 (PcdOvmfFlashNvStorageVariableBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus = PcdSet32S ( + PcdFlashNvStorageFtwWorkingBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus = PcdSet32S ( + PcdFlashNvStorageFtwSpareBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + } else { + // + // This build is suitable for flash variables only. Double-check several + // PCDs that point to the flash. + // + ASSERT ( + (PcdGet64 (PcdFlashNvStorageVariableBase64) == + PcdGet32 (PcdOvmfFlashNvStorageVariableBase)) + ); + ASSERT ( + (PcdGet32 (PcdFlashNvStorageFtwWorkingBase) == + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase)) + ); + ASSERT ( + (PcdGet32 (PcdFlashNvStorageFtwSpareBase) == + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase)) + ); + } FwhInstance = (EFI_FW_VOL_INSTANCE *) ( -- 2.14.1.3.gb7cf6e02401b