Sol Boucher (solb@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10122
-gerrit
commit dd6ecddc0d4d095773f67155ff73ab55d1a5dc28 Author: Sol Boucher solb@chromium.org Date: Tue May 5 15:35:18 2015 -0700
cbfstool: Fix cbfs_copy_instance()'s master header endianness
The function hadn't been updated to account for the fact that we now copy an endianness-corrected CBFS master header into a separate buffer from the CBFS data: it still performed pointer arithmetic accross the two buffers and wrote the copied buffer into the image without restoring the original endianness.
Change-Id: Ieb2a001f253494cf3a90d7e19cd260791200c4d3 Signed-off-by: Sol Boucher solb@chromium.org --- util/cbfstool/cbfs_image.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 8e0e9a4..457a873 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -336,17 +336,13 @@ int cbfs_copy_instance(struct cbfs_image *image, size_t copy_offset, size_t align, entry_offset; ssize_t last_entry_size;
- size_t header_offset, header_end; size_t cbfs_offset, cbfs_end; size_t copy_end = copy_offset + copy_size;
- align = htonl(image->header->align); + align = image->header->align;
- header_offset = (char *)image->header - image->buffer.data; - header_end = header_offset + sizeof(image->header); - - cbfs_offset = htonl(image->header->offset); - cbfs_end = htonl(image->header->romsize); + cbfs_offset = image->header->offset; + cbfs_end = image->header->romsize;
if (copy_end > image->buffer.size) { ERROR("Copy offset out of range: [%zx:%zx)\n", @@ -354,12 +350,7 @@ int cbfs_copy_instance(struct cbfs_image *image, size_t copy_offset, return 1; }
- /* Range check requested copy region with header and source cbfs. */ - if ((copy_offset >= header_offset && copy_offset < header_end) || - (copy_end >= header_offset && copy_end <= header_end)) { - ERROR("New image would overlap old header.\n"); - } - + /* Range check requested copy region with source cbfs. */ if ((copy_offset >= cbfs_offset && copy_offset < cbfs_end) || (copy_end >= cbfs_offset && copy_end <= cbfs_end)) { ERROR("New image would overlap old one.\n"); @@ -368,7 +359,7 @@ int cbfs_copy_instance(struct cbfs_image *image, size_t copy_offset,
/* This will work, let's create a copy. */ copy_header = (struct cbfs_header *)(image->buffer.data + copy_offset); - *copy_header = *image->header; + cbfs_put_header(copy_header, image->header);
copy_header->bootblocksize = 0; /* Romsize is a misnomer. It's the absolute limit of cbfs content.*/