coreboot-kgpe-d16/util/cbfstool
Julius Werner 76dab5f98f cbfstool: Add support for platform "fixups" when modifying bootblock
To support the new CONFIG_CBFS_VERIFICATION feature, cbfstool needs to
update the metadata hash embedded in the bootblock code every time it
adds or removes a CBFS file. This can lead to problems on certain
platforms where the bootblock needs to be specially wrapped in some
platform-specific data structure so that the platform's masked ROM can
recognize it. If that data structure contains any form of hash or
signature of the bootblock code that is checked on every boot, it will
no longer match if cbfstool modifies it after the fact.

In general, we should always try to disable these kinds of features
where possible (they're not super useful anyway). But for platforms
where the hardware simply doesn't allow that, this patch introduces the
concept of "platform fixups" to cbfstool. Whenever cbfstool finds a
metadata hash anchor in a CBFS image, it will run all built-in "fixup
probe" functions on that bootblock to check if it can recognize it as
the wrapper format for a platform known to have such an issue. If so, it
will register a corresponding fixup function that will run whenever it
tries to write back modified data to that bootblock. The function can
then modify any platform-specific headers as necessary.

As first supported platform, this patch adds a fixup for Qualcomm
platforms (specifically the header format used by sc7180), which
recalculates the bootblock body hash originally added by
util/qualcomm/createxbl.py.

(Note that this feature is not intended to support platform-specific
signature schemes like BootGuard directly in cbfstool. For anything that
requires an actual secret key, it should be okay if the user needs to
run a platform-specific signing tool on the final CBFS image before
flashing. This feature is intended for the normal unsigned case (which
on some platforms may be implemented as signing with a well-known key)
so that on a board that is not "locked down" in any way the normal use
case of manipulating an image with cbfstool and then directly flashing
the output file stays working with CONFIG_CBFS_VERIFICATION.)

Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I02a83a40f1d0009e6f9561ae5d2d9f37a510549a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41122
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-03-13 04:17:35 +00:00
..
console
flashmap
lz4
lzma
.gitignore
EXAMPLE
Makefile util/cbfstool: Update Makefiles 2021-02-25 10:03:05 +00:00
Makefile.inc cbfstool: Add support for platform "fixups" when modifying bootblock 2021-03-13 04:17:35 +00:00
ProcessorBind.h
amdcompress.c
cbfs-mkpayload.c
cbfs-mkstage.c cbfstool: Remove location pointer from parse_elf_to_stage() 2021-02-18 02:32:28 +00:00
cbfs-payload-linux.c
cbfs.h cbfstool: Add support for platform "fixups" when modifying bootblock 2021-03-13 04:17:35 +00:00
cbfs_glue.h cbfstool: Support CONFIG_CBFS_VERIFICATION and metadata hash anchor 2021-03-13 04:16:20 +00:00
cbfs_image.c cbfstool: Replace FILENAME_ALIGN 16 with ATTRIBUTE_ALIGN 4 2021-02-18 02:32:45 +00:00
cbfs_image.h
cbfs_sections.c
cbfs_sections.h cbfstool: Support CONFIG_CBFS_VERIFICATION and metadata hash anchor 2021-03-13 04:16:20 +00:00
cbfscomptool.c
cbfstool.c cbfstool: Add support for platform "fixups" when modifying bootblock 2021-03-13 04:17:35 +00:00
coff.h
common.c
common.h cbfstool: Remove location pointer from parse_elf_to_stage() 2021-02-18 02:32:28 +00:00
compress.c
default-x86.fmd
default.fmd
description.md
elf.h cbfstool: Add support for platform "fixups" when modifying bootblock 2021-03-13 04:17:35 +00:00
elfheaders.c
elfparsing.h
fdt.h
fit.c
fit.h
flashmap_tests.c
fmap_from_fmd.c
fmap_from_fmd.h
fmaptool.c
fmd.c
fmd.h
fmd_parser.c_shipped
fmd_parser.h_shipped
fmd_parser.y
fmd_scanner.c_shipped treewide: Remove trailing whitespace 2021-02-17 17:30:05 +00:00
fmd_scanner.h_shipped treewide: Remove trailing whitespace 2021-02-17 17:30:05 +00:00
fmd_scanner.l
fv.h
ifittool.c
ifwitool.c
linux.h
linux_trampoline.S
linux_trampoline.c
linux_trampoline.h
option.h
partitioned_file.c
partitioned_file.h
platform_fixups.c cbfstool: Add support for platform "fixups" when modifying bootblock 2021-03-13 04:17:35 +00:00
rmodtool.c
rmodule.c rmodtool: Make memlayout symbols absolute and do not relocate them 2021-02-18 02:32:06 +00:00
rmodule.h rmodtool: Make memlayout symbols absolute and do not relocate them 2021-02-18 02:32:06 +00:00
swab.h
xdr.c