duntan has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/57296 )
Change subject: util/cbftool: Fix the bug in parsing Uefipayload with extended header ......................................................................
util/cbftool: Fix the bug in parsing Uefipayload with extended header
There is an extended header in Fv file with FvNameGuid. The existence of ext header can be confirmed by the value of ext_header_offs.
Signed-off-by: Dun Tan dun.tan@intel.com Change-Id: Id063efb1c8e6c7a96ec2182e87b71c7e8b7b6423 --- M util/cbfstool/cbfs-mkpayload.c M util/cbfstool/fv.h 2 files changed, 12 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/57296/1
diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c index ae875f3..5341337 100644 --- a/util/cbfstool/cbfs-mkpayload.c +++ b/util/cbfstool/cbfs-mkpayload.c @@ -283,6 +283,7 @@ struct cbfs_payload_segment segs[2] = { {0} }; int doffset, len = 0; firmware_volume_header_t *fv; + firmware_volume_ext_header_t *fvh_ext; ffs_file_header_t *fh; common_section_header_t *cs; dos_header_t *dh; @@ -305,6 +306,12 @@ }
fh = (ffs_file_header_t *)(input->data + fv->header_length); + if (fv->ext_header_offs != 0) { + fvh_ext = (firmware_volume_ext_header_t *)((uintptr_t)fv + fv->ext_header_offs); + fh = (ffs_file_header_t *)((uintptr_t)fvh_ext + fvh_ext->ext_header_size); + fh = (ffs_file_header_t *)(((uintptr_t)fh + 7) & ~7); + } + while (fh->file_type == FILETYPE_PAD) { unsigned long offset = (fh->size[2] << 16) | (fh->size[1] << 8) | fh->size[0]; DEBUG("skipping %lu bytes of FV padding\n", offset); diff --git a/util/cbfstool/fv.h b/util/cbfstool/fv.h index 21bd89f..0ad650f 100644 --- a/util/cbfstool/fv.h +++ b/util/cbfstool/fv.h @@ -32,3 +32,8 @@ uint8_t size[3]; uint8_t section_type; } common_section_header_t; + +typedef struct { + uint8_t guid[16]; + uint32_t ext_header_size; +} firmware_volume_ext_header_t;