aboutsummaryrefslogtreecommitdiff
path: root/util/cbfstool/common.h
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-10-15 17:37:57 -0700
committerPatrick Georgi <pgeorgi@google.com>2021-03-17 08:10:00 +0000
commit81dc20e744aa1762c17dcf5aac5c37643d62a983 (patch)
tree1605652d540d384b6ea5b4ca585cba25d1a720d8 /util/cbfstool/common.h
parent2e973942bc34ff2d7b110ba35bf3cda987838907 (diff)
cbfs: Move stage header into a CBFS attribute
The CBFS stage header is part of the file data (not the header) from CBFS's point of view, which is problematic for verification: in pre-RAM environments, there's usually not enough scratch space in CBFS_CACHE to load the full stage into memory, so it must be directly loaded into its final destination. However, that destination is decided from reading the stage header. There's no way we can verify the stage header without loading the whole file and we can't load the file without trusting the information in the stage header. To solve this problem, this patch changes the CBFS stage format to move the stage header out of the file contents and into a separate CBFS attribute. Attributes are part of the metadata, so they have already been verified before the file is loaded. Since CBFS stages are generally only meant to be used by coreboot itself and the coreboot build system builds cbfstool and all stages together in one go, maintaining backwards-compatibility should not be necessary. An older version of coreboot will build the old version of cbfstool and a newer version of coreboot will build the new version of cbfstool before using it to add stages to the final image, thus cbfstool and coreboot's stage loader should stay in sync. This only causes problems when someone stashes away a copy of cbfstool somewhere and later uses it to try to extract stages from a coreboot image built from a different revision... a debugging use-case that is hopefully rare enough that affected users can manually deal with finding a matching version of cbfstool. The SELF (payload) format, on the other hand, is designed to be used for binaries outside of coreboot that may use independent build systems and are more likely to be added with a potentially stale copy of cbfstool, so it would be more problematic to make a similar change for SELFs. It is not necessary for verification either, since they're usually only used in post-RAM environments and selfload() already maps SELFs to CBFS_CACHE before loading them to their final destination anyway (so they can be hashed at that time). Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I8471ad7494b07599e24e82b81e507fcafbad808a Reviewed-on: https://review.coreboot.org/c/coreboot/+/46484 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/cbfstool/common.h')
-rw-r--r--util/cbfstool/common.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index db9c7e7297..479fd713dd 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -174,10 +174,12 @@ int parse_flat_binary_to_payload(const struct buffer *input,
enum cbfs_compression algo);
/* cbfs-mkstage.c */
int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
- enum cbfs_compression algo, const char *ignore_section);
+ const char *ignore_section,
+ struct cbfs_file_attr_stageheader *stageheader);
/* location is TOP aligned. */
int parse_elf_to_xip_stage(const struct buffer *input, struct buffer *output,
- uint32_t *location, const char *ignore_section);
+ uint32_t *location, const char *ignore_section,
+ struct cbfs_file_attr_stageheader *stageheader);
void print_supported_architectures(void);
void print_supported_filetypes(void);