[coreboot-gerrit] New patch to review for coreboot: commonlib: fsp_relocate is incompatible with UEFI 2.6

Brandon Breitenstein (brandon.breitenstein@intel.com) gerrit at coreboot.org
Wed Aug 24 00:36:26 CEST 2016


Brandon Breitenstein (brandon.breitenstein at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16309

-gerrit

commit 2b0c89b960adce8c2e1ff5380daf1f37f6c6acd7
Author: Brandon Breitenstein <brandon.breitenstein at intel.com>
Date:   Tue Aug 23 14:55:13 2016 -0700

    commonlib: fsp_relocate is incompatible 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). adding 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.
    
    Change-Id: Ie1b50d99576ac42a0413204bbd599bab9f01828e
    Signed-off-by: Brandon Breitenstein <brandon.breitenstein at intel.com>
---
 src/commonlib/fsp_relocate.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/commonlib/fsp_relocate.c b/src/commonlib/fsp_relocate.c
index 7f1e49a..d4ca1cd 100644
--- a/src/commonlib/fsp_relocate.c
+++ b/src/commonlib/fsp_relocate.c
@@ -258,9 +258,14 @@ 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));
-	else {
+	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 to  starting in UEFI 2.6 spec */
+		size = (size_t) FFS_FILE2_SIZE(ffsfh);
+		size = read_le32(&size);
+	}
+	else { 
 		size = read_le8(&ffsfh->Size[0]) << 0;
 		size |= read_le8(&ffsfh->Size[1]) << 8;
 		size |= read_le8(&ffsfh->Size[2]) << 16;



More information about the coreboot-gerrit mailing list