Commit Graph

5318 Commits

Author SHA1 Message Date
Michał Kopeć cde0a4b7d9 util/cbfstool/ifittool.c: Use relative addresses when adding FIT entries
This is needed to properly set addresses of objects located in the Top
Swap region of the flash, when Top Swap-based redundancy is enabled.

Upstream-Status: Pending
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2026-01-23 15:33:43 +01:00
Filip Gołaś d6065d7d39 CBFS verification: support Top Swap redundancy
Separating the bootblock into two copies (in BOOTBLOCK and TOPSWAP fmap
regions) breaks the CBFS verification as TSPI CRTM knows nothing about
the new regions and looks for bootblock in a hard-coded COREBOOT fmap
region.

Introduce and use cbfs_unverified_area_type_alloc() which is an
extension of cbfs_unverified_area_alloc(), very similar to how
cbfs_ro_type_map() is an extension of cbfs_ro_map().  This allows to
specify a region of the bootblock file and skip verification because
bootblock serves as a container of hashes and is not verified itself.

The branching is done on the state of RTC BUC to always use the current
bootblock.  Somewhat confusingly, the measurement always uses BOOTBLOCK
region because with active Top Swap that's the way to access a
memory-mapped TOPSWAP region.

Makefile.mk now verifies both COREBOOT and COREBOOT_TS regions.
cbfstool needed a few updates as well:
 - recognize both "BOOTBLOCK" and "TOPSWAP" regions
 - recognize both "COREBOOT" and "COREBOOT_TS" regions
 - reset metadata cache before processing each region as cache may now
   be invalid

SMM doesn't link with vboot functions, so cbfs_file_hash_mismatch() has
to skip verification in SMM due to the use of CMOS options backend.

This is a part of the bootblock redundancy feature proposed
on the mailing list:
https://mail.coreboot.org/archives/list/coreboot@coreboot.org/thread/C6JN2PB7K7D67EG7OIKB6BBERZU5YV35/

Tested by successfully booting into Protectli VP6670 with Top Swap and
CBFS Verification features enabled and Top Swap state being toggled.

Change-Id: Ia75e714ae84d8c0ae09b27495e3056313b109999
Upstream-Status: Backport [CB:8961]
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89691
Reviewed-by: Michał Kopeć <michal.kopec@3mdeb.com>
Reviewed-by: Filip Lewiński <filip.lewinski@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2026-01-23 15:27:15 +01:00
Filip Lewiński 6cd2a2bff3 ifittool: allow adding files from a separate region
Allows ifittool to add FIT entries for files that are located in a
different FMAP region than the FIT table.

The region from where to source the file can be specified with -R.
If not given it defaults to using the value of the mandatory -r,
for full backwards compatibility.

Example: Tested with a custom binary with the bootblock and
corresponding FIT table in a separate region, and the microcode still
in the COREBOOT region:

λ ./ifittool -f test_ts.rom -a -n cpu_microcode_blob.bin -t 1 \
	-r BOOTBLOCK \
	-R COREBOOT \
	-s 4

Change-Id: I7e49247f280ec118e09cf173795d7602a4c0d7f6
Upstream-Status: Backport [CB:89608]
Signed-off-by: Filip Lewiński <filip.lewinski@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89608
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2026-01-23 15:27:13 +01:00
Filip Gołaś cffafc0fc0 ifdtool: Add set top swap size PCH strap subcommand
Top-Block Swap mode of Intel PCH allows to swap the boot block with
another location placed directly below it by redirecting the memory
accesses.

The range of the addresses to be redirected is configured using the Top
Swap Block Size (or BOOT_BLOCK_SIZE) PCH strap using 3 bits to encode
one of 8 sizes:
    64 KB, 128 KB, 256 KB, 512 KB, 1 MB, 2 MB, 4 MB or 8 MB.

The source and target ranges depend on the configured size, eg:
- 64 KB  - FFFF_0000h - FFFF_FFFFh -> FFFE_0000h - FFFE_FFFFh
- 128 KB - FFFE_0000h - FFFF_FFFFh -> FFFC_0000h - FFFD_FFFFh
- 8 MB   - FF80_0000h - FFFF_FFFFh -> FF00_0000h - FF7F_FFFFh

Only supporting Alder Lake-P and Alder Lake-N for now.

Needed for the bootblock redundancy feature suggested at
https://mail.coreboot.org/archives/list/coreboot@coreboot.org/thread/C6JN2PB7K7D67EG7OIKB6BBERZU5YV35/

TEST=check using xxd, MFIT tool, ensure VP6670 boots
Test details:
xxd:
  ./util/ifdtool/ifdtool -p adl -T 0x10000 vp66xx_fd.bin && \
  xxd vp66xx_fd.bin > vp66xx.hex && \
  xxd vp66xx_fd.bin.new > vp66xx_fd.new.hex && \
  diff -au vp66xx_fd.hex vp66xx_fd.new.hex

File vp66xx_fd.bin is 4096 bytes
Writing new image to vp66xx_fd.bin.new

Change-Id: I7f2ae67808e8ac0aaa2a9ad5e091c2b358d4a5ab

--- vp66xx_fd.hex       2025-10-08 12:03:09.527193533 +0200
+++ vp66xx_fd.new.hex   2025-10-08 12:05:08.717108142 +0200
@@ -18,7 +18,7 @@
 00000110: 7f78 0700 0000 0000 1800 0000 0000 1f00  .x..............
 00000120: 0808 1170 0000 0000 0000 7f06 80f8 8107  ...p............
 00000130: 0000 0000 0f00 0000 2222 2222 2202 2222  ........""""".""
-00000140: 0000 0000 0000 0000 0000 ff00 6000 80c8  ............`...
+00000140: 0000 0000 0000 0000 0000 ff00 0000 80c8  ................
 00000150: 4586 0036 0000 0000 0002 5800 0000 4000  E..6......X...@.
 00000160: 0018 0000 0000 0000 0000 0000 0000 0000  ................
 00000170: 0000 0000 0000 0000 54b3 04a0 3000 0140  ........T...0..@

mfittool:
./mfit --gui -decompose protectli_vp66xx_v0.9.2.rom
In the UI:
Flash Settings > BIOS Configuration > Top Swap Block Size
shows the value changing to the expected one, ie.
    -T 0x10000 results in 64kB
    -T 0x20000 results in 128kB
    -T 0x400000 results in 4MB
    etc.

Change-Id: I50e9d4160ee4b60e83567bcd33c9d80d428cf2bb
Upstream-Status: Backport [CB:89438]
Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89438
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2026-01-23 15:27:12 +01:00
Benjamin Doron 279a9aa949 util/smmstoretool: Support other block sizes
smmstoretool is effectively a UEFI variable store writing tool, with
a specific emphasis on the SMMSTORE backend implementation.

However, it could also support other backends. Since it's typical for
the variable store to be `n / 2 - 1` blocks, but not typical how large
each block should be, allow this to be overridden on the command line.

This is necessary because in EDK2, the module producing the firmware
volume block protocol, the backend, will initialise a HOB or set PCDs to
indicate the size of the store to the rest of the stack, and an
assertion will be hit if the store has been preseeded by smmstoretool
using differently-sized blocks.

For example, `make CFLAGS=-DSMM_BLOCK_SIZE=8192` builds this for a
firmware volume block protocol implementation with 8K blocks.

Upstream-Status: Backport [CB:88427]
Change-Id: I08b78cfb0b591641f09fcf86f40dd31e6b6c9b30
Signed-off-by: Benjamin Doron <benjamin.doron@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88427
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Alicja Michalska <ahplka19@gmail.com>
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2025-10-20 16:41:52 +02:00
Krystian Hebel 2bce548f3e util/smmstoretool: allow for writing raw type variables from file
Some variables can't be described using any of the predefined types.
Allow passing their values from a file.

Upstream-Status: Pending
Change-Id: Idb03e8dbdbdd446cc16cae584640cf1641ecc2c1
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-07-22 16:18:26 +02:00
Krystian Hebel 46b6ef5b9f util/smmstore_debug: add tool for low-level interactions with SMMSTORE
Commands and parameters are passed as raw numbers, but that's the point,
we want to test it with something more than normal SMMSTORE interface.

Upstream-Status: Pending
Change-Id: Ib3a32f0bdef038e4ccc2fb2bb8a6c98ae6d0cfbd
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-07-22 16:18:26 +02:00
Sergii Dmytruk 0e3a0d83fc util/lint/kconfig_lint: fix negation of a match
This fixes the following Perl error (which prevents pre-commit hook from
succeeding):

    Possible precedence problem between ! and pattern match (m//)

`!$filename =~ /~$/` was apparently interpreted as
`(!$filename) =~ /~$/`.  Fix that by wrapping `=~` expression in
parenthesis.

Upstream-Status: Pending
Change-Id: If63a4b6981e5b562a9af7f2f8ac64947fad7f7b0
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2025-07-22 15:39:55 +03:00
Krystian Hebel 0b42ba7fcb util/dasharo/tag-with-changelog: try to reuse existing edk2 repository
If the script is run in the directory that was used to build coreboot,
chances are that edk2 repository is already cloned in the payloads
subdirectory. It is passed as '--reference-if-able' option, which
reduces the number of objects to be downloaded, even when it is checked
out on older revision. If that path doesn't exist, the repo gets cloned
as usual.

Upstream-Status: Inappropriate [Dasharo downstream]
Change-Id: I11eae8a7d87923a469ac7ba927103395ceb979f4
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-07-02 12:25:57 +02:00
Krystian Hebel 3096fcde4c util/dasharo/tag-with-changelog: list edk2 and submodules commits
Other payloads aren't supported.

Both submodules and edk2 commits are nested one level deeper that the
main log. This is a compromise between enough information (previously
just the number of commit added in a submodule was printed) and clear
grouping between categories.

Changelog for edk2 is limited in history, it starts with the first
commit pointed to by common Kconfig default. For releases made before
this commit, a warning about a possibly incomplete edk2 changelog
will be shown in the comment just above the changelog. The changelog
will be complete only if older tag is made after this commit, in most
cases this will be two releases (or release candidates) from now, for
each platform separately.

Upstream-Status: Inappropriate [Dasharo downstream]
Change-Id: I9db19340b25ba8fe3c8382217e777c9dbe901d04
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-07-02 12:24:15 +02:00
Krystian Hebel 97105c6159 util/dasharo/tag-with-changelog: dedupe Dasharo boards and build system
Protectli and NovaCustom aren't split to dedicated groups for single
boards, since new platforms are added often for those vendors.

Upstream-Status: Inappropriate [Dasharo downstream]
Change-Id: I2385ec18605f3095580857fdcac0f0e726446794
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-06-30 20:18:25 +02:00
Krystian Hebel 0e0d0dad35 util/dasharo/tag-with-changelog: create a tag with changelog as a message
Apart for new comments for handling the tags, the format of log file
was adjusted so that all informational lines that are not expected in
the final tag description are written as comments. The changelog file
now starts with the instructions for the committer.

This commit also changes the logic checking for clean git tree - the
script no longer requires running from the main branch.

Upstream-Status: Inappropriate [Dasharo downstream]
Change-Id: I9c9b5712fc346a59e9ad0bf7969ee0be1f473a61
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-06-30 20:18:25 +02:00
Krystian Hebel 7ce803b4bb util/dasharo/tag-with-changelog: remove unnecessary parts
This includes:
- tool check - it is assumed that git is installed, and other tools are
  no longer required
- lines of code calculations - not required for a changelog
- list of added or removed mainboards, SOCs, CPUs etc.
- number of commits by author and list of new authors

Upstream-Status: Inappropriate [Dasharo downstream]
Change-Id: I17ef764516cd4ca3467e96f39ac0c81b28b8e06a
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-06-30 14:06:22 +02:00
Krystian Hebel 19639b3aca util/dasharo/tag-with-changelog: add new file
This is an exact copy of util/release/genrelnotes as of 50e8579bfd
("util/release: Remove makefile.inc references from genrelnotes").
It will be modified for a new role in following commits.

Upstream-Status: Inappropriate [Dasharo downstream]
Change-Id: I32f3d2cb5ad57a52f4b20791f31f2b8ebdfcdd4a
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
2025-06-30 14:06:22 +02:00
Michał Żygowski 6cec520515 util/cbmem/cbmem.c: Avoid overflwos when parsing TCG TPM logs
The utility assumed that TCG TPM log area is zeroed and then filled
with events but it does not have to be true. If there is garbage
after the last valid event entry, the utility will most likely
access data outside of the cbmem area containing the logs. Relevant
issue: https://github.com/linuxboot/heads/issues/1608

TEST=Dump TCG TPM1.2 event log on Dell OptiPlex 7010 and see
"Invalid TPM1.2 log entry overflowing cbmem area" error is printed.

Upstream-Status: Submitted [CB:84926]
Change-Id: I7e057db3378b701d046d4e578272b10f294142a7
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2025-03-13 17:51:42 +02:00
Michał Żygowski 0d88b56cda util/txesbmantool: Add utility to generate TXE SB manifests
Print key hashes when displaying manifests as it may be useful when
obtaining information from binary about the used keys and what hash
should be provisioned in TXE.

Change-Id: I288fbb3db6b42e231977683145ce67e8fbd98dfc
Upstream-Status: Pending
Co-authored-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2025-03-13 17:50:48 +02:00
Michał Żygowski 8671693486 util/msi: Allow to include ROMHOLE as CBFS file
Change-Id: I3871236dccf128fb9038e98977629613d28b7121
Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2025-03-13 17:50:36 +02:00
Michał Żygowski d952ce4166 util/ifdtool/ifdtool.c: Print current HAP state for all platforms
Change-Id: Id36e05e9d5668b7c4167bd41846d9ddee40ffea6
Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2025-03-13 17:50:36 +02:00
Michał Żygowski 878a652008 util/ifdtool: Add complete set of HAP bit locations
Change-Id: I74427dc0c0aa5da317418a7610b5960c411cb032
Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
2025-03-13 17:50:36 +02:00
Michał Żygowski 6fab6401b6 util/msi: add utility to generate the MSI ROMHOLE
Upstream-Status: Pending
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Change-Id: Icc27a9162b7a56c3fb1dba08406a1f3dae592b7b
2025-03-13 17:50:27 +02:00
Michał Żygowski d839eb3aa3 util/genbuild_h/genbuild_h.sh: generate Dasharo version
Change-Id: I656ab30e2d628719a9a68ef48967a1d327e96e05
Upstream-Status: Inappropriate [Dasharo downstream]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
2025-02-28 15:37:40 +02:00
Dinesh Gehlot 5af5e66686 util/cbfstool: eliminate late sign of life event
The purpose of the late sign-of-life (SOL) event was to add logs for
the CSE sync at the payload. However, recent changes have decoupled CSE
sync and SOL events, resulting in redundant event logging. This update
eliminates the superfluous late SOL event logs.

BUG=b:379585294
TEST=boot verified on google/rex0 and google/rex64

without change:
```
rex-rev3 ~ # elogtool list
rex64-rev3 ~ # /media/usb/elogtool list
0 | 2024-01-01 22:50:19-0800 | Log area cleared | 250
1 | 2024-01-01 22:50:59-0800 | System boot | 30
2 | 2024-01-01 22:50:59-0800 | Firmware Splash Screen | Enabled
3 | 2024-01-01 22:51:00-0800 | Power Fail
4 | 2024-01-01 22:51:00-0800 | SUS Power Fail
5 | 2024-01-01 22:51:00-0800 | ACPI Wake | S5
6 | 2024-01-01 22:51:00-0800 | Wake Source | Power Button | 0
7 | 2024-01-01 22:51:00-0800 | Late Sign of Life  | CSE Sync Late SOL Screen Shown
8 | 2024-01-01 22:51:00-0800 | Firmware CSE sync | CSE Sync at Payload
```
with change:
```
rex64-rev3 ~ # elogtool list
0 | 2024-12-17 02:42:23-0800 | Log area cleared | 141
1 | 2024-12-17 02:43:14-0800 | System boot | 81
2 | 2024-12-17 02:43:14-0800 | Firmware Splash Screen | Enabled
3 | 2024-12-17 02:43:16-0800 | Power Fail
4 | 2024-12-17 02:43:16-0800 | SUS Power Fail
5 | 2024-12-17 02:43:16-0800 | ACPI Wake | S5
6 | 2024-12-17 02:43:16-0800 | Wake Source | Power Button | 0
7 | 2024-12-17 02:43:16-0800 | Firmware CSE sync | CSE Sync at Payload
```

Change-Id: I53baecb3ca0cef5e0e18732e02832e8331e000d0
Signed-off-by: Dinesh Gehlot <digehlot@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85621
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
2024-12-19 14:30:23 +00:00
Jon Murphy e3150e819d util/crossgcc: Add libstdcxx target
Add target for building libstdcxx for a cross compile target using the
GCC source downloaded for a cross compiler build and linking against a
specified libc implementation.

BUG=NONE
TEST=Build libstdc++ for cross compilers, link against generated library
./util/crossgcc/buildgcc -t -p arm-eabi -P libstdcxx -l c,c++ -j128 \
--libstdcxx_include /tmp/picolibc

Change-Id: Ie0c06ffaeab632c27a992dee8abcc403cceabeed
Signed-off-by: Jon Murphy <jpmurphy@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85275
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
2024-12-19 06:59:19 +00:00
Vince Liu 0b252ef8b4 util/mtkheader: Add GFH header for mt8189 bootblock code
Set bootblock load address for bootROM.

BUG=b:379008996
BRANCH=none
TEST=Build Pass.

Change-Id: I47078272880a89e81c851ede307cdc306b1c79ac
Signed-off-by: Vince Liu <vince-wl.liu@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85598
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
2024-12-18 02:08:42 +00:00
Dinesh Gehlot 673075f102 util/cbfstool: Add eventLog support for ELOG_TYPE_FW_CSE_SYNC
This patch introduces logging for the ELOG_TYPE_FW_CSE_SYNC event. This
event logs data related to CSE synchronization, along with the relevant
boot stage information.

BUG=b:305898363
TEST=boot verified on google/rex0 and google/rex64

Change-Id: I4d6d3c4e07ab8677feb6a8acf8d4c6604ab704b8
Signed-off-by: Dinesh Gehlot <digehlot@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85218
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-12-16 03:30:21 +00:00