Skip regions locked via flash descriptor for Intel platforms

This patch will prevent flashrom from attempting to read / erase /
write forbidden regions. Instead, it will "fake it". When a read
is performed on a write-only region, the gaps will return as 0xff
bytes. Erase/write operations performed on read-only regions will
be ignored.

Hopefully this approach can be extended to gracefully handle normal
SPI ROM block protect schemes.

1. This does not (yet) deal with region boundaries that are unaligned
   to block boundaries. For example, if region 0x1800-0x3000 are
   write-protected, flashrom may still erase an entire 4K block
   ranging from 0x1000 to 0x1fff and will fail to write valid data to
2. Verification is not entirely truthful. For one, it cannot verify
   regions which are unreadable (e.g. ME region). Also, differences
   between user-provided file and ROM content in read-only regions
   will cause annoying problems because it will appear inconsistent.

TEST=Tested on Stumpy with read-only descriptor and locked ME region

Change-Id: I004cc9de15d115368261efbb4835622aedfadea0
Reviewed-by: Stefan Reinauer <>
Tested-by: David Hendricks <>
7 files changed