Skip to content

Add CBFS/IFD validation + CBFS free space for coreboot builds#2041

Merged
tlaurion merged 2 commits into
linuxboot:masterfrom
tlaurion:cbfs_ifd_validation-free_space_on_build
Jan 7, 2026
Merged

Add CBFS/IFD validation + CBFS free space for coreboot builds#2041
tlaurion merged 2 commits into
linuxboot:masterfrom
tlaurion:cbfs_ifd_validation-free_space_on_build

Conversation

@tlaurion
Copy link
Copy Markdown
Collaborator

@tlaurion tlaurion commented Jan 5, 2026

Introduce validation to ensure coreboot CBFS size matches IFD BIOS region:

  • Add bin/validate_cbfs_ifd_fit.sh: New script to validate CBFS size against Intel Flash Descriptor (IFD) BIOS region and provide space usage statistics
  • Add Makefile targets: validate_cbfs_ifd and fix_cbfs_ifd for manual validation and automatic fixes
  • Integrate validation into coreboot module build process to catch misconfigs at compile time
  • Add validation to final ROM image generation step
  • Add informational hint to Makefile when V=1 verbose flag is not set
  • Add logic so that qemu/kvm boards gpg public key injection only happens if rom changed

This prevents shipping firmware with CBFS sizes that exceed the available BIOS region, catching configuration errors early in the build process.

As can be seen on CircleCI x220-hotp-maximized build :

Jan 06 22:44:08 "/root/heads/build/x86/coreboot-25.09/EOL_t420-hotp-maximized/cbfstool" "/root/heads/build/x86/coreboot-25.09/EOL_t420-hotp-maximized/coreboot.rom" print
Jan 06 22:44:08 FMAP REGION: COREBOOT
Jan 06 22:44:08 Name                           Offset     Type           Size   Comp
Jan 06 22:44:08 cbfs_master_header             0x0        cbfs header        32 none
Jan 06 22:44:08 cpu_microcode_blob.bin         0x80       microcode       26624 none
Jan 06 22:44:08 fallback/romstage              0x68c0     stage          101016 none
Jan 06 22:44:08 fallback/ramstage              0x1f3c0    stage          151125 LZMA (323316 decompressed)
Jan 06 22:44:08 config                         0x44280    raw              3526 LZMA (11252 decompressed)
Jan 06 22:44:08 revision                       0x45080    raw               766 none
Jan 06 22:44:08 build_info                     0x453c0    raw               101 none
Jan 06 22:44:08 bootsplash.jpg                 0x45480    bootsplash      43282 none
Jan 06 22:44:08 fallback/dsdt.aml              0x4fdc0    raw             14520 none
Jan 06 22:44:08 vbt.bin                        0x536c0    raw              1368 LZMA (3985 decompressed)
Jan 06 22:44:08 cmos.default                   0x53c80    cmos_default      256 none
Jan 06 22:44:08 cmos_layout.bin                0x53dc0    cmos_layout      2120 none
Jan 06 22:44:08 fallback/postcar               0x54640    stage           31180 none
Jan 06 22:44:08 fallback/payload               0x5c080    simple elf    7714640 none
Jan 06 22:44:08 (empty)                        0x7b7800   null            71076 none
Jan 06 22:44:08 bootblock                      0x7c8dc0   bootblock       28672 none
Jan 06 22:44:08 
Jan 06 22:44:08 Validating final CBFS/IFD configuration...
Jan 06 22:44:08 ===================================================================
Jan 06 22:44:08 IFD vs CBFS Size Validation
Jan 06 22:44:08 ===================================================================
Jan 06 22:44:08 IFD BIOS Region: 0x00018000 - 0x007fffff
Jan 06 22:44:08 IFD BIOS Size:   0x7E8000 (8096 KiB)
Jan 06 22:44:08 CONFIG_CBFS_SIZE: 0x7E7FFF (8095 KiB)
Jan 06 22:44:08 
Jan 06 22:44:08 ✓ CONFIG_CBFS_SIZE fits within IFD BIOS region
Jan 06 22:44:08    Unused IFD capacity: 1 bytes (< 1 KiB)
Jan 06 22:44:08 
Jan 06 22:44:08 CBFS Free Space: 71076 bytes (69 KiB)
Jan 06 22:44:08 
Jan 06 22:44:08 ===================================================================
Jan 06 22:44:08 ✓ Validation complete
Jan 06 22:44:08 ===================================================================

Master currently has only 69 KiB for this board. We will try to improve on that on #1991 next

Copilot AI review requested due to automatic review settings January 5, 2026 03:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces comprehensive validation to ensure coreboot CBFS size matches the Intel Flash Descriptor (IFD) BIOS region, preventing misconfigurations that could result in firmware that cannot be flashed or boots incorrectly.

Key Changes:

  • New validation script (bin/validate_cbfs_ifd_fit.sh) that parses IFD files, compares CBFS size against BIOS region, and provides space usage statistics
  • Integration of validation into the coreboot build process at both configure and ROM generation stages
  • New Makefile targets (validate_cbfs_ifd and fix_cbfs_ifd) for manual validation and automatic configuration fixes

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
bin/validate_cbfs_ifd_fit.sh New 321-line bash script that validates CONFIG_CBFS_SIZE against IFD BIOS region, supports auto-fix mode, includes Intel 16 MiB decode window limit handling, and provides CBFS free space reporting
modules/coreboot Integrates validation into coreboot configure step (lines 165-173) and final ROM generation (lines 244-256), adds .PHONY marker to force ROM rebuilds
Makefile Adds informational hint for verbose builds when V flag is not set (lines 68-72) and two new targets for manual validation and auto-fix operations (lines 292-318)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/coreboot Outdated
Introduce validation to ensure coreboot CBFS size matches IFD BIOS region:

- Add bin/validate_cbfs_ifd_fit.sh: New script to validate CBFS size against
  Intel Flash Descriptor (IFD) BIOS region and provide space usage statistics
- Add Makefile targets: validate_cbfs_ifd and fix_cbfs_ifd for manual validation
  and automatic fixes
- Integrate validation into coreboot module build process to catch misconfigs
  at compile time
- Add validation to final ROM image generation step
- Add informational hint to Makefile when V=1 verbose flag is not set

This prevents shipping firmware with CBFS sizes that exceed the available
BIOS region, catching configuration errors early in the build process.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
@tlaurion tlaurion force-pushed the cbfs_ifd_validation-free_space_on_build branch from 6a89cef to 2b3a7bd Compare January 5, 2026 03:31
@tlaurion tlaurion requested a review from Copilot January 5, 2026 03:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
Comment thread Makefile
@tlaurion

This comment was marked as outdated.

@tlaurion

This comment was marked as outdated.

@tlaurion tlaurion force-pushed the cbfs_ifd_validation-free_space_on_build branch 2 times, most recently from 2df2833 to bbfe226 Compare January 5, 2026 20:50
@tlaurion tlaurion requested a review from Copilot January 5, 2026 20:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
Comment thread Makefile
Comment thread Makefile Outdated
Improve build performance by avoiding redundant GPG key injections:

- Add $(PUBKEY_ASC) as explicit dependency to trigger rebuilds when key changes
- Implement caching via .meta file storing SHA256 checksums of source ROM and GPG key
- Skip re-injection when both source and key haven't changed since last build
- Use shell variables for cleaner code and better maintainability

This reduces unnecessary re-injection operations during incremental builds,
improving build times when neither the ROM nor the GPG key has been modified.

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
@tlaurion tlaurion force-pushed the cbfs_ifd_validation-free_space_on_build branch from bbfe226 to cfa46bc Compare January 6, 2026 21:43
@tlaurion tlaurion requested a review from Copilot January 6, 2026 21:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

Makefile:960

  • There are excessive blank lines (4 consecutive blank lines) that should be reduced to maintain consistent spacing throughout the Makefile.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tlaurion tlaurion merged commit a44a0ab into linuxboot:master Jan 7, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants