diff options
author | Edward O'Callaghan <quasisec@google.com> | 2022-12-25 11:06:10 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2023-01-13 11:18:54 +0000 |
commit | c1fb4bd9fd70d59eaeec41add5d449da9347f9fa (patch) | |
tree | 8605fbcbc357beb9b134c7b86ddad84586997e61 /include | |
parent | e4c51439ac82a0e29186afd1ed44fd51bdc1067a (diff) | |
download | flashrom-c1fb4bd9fd70d59eaeec41add5d449da9347f9fa.tar.gz flashrom-c1fb4bd9fd70d59eaeec41add5d449da9347f9fa.tar.bz2 flashrom-c1fb4bd9fd70d59eaeec41add5d449da9347f9fa.zip |
programmer.h: Guard against sending spi commands on non-spi mst
Validate (flash->chip->bustype == BUS_SPI) as ich copies the
chip flags in the opaque master and tries incorrectly
to issue 4BA commands which results in failure.
The issue was detected only in the case of chips >16MB, in
this case 'W25Q256FV' that has the feature bits:
```
.feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_4BA_ENTER_WREN |
FEATURE_4BA_EAR_C5C8 | FEATURE_4BA_READ | FEATURE_4BA_FAST_READ |
FEATURE_WRSR2,
```
The regression was noticed from,
commit 0741727925b841c2479b993204ce58c5eb75185a ichspi.c: Read chip ID and use it to populate `flash->chip`
TEST=In the case of 'W25Q256FV' on TigerLake.
Change-Id: I7cce4f9c032d33c01bf616e27a50b9727a40fe1b
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/71269
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathon Hall <jonathon.hall@puri.sm>
Reviewed-by: Sam McNally <sammc@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/programmer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/programmer.h b/include/programmer.h index 281a4f69..ad3c5022 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -513,6 +513,12 @@ static inline bool spi_master_no_4ba_modes(const struct flashctx *const flash) return flash->mst->buses_supported & BUS_SPI && flash->mst->spi.features & SPI_MASTER_NO_4BA_MODES; } +/* spi_chip feature checks */ +static inline bool spi_chip_4ba(const struct flashctx *const flash) +{ + return flash->chip->bustype == BUS_SPI && + (flash->chip->feature_bits & (FEATURE_4BA_ENTER | FEATURE_4BA_ENTER_WREN | FEATURE_4BA_ENTER_EAR7)); +} /* usbdev.c */ struct libusb_device_handle; |