From nobody Thu Apr 18 06:54:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70116+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70116+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1610362654; cv=none; d=zohomail.com; s=zohoarc; b=G7uHSLkOPLZ+7xyVfTQr3tF7H09Y8khRqq1UXiP+Ha2LMgCp77Z1BAbmik9kf4psQj7SIuOxnmpoj/Iu6jBLbu35xOP99MztOpq10XMz+GGop70E3K/LsRlxT/XQYi7TNHvXHBRrYcRhOKOpCBqKNtYQH4L++xg5gxpa1f6YfpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610362654; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=ZEVES6unmCt70SqjMasNPNabnHexeyTjOmSeXSi/Q/4=; b=SanDlC8E3CZwBnvhKBplrvNoY/wgLLyc5GjDd3vX86hfqwJzT1WpQwjOLlGoMM3CgFLdhQWGulRjWkGLDcjRlr4EkfznwTo1Ii3NPXgDjOBUXQAbHaUF9ny3X0Jgt/J2dcW3qOYxvVwCBWjJ3cWyNPmsA8r/S2+ujYoNmLsdV3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70116+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 161036265441742.85035048597251; Mon, 11 Jan 2021 02:57:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id TEb3YY1788612xrnmWyBHbk7; Mon, 11 Jan 2021 02:57:34 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.32101.1610362653497454310 for ; Mon, 11 Jan 2021 02:57:33 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F22F931B; Mon, 11 Jan 2021 02:57:31 -0800 (PST) X-Received: from e123331-lin.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E17B83F719; Mon, 11 Jan 2021 02:57:30 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel , Vijayenthiran Subramaniam , Masahisa Kojima , Sami Mujawar Subject: [edk2-devel] [PATCH] ArmPlatformPkg/NorFlashDxe: use correct PCD accessors Date: Mon, 11 Jan 2021 11:57:19 +0100 Message-Id: <20210111105719.18700-1-ard.biesheuvel@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: YrF8j1UD9hcS2ettSe23JBNQx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610362654; bh=X6cwKhb90NTS8JWP8IfFS+HZFkEM66vjraqOlxRVTls=; h=Cc:Date:From:Reply-To:Subject:To; b=FxHMF08DiINfVm2Fi6yi9Chc6wg4T4YL5RGnP9c13/4IevYbzODMMNZRqWXXFSoirCV 2U7duhA3CWNBPwH6SDCL6nJjOiwMfOZJHRZv818KTT5yrwjG+B/v7FBnRlGtXhW3I+Dbf 1BOkVbnbMyt6RLWLxfa2cC0y3EohIWoXxOo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 8015f3f6d4005d83 ("ArmPlatformPkg: Enable support for flash in 64-bit address space") updated the NorFlash DXE and StMM drivers to take alternate PCDs into account when discovering the base of the NOR flash regions. This introduced a disparity between the declarations of the PCD references in the .INF files, which permits the use of dynamic PCDs, and the code itself, which now uses FixedPcdGet() accessors. On platforms that actually use dynamic PCDs, this results in a build error. So let's clean this up: - for the DXE version, use the generic PcdGet() accessors, so dynamic PCDs are permitted - for the standalone MM version, redeclare the PCDs as [FixedPcd] in the .INF description, and switch to the FixedPcdGet() accessors. Cc: Vijayenthiran Subramaniam Cc: Masahisa Kojima Cc: Sami Mujawar Signed-off-by: Ard Biesheuvel Acked-by: Laszlo Ersek Tested-by: Vijayenthiran Subramaniam --- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf | 3 ++- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 4 ++-- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf b/= ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf index b2f72fb4de20..56347a8bc7c1 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf @@ -49,7 +49,7 @@ [Guids] [Protocols] gEfiSmmFirmwareVolumeBlockProtocolGuid =20 -[Pcd.common] +[FixedPcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize @@ -60,6 +60,7 @@ [Pcd.common] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize =20 +[FeaturePcd] gArmPlatformTokenSpaceGuid.PcdNorFlashCheckBlockLocked =20 [Depex] diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatform= Pkg/Drivers/NorFlashDxe/NorFlashDxe.c index 28dc8e125c78..f412731200cf 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c @@ -422,8 +422,8 @@ NorFlashFvbInitialize ( EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); ASSERT_EFI_ERROR (Status); =20 - mFlashNvStorageVariableBase =3D (FixedPcdGet64 (PcdFlashNvStorageVariabl= eBase64) !=3D 0) ? - FixedPcdGet64 (PcdFlashNvStorageVariableBase64) : FixedPcdGet32 (PcdFl= ashNvStorageVariableBase); + mFlashNvStorageVariableBase =3D (PcdGet64 (PcdFlashNvStorageVariableBase= 64) !=3D 0) ? + PcdGet64 (PcdFlashNvStorageVariableBase64) : PcdGet32 (PcdFlashNvStora= geVariableBase); =20 // Set the index of the first LBA for the FVB Instance->StartLba =3D (mFlashNvStorageVariableBase - Instance->RegionBa= seAddress) / Instance->Media.BlockSize; diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c b/Ar= mPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c index 8a4fb395d286..4ebbc06e1de3 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c @@ -299,15 +299,15 @@ NorFlashInitialise ( for (Index =3D 0; Index < mNorFlashDeviceCount; Index++) { // Check if this NOR Flash device contain the variable storage region =20 - if (PcdGet64 (PcdFlashNvStorageVariableBase64) !=3D 0) { + if (FixedPcdGet64 (PcdFlashNvStorageVariableBase64) !=3D 0) { ContainVariableStorage =3D - (NorFlashDevices[Index].RegionBaseAddress <=3D PcdGet64 (PcdFlashNv= StorageVariableBase64)) && - (PcdGet64 (PcdFlashNvStorageVariableBase64) + PcdGet32 (PcdFlashNvS= torageVariableSize) <=3D + (NorFlashDevices[Index].RegionBaseAddress <=3D FixedPcdGet64 (PcdFl= ashNvStorageVariableBase64)) && + (FixedPcdGet64 (PcdFlashNvStorageVariableBase64) + FixedPcdGet32 (P= cdFlashNvStorageVariableSize) <=3D NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].= Size); } else { ContainVariableStorage =3D - (NorFlashDevices[Index].RegionBaseAddress <=3D PcdGet32 (PcdFlashNv= StorageVariableBase)) && - (PcdGet32 (PcdFlashNvStorageVariableBase) + PcdGet32 (PcdFlashNvSto= rageVariableSize) <=3D + (NorFlashDevices[Index].RegionBaseAddress <=3D FixedPcdGet32 (PcdFl= ashNvStorageVariableBase)) && + (FixedPcdGet32 (PcdFlashNvStorageVariableBase) + FixedPcdGet32 (Pcd= FlashNvStorageVariableSize) <=3D NorFlashDevices[Index].RegionBaseAddress + NorFlashDevices[Index].= Size); } =20 --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70116): https://edk2.groups.io/g/devel/message/70116 Mute This Topic: https://groups.io/mt/79593039/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-