From 753129ff2b44becf159c763252b8fa669b4abef2 Mon Sep 17 00:00:00 2001 From: Maurice Ma Date: Wed, 29 Jan 2020 08:23:38 -0800 Subject: [PATCH] Avoid hardcoded flashmap address Current FLASH_MAP address is hard-coded at 0xFFFFFFF8. It will work in most of the cases. However, if region is added on top of the Stage1A FV, it will cause FLASH_MAP address shift. Instead, the code can use relative address to locate FLASH_MAP. The address can be calculated with (Stage1AFvBase + Stage1AFvSize + 0xFFFFFFF8). Signed-off-by: Maurice Ma --- BootloaderCorePkg/Stage1A/Stage1A.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BootloaderCorePkg/Stage1A/Stage1A.c b/BootloaderCorePkg/Stage1A/Stage1A.c index d7c80155..eb008bb9 100644 --- a/BootloaderCorePkg/Stage1A/Stage1A.c +++ b/BootloaderCorePkg/Stage1A/Stage1A.c @@ -47,8 +47,8 @@ GetFlashMapBufInfo ( UINT32 Stage1aFvBase; FlashMap = NULL; - FlashMapBase = (* (UINT32 *)FLASH_MAP_ADDRESS); Stage1aFvBase = PcdGet32 (PcdStage1AFdBase) + PcdGet32 (PcdFSPTSize); + FlashMapBase = (* (UINT32 *)(UINT32)(Stage1aFvBase + PcdGet32 (PcdStage1AFvSize) + FLASH_MAP_ADDRESS)); if ( (FlashMapBase > Stage1aFvBase) && \ (FlashMapBase + sizeof(FLASH_MAP) < Stage1aFvBase + PcdGet32 (PcdStage1AFvSize) - 1) ) { // Verify FLASH_MAP is valid before access