From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (EUR03-DB5-obe.outbound.protection.outlook.com [40.107.4.70]) by mx.groups.io with SMTP id smtpd.web11.535.1608315240972549696 for ; Fri, 18 Dec 2020 10:14:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=HJLcjb8A; spf=pass (domain: arm.com, ip: 40.107.4.70, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aogXNaH7TfWw9CNtwbKJCTryYNwAeDKLQTg1JYgCono=; b=HJLcjb8Ag0T8zGfm9uT0ZvvvBhtvlO1EyfJ0Zsk610wB9cydPFo/otAjJ8AQuSKc19QM0BWmH92WHeirIBxh1lnHk4Bt0sPEWdXhVCBHZq2VWpm0dPBegWQmg4b/jDCmKUezmFWOkMJ5k8Czs8jrLOdTvmHEOWFG17QhxkJLZtU= Received: from DB8PR06CA0039.eurprd06.prod.outlook.com (2603:10a6:10:120::13) by AS8PR08MB5880.eurprd08.prod.outlook.com (2603:10a6:20b:29f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.25; Fri, 18 Dec 2020 18:13:58 +0000 Received: from DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::2) by DB8PR06CA0039.outlook.office365.com (2603:10a6:10:120::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 18 Dec 2020 18:13:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT039.mail.protection.outlook.com (10.152.21.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22 via Frontend Transport; Fri, 18 Dec 2020 18:13:58 +0000 Received: ("Tessian outbound eeda57fffe7b:v71"); Fri, 18 Dec 2020 18:13:58 +0000 X-CR-MTA-TID: 64aa7808 Received: from a9cab81c27db.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D6EDCB56-0C92-4726-B157-3EF96AA327E7.1; Fri, 18 Dec 2020 18:13:53 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a9cab81c27db.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 18 Dec 2020 18:13:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YL1dq+DX016b8ZGwOy38/wPwAQKUImcIHMsbOaFjP1B5LpoN8PftE7AQ1HPSZ77qnicGY4kUaz2PL9sZYeUemgAtXXPH8rFOYTZJ6RUkSWSh3eAcC9LLvIfQpBIy3QuLRVxTe1QREd2QqUIEk+6xmYEfFCTjCjIJhPR8bbpDsKBN1Y9U/NdT9Llu3DTOq6sg01ZzySA7hYThePuol+dDL2pbXHFhjLaUUn7AGiUg6c46IYkEayVO0vojZUwY3zLeW456sbi94dumYWljP7kKsZXg7vJzkeTckhaIGt++R/EuEre19jXopKqQoDAprMo9L/fl4blHXhAtMZyf8elN4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aogXNaH7TfWw9CNtwbKJCTryYNwAeDKLQTg1JYgCono=; b=ie5uHznUAnW0Nu06owEhyJ/rln7UikU7+XU7N84Cx6Bo8MGgGv964loII1l6+AzH31z3UpmrJUbjguHUy2Jy7ow1mP0pBJB/jSpE1EgFVUFn+rqe3UZZktWMK7fgkOkcn7xvfXPkADuFOxvkANFiYGUbHxvATRlKwwRADUVfEn2pGeiOin3nw3U2QreLxZGr2CvrDiaBAq5n92Cz9Os0aq/FIN2ferkVxTf7Ze4RLZlw2kCiM6fP3Z2yY5qvxFEcrjqALs/J3QS567sv8p9jr53cHR+d8OjhD7KRljeWS9nTrJXNw/ZOOn1Mq+Dy4uooh5768tW0AvzN6KjXLYV3ZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aogXNaH7TfWw9CNtwbKJCTryYNwAeDKLQTg1JYgCono=; b=HJLcjb8Ag0T8zGfm9uT0ZvvvBhtvlO1EyfJ0Zsk610wB9cydPFo/otAjJ8AQuSKc19QM0BWmH92WHeirIBxh1lnHk4Bt0sPEWdXhVCBHZq2VWpm0dPBegWQmg4b/jDCmKUezmFWOkMJ5k8Czs8jrLOdTvmHEOWFG17QhxkJLZtU= Received: from AM0PR08MB3091.eurprd08.prod.outlook.com (2603:10a6:208:60::10) by AM0PR08MB5298.eurprd08.prod.outlook.com (2603:10a6:208:188::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Fri, 18 Dec 2020 18:13:51 +0000 Received: from AM0PR08MB3091.eurprd08.prod.outlook.com ([fe80::2c1c:6f6a:bd35:cd65]) by AM0PR08MB3091.eurprd08.prod.outlook.com ([fe80::2c1c:6f6a:bd35:cd65%3]) with mapi id 15.20.3654.024; Fri, 18 Dec 2020 18:13:51 +0000 From: "Sami Mujawar" To: Vijayenthiran Subramaniam , "devel@edk2.groups.io" , "leif@nuviainc.com" , Ard Biesheuvel , Thomas Abraham Subject: Re: [PATCH v2] ArmPlatformPkg: Enable support for flash in 64-bit address space Thread-Topic: [PATCH v2] ArmPlatformPkg: Enable support for flash in 64-bit address space Thread-Index: AQHWzvvwDTK1W3XsEU6VBUw/xF2jg6n9NI9A Date: Fri, 18 Dec 2020 18:13:50 +0000 Message-ID: References: <1607608381-22625-1-git-send-email-vijayenthiran.subramaniam@arm.com> In-Reply-To: <1607608381-22625-1-git-send-email-vijayenthiran.subramaniam@arm.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 46ABD5AB3E98044FACB1BCF1A3A1C6E0.0 x-checkrecipientchecked: true Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [217.140.99.251] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 47337ff1-cb1f-490c-17d4-08d8a380b0ac x-ms-traffictypediagnostic: AM0PR08MB5298:|AS8PR08MB5880: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1zr0kFHl3/SmgfYX5WQH1ge/Uwqduopo/BA3+VuUFzXdBB8eOQqNmehAxL2WvUWVdWO3N+vSNJjG0jOm9CdlqU2nSjKmteNrdnnGxIgawwu0wMD7VRPEcLU/vy1Ndj4Tt2fb/UrvGMVNaZ8y4UUbkg7DwI1lJMN/LMVHhlBDh2JwAhV0afMjjrzTuJIClKUNlcVplqBYo5HKM5fNYATAnH03sA036PoBpA4beIgz6WGWdhV28GrnJjLE/Si5GWuhUZut2KoB9Es7B1OAV2V45BrXt7vBVWQitlL95+Xm0XKLO+9tyJPswtbme/RnzJEhmGkLF9ShZt5wQXDgnbVf1Sq2tPRP617xpCjTSwFGu0hK7LatBE7zffcTv3QxOTeTiE/x75CjG9oeJG5sKnmFIQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3091.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(136003)(396003)(366004)(39860400002)(346002)(76116006)(71200400001)(53546011)(9686003)(52536014)(6506007)(55016002)(66446008)(5660300002)(26005)(316002)(6636002)(33656002)(83380400001)(8676002)(66556008)(186003)(7696005)(478600001)(8936002)(64756008)(66946007)(110136005)(66476007)(86362001)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?4pwmQhCzP8yb/NPW5rb5uRioRIqZUYDy4PJoKxOPVWM+zpKuir5dPDQmPzvP?= =?us-ascii?Q?c1dAbdZo018eE26DB3cMhOyYTubGXpcCYq2cD0Nehn0YQErycstlDxyAPAM4?= =?us-ascii?Q?5YsBVNbcncBnkExCYYyJWIBwRo+pa3WDQVFNokusjOFVH+rzFoBWNRZrXkUE?= =?us-ascii?Q?46a+EYsNgh/eoJKaEOPEZ1hVEVo7cRaiono3xwV2Q6xhwbEcl2PQT7DF5ZE3?= =?us-ascii?Q?bm7AjmihtsUVgmzgMp7KcgC3pNG78JqUTTDZSj4Pc1TZPO2fc/9s8bJFMlo8?= =?us-ascii?Q?q7/4NibTzZB2y/F543aFnak/LOEtbWaqjy4cqCm/2AI4+C+4aDJlEvFDfOXA?= =?us-ascii?Q?xzPJcFEgsnR32LbcPsuYhPnFFa+w5guVDoDNPus+WeDwkOpyrO2n9Y63ehuc?= =?us-ascii?Q?h9kZTOPsMI0QMHxx9+xaNDxoSlnUF1xAFkruLvnfU9tuRWQCrp7CpC/lKKhb?= =?us-ascii?Q?eHyfGMWcl/1GgxuRYhrm2gLxZ4/qS328CRMmG9MDIvwCOQs2btkFf4s3w+fq?= =?us-ascii?Q?h7ewP4uq4dHVYpRzUiDc4ZdMB7h9XA0kUCrN2TXWbSygU8/EsxxqUR3G18bA?= =?us-ascii?Q?7nk3mwKKLT9RZKk0cymKDNE5lajyPB18TtxzFDjp1Gbhmfgv58oOufI3Ldo5?= =?us-ascii?Q?jt4z5YscQaAfvqg5TEFfheFEFCpxfBrSU/ZyLxNUAndqMVvgydscDnT6samp?= =?us-ascii?Q?+A5pa+qO/yfsEojBmzCnhYjPif58Lv/NDPztFp1hkJZ9NrPCR7t09Sb/X8L6?= =?us-ascii?Q?nUFcOfioDZZmxah807UhqBfmLNiX4n0pji4DUur+ge8kfuTaibVnys62W/9Y?= =?us-ascii?Q?G0Q4yRa2u0gPsAJdHJrfiMTgta04a//2ccL6xQgrei8QcBFmHj8gdIHGMwLr?= =?us-ascii?Q?knNd0IDeLeWjqk5+UCRvLRIZQ42N25rqfKD/Ch5j20G7HqOSvQGZnviuaVm/?= =?us-ascii?Q?mxmlu96xdK9xgNW0DPL1KzE1iAhse7NwZFLId0yKKOw=3D?= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5298 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 6631a0c8-2a1f-4adf-dc86-08d8a380ac5c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vX6KcQpLaG2wz0u6nMdzDEUo3emBd/1u5Eaqafy45QdT1aF+F1N9bzohu+n+hFX26Uju3tAkdnSfROoeUgiHXFioBWZFgQzu4cHVJdTZuBe8XETz6039i+iWGuCtt4EBuXYRRPyPs0t2kfUEz4vGqyWQSZkQobw8Nv642s3lEeNEOe+LQEM2Ehxzkt5TrLjna0Jr6EXFhYHurN/BOuUFA36Q1vilJRt5XC8fjzDCoWVVkW8kGTwpCwSuM9p279grpjtfxHjAvC4EvDDZfx/OGs52xAt+RttpHcunxb2dBKsxoPsuiOV45iTTckOEGzs2CbsBtlCYLo4VTJ4lqOivimak0YSzeXgyvZcoSCC8BowIppzRBf8TOXhGo+zIz9gZ7EMxc86EBVjT/U6vhsC1Qw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(39860400002)(136003)(376002)(396003)(46966005)(8676002)(7696005)(70586007)(82740400003)(316002)(6506007)(9686003)(8936002)(5660300002)(110136005)(47076004)(6636002)(86362001)(52536014)(82310400003)(70206006)(478600001)(81166007)(356005)(2906002)(33656002)(83380400001)(336012)(26005)(53546011)(55016002)(186003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2020 18:13:58.8074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 47337ff1-cb1f-490c-17d4-08d8a380b0ac X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5880 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This patch looks good to me. Reviewed-by: Sami Mujawar Regards, Sami Mujawar -----Original Message----- From: Vijayenthiran Subramaniam Sent: 10 December 2020 01:53 PM To: devel@edk2.groups.io; leif@nuviainc.com; Ard Biesheuvel ; Thomas Abraham ; Sami Mujawar Subject: [PATCH v2] ArmPlatformPkg: Enable support for flash in 64-bit addr= ess space The existing NOR Flash dxe driver supports NOR flash devices connected in the 32-bit address space. Extend this driver to allow NOR flash devices connected to 64-bit address space to be usable as well. Also, convert the base address and size sanity check from ASSERT() to if condition so that even if the firmware is build in release mode, it can return error if the parameter(s) is/are invalid. Signed-off-by: Vijayenthiran Subramaniam --- Changes since v1: - Address Sami Mujawar from edk2.groups.io/g/devel/message/67980 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf | 5 +- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 15 ++++- ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c | 66 ++++++++++++++++-= --- 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf b/ArmPlatfo= rmPkg/Drivers/NorFlashDxe/NorFlashDxe.inf index a647c016878d..992ae32f4c3b 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf @@ -2,7 +2,7 @@ # # Component description file for NorFlashDxe module # -# Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+# Copyright (c) 2011 - 2020, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -54,10 +54,13 @@ [Protocols] gEfiDiskIoProtocolGuid [Pcd.common] + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatform= Pkg/Drivers/NorFlashDxe/NorFlashDxe.c index 20134094badc..de9f3d0d7edb 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c @@ -1300,9 +1300,18 @@ NorFlashInitialise ( for (Index =3D 0; Index < mNorFlashDeviceCount; Index++) { // Check if this NOR Flash device contain the variable storage region - ContainVariableStorage =3D - (NorFlashDevices[Index].RegionBaseAddress <=3D PcdGet32 (PcdFlashN= vStorageVariableBase)) && - (PcdGet32 (PcdFlashNvStorageVariableBase) + PcdGet32 (PcdFlashNvSt= orageVariableSize) <=3D NorFlashDevices[Index].RegionBaseAddress + NorFlash= Devices[Index].Size); + + if (PcdGet64 (PcdFlashNvStorageVariableBase64) !=3D 0) { + ContainVariableStorage =3D + (NorFlashDevices[Index].RegionBaseAddress <=3D PcdGet64 (PcdFlashNv= StorageVariableBase64)) && + (PcdGet64 (PcdFlashNvStorageVariableBase64) + PcdGet32 (PcdFlashNvS= torageVariableSize) <=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 + NorFlashDevices[Index].= Size); + } Status =3D NorFlashCreateInstance ( NorFlashDevices[Index].DeviceBaseAddress, diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatf= ormPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c index 9cdd85096a46..e2a1ad5ece50 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c @@ -1,6 +1,6 @@ /*++ @file NorFlashFvbDxe.c - Copyright (c) 2011 - 2020, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -53,23 +53,66 @@ InitializeFvAndVariableStoreHeaders ( UINTN HeadersLength; EFI_FIRMWARE_VOLUME_HEADER *FirmwareVolumeHeader; VARIABLE_STORE_HEADER *VariableStoreHeader; + UINT32 NvStorageFtwSpareSize; + UINT32 NvStorageFtwWorkingSize; + UINT32 NvStorageVariableSize; + UINT64 NvStorageFtwSpareBase; + UINT64 NvStorageFtwWorkingBase; + UINT64 NvStorageVariableBase; HeadersLength =3D sizeof(EFI_FIRMWARE_VOLUME_HEADER) + sizeof(EFI_FV_BLO= CK_MAP_ENTRY) + sizeof(VARIABLE_STORE_HEADER); Headers =3D AllocateZeroPool(HeadersLength); + NvStorageFtwWorkingSize =3D PcdGet32 (PcdFlashNvStorageFtwWorkingSize); + NvStorageFtwSpareSize =3D PcdGet32 (PcdFlashNvStorageFtwSpareSize); + NvStorageVariableSize =3D PcdGet32 (PcdFlashNvStorageVariableSize); + + NvStorageFtwSpareBase =3D (PcdGet64 (PcdFlashNvStorageFtwSpareBase64) != =3D 0) ? + PcdGet64 (PcdFlashNvStorageFtwSpareBase64) : PcdGet32 (PcdFlashNvStora= geFtwSpareBase); + NvStorageFtwWorkingBase =3D (PcdGet64 (PcdFlashNvStorageFtwWorkingBase64= ) !=3D 0) ? + PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) : PcdGet32 (PcdFlashNvSto= rageFtwWorkingBase); + NvStorageVariableBase =3D (PcdGet64 (PcdFlashNvStorageVariableBase64) != =3D 0) ? + PcdGet64 (PcdFlashNvStorageVariableBase64) : PcdGet32 (PcdFlashNvStora= geVariableBase); + // FirmwareVolumeHeader->FvLength is declared to have the Variable area = AND the FTW working area AND the FTW Spare contiguous. - ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) + PcdGet32(PcdFlashNvStor= ageVariableSize) =3D=3D PcdGet32(PcdFlashNvStorageFtwWorkingBase)); - ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) + PcdGet32(PcdFlashNvSt= orageFtwWorkingSize) =3D=3D PcdGet32(PcdFlashNvStorageFtwSpareBase)); + if ((NvStorageVariableBase + NvStorageVariableSize) !=3D NvStorageFtwWor= kingBase) { + DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwWorkingBase is not contiguous wi= th NvStorageVariableBase region\n", + __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + if ((NvStorageFtwWorkingBase + NvStorageFtwWorkingSize) !=3D NvStorageFt= wSpareBase) { + DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwSpareBase is not contiguous with= NvStorageFtwWorkingBase region\n", + __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } // Check if the size of the area is at least one block size - ASSERT((PcdGet32(PcdFlashNvStorageVariableSize) > 0) && (PcdGet32(PcdFla= shNvStorageVariableSize) / Instance->Media.BlockSize > 0)); - ASSERT((PcdGet32(PcdFlashNvStorageFtwWorkingSize) > 0) && (PcdGet32(PcdF= lashNvStorageFtwWorkingSize) / Instance->Media.BlockSize > 0)); - ASSERT((PcdGet32(PcdFlashNvStorageFtwSpareSize) > 0) && (PcdGet32(PcdFla= shNvStorageFtwSpareSize) / Instance->Media.BlockSize > 0)); + if ((NvStorageVariableSize <=3D 0) || (NvStorageVariableSize / Instance-= >Media.BlockSize <=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a: NvStorageVariableSize is 0x%x, should be atl= east one block size\n", __FUNCTION__, + NvStorageVariableSize)); + return EFI_INVALID_PARAMETER; + } + + if ((NvStorageFtwWorkingSize <=3D 0) || (NvStorageFtwWorkingSize / Insta= nce->Media.BlockSize <=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwWorkingSize is 0x%x, should be a= tleast one block size\n", __FUNCTION__, + NvStorageFtwWorkingSize)); + return EFI_INVALID_PARAMETER; + } + + if ((NvStorageFtwSpareSize <=3D 0) || (NvStorageFtwSpareSize / Instance-= >Media.BlockSize <=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a: NvStorageFtwSpareSize is 0x%x, should be atl= east one block size\n", __FUNCTION__, + NvStorageFtwSpareSize)); + return EFI_INVALID_PARAMETER; + } // Ensure the Variable area Base Addresses are aligned on a block size b= oundaries - ASSERT(PcdGet32(PcdFlashNvStorageVariableBase) % Instance->Media.BlockSi= ze =3D=3D 0); - ASSERT(PcdGet32(PcdFlashNvStorageFtwWorkingBase) % Instance->Media.Block= Size =3D=3D 0); - ASSERT(PcdGet32(PcdFlashNvStorageFtwSpareBase) % Instance->Media.BlockSi= ze =3D=3D 0); + if ((NvStorageVariableBase % Instance->Media.BlockSize !=3D 0) || + (NvStorageFtwWorkingBase % Instance->Media.BlockSize !=3D 0) || + (NvStorageFtwSpareBase % Instance->Media.BlockSize !=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a: NvStorage Base addresses must be aligned to = block size boundaries", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } // // EFI_FIRMWARE_VOLUME_HEADER @@ -736,10 +779,11 @@ NorFlashFvbInitialize ( EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); ASSERT_EFI_ERROR (Status); - mFlashNvStorageVariableBase =3D PcdGet32 (PcdFlashNvStorageVariableBase)= ; + mFlashNvStorageVariableBase =3D (FixedPcdGet64 (PcdFlashNvStorageVariabl= eBase64) !=3D 0) ? + FixedPcdGet64 (PcdFlashNvStorageVariableBase64) : FixedPcdGet32 (PcdFl= ashNvStorageVariableBase); // Set the index of the first LBA for the FVB - Instance->StartLba =3D (PcdGet32 (PcdFlashNvStorageVariableBase) - Insta= nce->RegionBaseAddress) / Instance->Media.BlockSize; + Instance->StartLba =3D (mFlashNvStorageVariableBase - Instance->RegionBa= seAddress) / Instance->Media.BlockSize; BootMode =3D GetBootModeHob (); if (BootMode =3D=3D BOOT_WITH_DEFAULT_SETTINGS) { -- 2.17.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.