From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on0627.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::627]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A5E681E9C for ; Fri, 20 Jan 2017 03:54:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BrJK7JfITPeJTcStA6NHZlozgO7G8vfoPvoTj8ilIYs=; b=glYDTxz375SJ9/QMh5lH4KqaTD2UB0Hbku+kdL/pK+jYkLNZqw3Wr4UvjNGPlyvpyNLMgvRhpoiReMe8tdLVdrEwY/ze/a/nSRNYkLXFnXhAG6zxQxitWRG6j5SzF3q9I9rY8tgm/JLvARa8A+YOdYQ7REsFws6wjTQ/94kiq4s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Achin.Gupta@arm.com; Received: from e104320-lin.cambridge.arm.com (217.140.96.140) by VI1PR08MB1197.eurprd08.prod.outlook.com (10.166.45.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Fri, 20 Jan 2017 11:54:43 +0000 From: To: CC: , , , Achin Gupta Date: Fri, 20 Jan 2017 11:54:59 +0000 Message-ID: X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (10.165.22.149) To VI1PR08MB1197.eurprd08.prod.outlook.com (10.166.45.150) X-MS-Office365-Filtering-Correlation-Id: e3bb0d69-bc96-476f-6774-08d4412b1ffe X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR08MB1197; X-Microso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B93FhR6i40HNHGvmIC8lFMOGpOdM2ZRpkDKekkHDLcv/j8wQe7DTI3A X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB1197; 31:6O3kz2bkX10CbcQ287foQFMJS8Tosowrol5yG5BScNkOfwBtD7B5O+KUL6f+M1/TBSPwLxZlPIK7FscJUJzhqvOfbCRvDT9pPlDCWROU3iXJr38QPXo4A17xft6zm4PKRnjp7rvgas8lx5ni98x4+YnOvu316u2CA1lZYdH+4np6SbNhTwzNfsSCtUO0hDYLgtDi/Jkvm+ugE7VxwseXfuyXNjw1Jn6be4ChQ6JBFBoeoankXmjipOOzwOtmMtGp+QGgM9cg7cClAQWXluinFA==; 20:NDo2D97XLt0T7Av+goCfrZ0v5P/WcztudfFlycbMilo+AqE0mRKGjmESBKmZnQiQ1iHcE7n0495e+WMvh1dlFCyvwfmiQVySM588PiwpW9DByVohQMi8XWJyXwEeLzsRsuy5VOxqIJRxKEQzqvsGocUYtEJg15VhOV6ikN3jmZo= NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123558021)(20161123560025)(6072148); SRVR:VI1PR08MB1197; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB1197; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB1197; 4:S+SHAsBbxUdYluMjF5qwYcla92dfJ2TakV6yhI5vmI9Q82FzCZj8UvxSmViJb/fp0TRRB/55rNfB2SzEWo2ZlWZlvyHiKNaPyRQbIh7I/nIdpR3PEsga0+6UM2DnZnGBIxoLKJt9wGWvNw22Kdl+c5Iss6JVH1FOYQxRdwCWhefu4yzWDQIwduBjCsKrvlB/Q5m685hQVGCa0kvMVwtC7rU5Vko84eo8zmfICVEbF/eJ4n2Upn6mQTJBO8fQts/3tjTwzoTgChhPZoVYKfAi48IkN5WrPE44623jXqHdzM3ysfRHmai67sGumzM177k5HI0cQlbUyRSA+4panmJjZq+wrfYVMcx/JMuILruQkNfm6WzR7hUZQITWCUPcApvUABTC4QvtoQaH5aDwek2ngVBgiw1ckmIBu7LtRyyMW4XFbVgekO28ut22BPa9wFZRa/QoXo+kygG5uHedibkDA7DA7aOp1rHxbAFACOmYtmq1zf+EHBExfCLS9QX4FTBooMP75vAFCo5H1YCqMqj6GTqxWDQfQEIDgynAYrqKxeQyM4yGHblwq7nrSxgS7FdR+PwPF1mhrGAyz5yEcoSTIesapSs3qO9P02T19IBRpLb8VbocYfb9nkjfoAdVJja9In4SbOnqIXgpk3QRU9MM8yWMcq1Zoz+fcjcTmtDmF2E= X-Forefront-PRVS: 01930B2BA8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39850400002)(39410400002)(39860400002)(39840400002)(39450400003)(199003)(189002)(2351001)(81156014)(2876002)(7736002)(101416001)(36756003)(86362001)(50986999)(305945005)(105586002)(118296001)(106356001)(4326007)(48376002)(50466002)(53936002)(5660300001)(110136003)(42186005)(33646002)(6916009)(92566002)(47776003)(6666003)(66066001)(3846002)(189998001)(2906002)(5003940100001)(54906002)(50226002)(86152003)(38730400001)(68736007)(97736004)(8676002)(25786008)(81166006)(6116002)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB1197; H:e104320-lin.cambridge.arm.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB1197; 23:WiHisBrRXNji/a5BrBjKLWdvWT2bm+6Dg/OkAJStK?= =?us-ascii?Q?kC/FeV19b34jkSsgzU8v938XD/EK+o5yVKkg0E1Rz+H8yvzTnyw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lh4FhGd8sWosQi5h+EMLjqkuLgC7O5TBeTZ6xx8HXsUzIzwP4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB1197; 7:PJlByYF/+CP7jJBE6McSCr1Q3rp2I8x/FCXCEiyK4RE/SaCuroBhJQAvG4NevRFNsHXPuMAaet17kW5qolFGipCbIWd5NW7cdegcqkPig7ax/EDHf/lnIEwlQgCb49a9RHhQKzns+4pOu/Yp2ROQwm3wghH8veI9SDyCi8sJ2EgjqzAPiTjy5KKsUVGTp9HcXGN5KFS9a0UlAnHrU9QnJQByYVwVNuIC9wghqExCQHOqVFdV7j43FEbMgLjmwAaRP5/YELJrKii4tOcXzCBr25KKdp6XWi9/IdLQISPITT4RuM+nmBmCq9tbBf56k02X5stCPpMXbzE4cLrpe3VIQLBD6ollCTOdU/5YgYA9MWP0m3vCil0J3iDmMx5Zmo/nJdMovyFyykRRJIz8WsIVM+psH8HX6Ruf5vYOj53WeeLsc1r2e+I/ZRqNwF5I9sn5sL+8wYKPeRUR0bG0EDDYww== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2017 11:54:43.9726 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB1197 Subject: [PATCH] ArmPlatformPkg/NorFlashDxe: Change Flash memory attributes before writes X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2017 11:54:47 -0000 Content-Type: text/plain From: Achin Gupta In NorFlashFvbInitialize() if a valid Firmware Volume header is not found at the start of NOR Flash, the Flash memory is written before it has been remapped with EFI_MEMORY_UC attributes to allow write commands. Since the flash memory was previously mapped with Normal and possibly cacheable memory attributes, the Flash commands might never reach the device. This patch fixes this issue by remapping the Flash memory region with correct memory attributes before writing to it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Achin Gupta --- .../Drivers/NorFlashDxe/NorFlashFvbDxe.c | 45 +++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c index 42be5c2..12a8612 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c @@ -719,6 +719,29 @@ NorFlashFvbInitialize ( UINTN RuntimeMmioRegionSize; DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n")); + ASSERT((Instance != NULL)); + + // + // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME + // + + // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory; + // even if we only use the small block region at the top of the NOR Flash. + // The reason is when the NOR Flash memory is set into program mode, the command + // is written as the base of the flash region (ie: Instance->DeviceBaseAddress) + RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size; + + Status = gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + Instance->DeviceBaseAddress, RuntimeMmioRegionSize, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + + Status = gDS->SetMemorySpaceAttributes ( + Instance->DeviceBaseAddress, RuntimeMmioRegionSize, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); + ASSERT_EFI_ERROR (Status); Instance->Initialized = TRUE; mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase); @@ -757,28 +780,6 @@ NorFlashFvbInitialize ( } // - // Declare the Non-Volatile storage as EFI_MEMORY_RUNTIME - // - - // Note: all the NOR Flash region needs to be reserved into the UEFI Runtime memory; - // even if we only use the small block region at the top of the NOR Flash. - // The reason is when the NOR Flash memory is set into program mode, the command - // is written as the base of the flash region (ie: Instance->DeviceBaseAddress) - RuntimeMmioRegionSize = (Instance->RegionBaseAddress - Instance->DeviceBaseAddress) + Instance->Size; - - Status = gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, - Instance->DeviceBaseAddress, RuntimeMmioRegionSize, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME - ); - ASSERT_EFI_ERROR (Status); - - Status = gDS->SetMemorySpaceAttributes ( - Instance->DeviceBaseAddress, RuntimeMmioRegionSize, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME); - ASSERT_EFI_ERROR (Status); - - // // Register for the virtual address change event // Status = gBS->CreateEventEx ( -- 1.9.1