Conversation
On Intel PCH platforms with flash chips larger than 16MB, only the top
16MB of the BIOS region is mapped in the fixed decode window at
0xFF000000. The remaining lower portion is accessible through a second
"extended BIOS window" (EXT_BIOS_WIN) programmed by coreboot into the
SPI controller's PCI config space:
SPI_BIOS_CONTROL (PCI 0xdc): bit 27 = EXT_BIOS_ENABLE
bits 12-26 = EXT_BIOS_LIMIT (size)
SPI_CFG_BAR1 (PCI 0xe0): host base of the 32MB EXT_BIOS_WIN
When cbfs runs without -o (live flash), it now calls try_ext_bios_win()
which reads these registers from /sys/bus/pci/devices/0000:00:1f.5/config.
If the extended window is active, both memory windows are mapped and
assembled into a contiguous ROM buffer; FMAP+CBFS search is then used
to locate the CBFS master header within the full image. Falls back to
the original 16MB delta-pointer path when EXT_BIOS_WIN is absent.
Fixes: osresearch/flashtools#10
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
The cbfs tool now natively supports >16MB BIOS regions on Intel ADL+ platforms by reading the extended BIOS decode window (EXT_BIOS_WIN) directly from the SPI controller's PCI config space, via the patch in patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch. Comment out CONFIG_CBFS_VIA_FLASHPROG=y on all four MSI boards (msi_z790p_ddr5, UNTESTED_msi_z790p_ddr4, UNTESTED_msi_z690a_ddr5, UNTESTED_msi_z690a_ddr4) since the flashprog-based workaround is no longer needed. Signed-off-by: Thierry Laurion <insurgo@riseup.net>
There was a problem hiding this comment.
Pull request overview
This PR updates the flashtools cbfs utility to support extracting CBFS contents from Intel systems with BIOS flash sizes larger than 16MiB by using the Intel PCH extended BIOS decode window (EXT_BIOS_WIN), and disables the existing flashprog-based workaround in affected board configs.
Changes:
- Add EXT_BIOS_WIN detection/reading logic to the flashtools
cbfs.c(via a build-applied patch) to assemble a full ROM image for >16MiB flash. - Prefer EXT_BIOS_WIN CBFS discovery for “live flash” reads, falling back to the legacy delta-pointer method when not available.
- Comment out
CONFIG_CBFS_VIA_FLASHPROGfor MSI Z690/Z790 board configs now that native support is intended.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch | Implements Intel EXT_BIOS_WIN-based ROM assembly and CBFS header lookup for >16MiB flash. |
| boards/msi_z790p_ddr5/msi_z790p_ddr5.config | Disables flashprog CBFS workaround and documents native EXT_BIOS_WIN approach. |
| boards/UNTESTED_msi_z790p_ddr4/UNTESTED_msi_z790p_ddr4.config | Same workaround disablement/documentation for DDR4 variant. |
| boards/UNTESTED_msi_z690a_ddr5/UNTESTED_msi_z690a_ddr5.config | Same workaround disablement/documentation for Z690-A DDR5. |
| boards/UNTESTED_msi_z690a_ddr4/UNTESTED_msi_z690a_ddr4.config | Same workaround disablement/documentation for Z690-A DDR4. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| + if (ext_rom != NULL) { | ||
| + /* Full ROM already in memory from extended BIOS window */ | ||
| + rom = ext_rom; | ||
| + /* size already set when ext_rom was assembled */ |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Thierry Laurion <insurgo@riseup.net>
There was a problem hiding this comment.
Pull request overview
Adds an experimental workaround to let the flashtools cbfs utility access CBFS contents on >16MiB SPI flash by assembling the full ROM from Intel’s fixed 16MiB decode window plus the EXT_BIOS_WIN mapping, and updates several MSI board configs to reflect the intended removal of the flashprog-based workaround.
Changes:
- Extend flashtools
cbfs.cto detect and use Intel PCH EXT_BIOS_WIN to read full ROM contents (>16MiB). - Adjust live-flash CBFS header discovery to prefer the assembled “full ROM” buffer when EXT_BIOS_WIN is available.
- Update MSI Z690/Z790 board configs to comment out the prior
CONFIG_CBFS_VIA_FLASHPROGworkaround and add explanatory notes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch | Implements EXT_BIOS_WIN ROM assembly + CBFS header lookup changes in flashtools cbfs.c. |
| boards/msi_z790p_ddr5/msi_z790p_ddr5.config | Updates comments / disables flashprog workaround flag. |
| boards/UNTESTED_msi_z790p_ddr4/UNTESTED_msi_z790p_ddr4.config | Updates comments / disables flashprog workaround flag. |
| boards/UNTESTED_msi_z690a_ddr5/UNTESTED_msi_z690a_ddr5.config | Updates comments / disables flashprog workaround flag. |
| boards/UNTESTED_msi_z690a_ddr4/UNTESTED_msi_z690a_ddr4.config | Updates comments / disables flashprog workaround flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| + uint64_t ext_size = 0; | ||
| + ext_rom = try_ext_bios_win(&ext_size); | ||
| + if (ext_rom != NULL) { | ||
| + int64_t offset = find_cbfs("live flash", | ||
| + ext_rom, ext_size); | ||
| + if (offset < 0) { | ||
| + free(ext_rom); | ||
| + return EXIT_FAILURE; | ||
| + } | ||
| + size = ext_size; |
| export CONFIG_CBFS_VIA_FLASHPROG=y | ||
| # cbfs now supports > 16MiB BIOS regions natively via Intel EXT_BIOS_WIN | ||
| # (see patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch) | ||
| # export CONFIG_CBFS_VIA_FLASHPROG=y |
| export CONFIG_CBFS_VIA_FLASHPROG=y | ||
| # cbfs now supports > 16MiB BIOS regions natively via Intel EXT_BIOS_WIN | ||
| # (see patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch) | ||
| # export CONFIG_CBFS_VIA_FLASHPROG=y |
| export CONFIG_CBFS_VIA_FLASHPROG=y | ||
| # cbfs now supports > 16MiB BIOS regions natively via Intel EXT_BIOS_WIN | ||
| # (see patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch) | ||
| # export CONFIG_CBFS_VIA_FLASHPROG=y |
| export CONFIG_CBFS_VIA_FLASHPROG=y | ||
| # cbfs now supports > 16MiB BIOS regions natively via Intel EXT_BIOS_WIN | ||
| # (see patches/flashtools-d1e6f12568cb23387144a4b7a6535fe1bc1e79b1.patch) | ||
| # export CONFIG_CBFS_VIA_FLASHPROG=y |
| + void *ext = map_physical(ext_flash_host, ext_size); | ||
| + if (!ext) { | ||
| + fprintf(stderr, | ||
| + "Failed to map extended BIOS window at 0x%016llx\n", | ||
| + (unsigned long long)ext_flash_host); | ||
| + munmap(fixed, FIXED_BIOS_WIN_SIZE); | ||
| + free(rom); | ||
| + return NULL; |
| + munmap(fixed, FIXED_BIOS_WIN_SIZE); | ||
| + free(rom); | ||
| + return NULL; | ||
| + } | ||
| + memcpy(rom, ext, ext_size); | ||
| + unmap_physical(ext, ext_size); | ||
| + | ||
| + /* Mappings are no longer needed after copying into the ROM buffer. */ | ||
| + munmap(ext, ext_size); | ||
| + munmap(fixed, FIXED_BIOS_WIN_SIZE); | ||
| + |
|
Tried a couple more things but everything I do adds a 200s delay with cbfs calls in cbfs-init for other platforms. Flashprog still better option from regression perspective only. Not good yet. |
@Tonux599 this is Poc to be tested and improved so flashprog is not involved early at boot to extract cbfs content on 16+
This is half-half Claude code generated, so deal with this accordingly.
Might fix osresearch/flashtools#10 or not extract your keyring+trustdb+config/user override. In such case, just flash back current rom and all shoul be good, do not seal new secret just revert.
Let me know.
As of now, as a patch and when worked around, will do fork and and move modules/flashtools to tlaurion and do pr upstream to osresearch for merge.