From 6ffaac1d1136a5ab06de82802ee1a7548e924008 Mon Sep 17 00:00:00 2001 From: Brandon Breitenstein Date: Tue, 23 Aug 2016 14:55:13 -0700 Subject: [PATCH] UPSTREAM: commonlib: update fsp_relocate to make it compatible with UEFI 2.6 UEFI 2.6 spec casts the return of FFS_FILE2_SIZE to a UINT32 which cannot be read using read_le32(&returnval). Add in a cast in order to safeguard for any non x86 architecture that may use this relocate. The proper change will be to get the UEFI header files changed to not cast this return value. BUG=None BRANCH=None TEST=None Signed-off-by: Brandon Breitenstein Reviewed-on: https://review.coreboot.org/16309 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Change-Id: Ie1b50d99576ac42a0413204bbd599bab9f01828e Reviewed-on: https://chromium-review.googlesource.com/381005 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Aaron Durbin --- src/commonlib/fsp_relocate.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/commonlib/fsp_relocate.c b/src/commonlib/fsp_relocate.c index 7f1e49accf..57c0ac99eb 100644 --- a/src/commonlib/fsp_relocate.c +++ b/src/commonlib/fsp_relocate.c @@ -258,8 +258,15 @@ static size_t ffs_file_size(const EFI_FFS_FILE_HEADER *ffsfh) { size_t size; - if (IS_FFS_FILE2(ffsfh)) - size = read_le32(&FFS_FILE2_SIZE(ffsfh)); + if (IS_FFS_FILE2(ffsfh)) { + /* + * this cast is needed with UEFI 2.6 headers in order + * to read the UINT32 value that FFS_FILE2_SIZE converts + * the return into + */ + uint32_t file2_size = FFS_FILE2_SIZE(ffsfh); + size = read_le32(&file2_size); + } else { size = read_le8(&ffsfh->Size[0]) << 0; size |= read_le8(&ffsfh->Size[1]) << 8;