Hello Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/47827
to review the following change.
Change subject: cbfstool: Replace FILENAME_ALIGN 16 with ATTRIBUTE_ALIGN 4
......................................................................
cbfstool: Replace FILENAME_ALIGN 16 with ATTRIBUTE_ALIGN 4
cbfstool has always had a CBFS_FILENAME_ALIGN that forces the filename
field to be aligned upwards to the next 16-byte boundary. This was
presumably done to align the file contents (which used to come
immediately after the filename field).
However, this hasn't really worked right ever since we introduced CBFS
attributes. Attributes come between the filename and the contents, so
what this code currently does is fill up the filename field with extra
NUL-bytes to the boundary, and then just put the attributes behind it
with whatever size they may be. The file contents don't end up with any
alignment guarantee and the filename field is just wasting space.
This patch removes the old FILENAME_ALIGN, and instead adds a new
alignment of 4 for the attributes. 4 seems like a reasonable alignment
to enforce since all existing attributes (with the exception of weird
edge cases with the padding attribute) already use sizes divisible by 4
anyway, and the common attribute header fields have a natural alignment
of 4. This means file contents will also have a minimum alignment
guarantee of 4 -- files requiring a larger guarantee can still be added
with the --alignment flag as usual.
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Change-Id: I43f3906977094df87fdc283221d8971a6df01b53
---
M src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h
M util/cbfstool/cbfs_image.c
M util/cbfstool/cbfstool.c
3 files changed, 7 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/47827/1
diff --git a/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h b/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h
index c31d995..7cdea26 100644
--- a/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h
+++ b/src/commonlib/bsd/include/commonlib/bsd/cbfs_serialized.h
@@ -115,6 +115,9 @@
uint8_t data[0];
} __packed;
+/* All attribute sizes must be divisible by this! */
+#define CBFS_ATTRIBUTE_ALIGN 4
+
/* Depending on how the header was initialized, it may be backed with 0x00 or
* 0xff. Support both. */
enum cbfs_file_attr_tag {
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index c7531d6..20df20b 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -34,10 +34,6 @@
* removing said guarantees.
*/
-/* The file name align is not defined in CBFS spec -- only a preference by
- * (old) cbfstool. */
-#define CBFS_FILENAME_ALIGN (16)
-
static const char *lookup_name_by_type(const struct typedesc_t *desc, uint32_t type,
const char *default_value)
{
@@ -70,7 +66,7 @@
size_t cbfs_calculate_file_header_size(const char *name)
{
return (sizeof(struct cbfs_file) +
- align_up(strlen(name) + 1, CBFS_FILENAME_ALIGN));
+ align_up(strlen(name) + 1, CBFS_ATTRIBUTE_ALIGN));
}
/* Only call on legacy CBFSes possessing a master header. */
@@ -1836,6 +1832,7 @@
uint32_t tag,
uint32_t size)
{
+ assert(IS_ALIGNED(size, CBFS_ATTRIBUTE_ALIGN));
struct cbfs_file_attribute *attr, *next;
next = cbfs_file_first_attr(header);
do {
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 68c2c22..8df0fa1 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -740,7 +740,8 @@
if (param.padding) {
const uint32_t hs = sizeof(struct cbfs_file_attribute);
- uint32_t size = MAX(hs, param.padding);
+ uint32_t size = ALIGN_UP(MAX(hs, param.padding),
+ CBFS_ATTRIBUTE_ALIGN);
INFO("Padding %d bytes\n", size);
struct cbfs_file_attribute *attr =
(struct cbfs_file_attribute *)cbfs_add_file_attr(
--
To view, visit https://review.coreboot.org/c/coreboot/+/47827
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I43f3906977094df87fdc283221d8971a6df01b53
Gerrit-Change-Number: 47827
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-MessageType: newchange
Julius Werner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/47824 )
Change subject: cbfstool: Ensure attributes always come last in the metadata
......................................................................
cbfstool: Ensure attributes always come last in the metadata
In a rare placement edge case when adding a file with alignment
requirements, cbfstool may need to generate a CBFS header that's
slightly larger than it needs to be. The way we do this is by just
increasing the data offset field in the CBFS header until the data falls
to the desired value.
This approach works but it may confuse parsing code in the presence of
CBFS attributes. Normally, the whole area between the attribute offset
and the data offset is filled with valid attributes written back to
back, but when this header expansion occurs the attributes are followed
by some garbage data (usually 0xff). Parsers are resilient against this
but may show unexpected error messages.
This patch solves the problem by moving the attribute offset forwards
together with the data offset, so that the total area used for
attributes doesn't change. Instead, the filename field becomes the
expanded area, which is a closer match to how this worked when it was
originally implemented (before attributes existed) and is less confusing
for parsers since filenames are zero-terminated anyway.
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Change-Id: I3dd503dd5c9e6c4be437f694a7f8993a57168c2b
---
M util/cbfstool/cbfs_image.c
1 file changed, 19 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/47824/1
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index a51f941..c7531d6 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -666,15 +666,28 @@
len = content_offset - addr - header_size;
memcpy(entry, header, header_size);
if (len != 0) {
- /* the header moved backwards a bit to accommodate cbfs_file
+ /*
+ * The header moved backwards a bit to accommodate cbfs_file
* alignment requirements, so patch up ->offset to still point
- * to file data.
+ * to file data. Move attributes forward so the end of the
+ * attribute list still matches the end of the metadata.
*/
+ uint32_t offset = ntohl(entry->offset);
+ uint32_t attrs = ntohl(entry->attributes_offset);
DEBUG("|..|header|content|... <use offset to create entry>\n");
- DEBUG("before: offset=0x%x\n", ntohl(entry->offset));
- // TODO reset expanded name buffer to 0xFF.
- entry->offset = htonl(ntohl(entry->offset) + len);
- DEBUG("after: offset=0x%x\n", ntohl(entry->len));
+ DEBUG("before: attr_offset=0x%x, offset=0x%x\n", attrs, offset);
+ if (attrs == 0) {
+ memset((uint8_t *)entry + offset, 0, len);
+ } else {
+ uint8_t *p = (uint8_t *)entry + attrs;
+ memmove(p + len, p, offset - attrs);
+ memset(p, 0, len);
+ attrs += len;
+ entry->attributes_offset = htonl(attrs);
+ }
+ offset += len;
+ entry->offset = htonl(offset);
+ DEBUG("after: attr_offset=0x%x, offset=0x%x\n", attrs, offset);
}
// Ready to fill data into entry.
--
To view, visit https://review.coreboot.org/c/coreboot/+/47824
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I3dd503dd5c9e6c4be437f694a7f8993a57168c2b
Gerrit-Change-Number: 47824
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-MessageType: newchange
HAOUAS Elyes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42251 )
Change subject: crossgcc: Upgrade GCC to 10.1.0
......................................................................
crossgcc: Upgrade GCC to 10.1.0
nds32, GNAT bad constant and gnat_eh patches are integrated in upstream
so we don't need them anymore.
Change-Id: I4d279dd6cfc7b2382b51469b04dbec83a91295d1
Signed-off-by: Elyes HAOUAS <ehaouas(a)noos.fr>
---
M util/crossgcc/buildgcc
R util/crossgcc/patches/gcc-10.1.0_ada-musl_workaround.patch
R util/crossgcc/patches/gcc-10.1.0_gnat.patch
R util/crossgcc/patches/gcc-10.1.0_libgcc.patch
D util/crossgcc/patches/gcc-8.3.0_gnat-bad_constant.patch
D util/crossgcc/patches/gcc-8.3.0_gnat_eh.patch
D util/crossgcc/patches/gcc-8.3.0_nds32_ite.patch
A util/crossgcc/sum/gcc-10.1.0.tar.xz.cksum
D util/crossgcc/sum/gcc-8.3.0.tar.xz.cksum
9 files changed, 2 insertions(+), 21,441 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/42251/1
--
To view, visit https://review.coreboot.org/c/coreboot/+/42251
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I4d279dd6cfc7b2382b51469b04dbec83a91295d1
Gerrit-Change-Number: 42251
Gerrit-PatchSet: 1
Gerrit-Owner: HAOUAS Elyes <ehaouas(a)noos.fr>
Gerrit-MessageType: newchange