Edward O'Callaghan has uploaded this change for review.

View Change

flashrom.c: Fix 4BA for non SPI masters

Chips that indicate they support 4BA in their feature flags
break horribly as the current 4BA support assumes a SPI
master bus in spi_master_no_4ba_modes() by dereferencing
flash->mst.spi in the mst union type.

BUG=b:178419441,b:177252170
TEST=<needed>

Change-Id: Ieb59d9d69d5b4f5c1e5aac424898e94c9fe3790b
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M flashrom.c
M programmer.h
2 files changed, 13 insertions(+), 8 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/45/50245/1
diff --git a/flashrom.c b/flashrom.c
index c89abad..c1438c9 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -2287,12 +2287,14 @@
flash->chip_restore_fn_count = 0;

/* Be careful about 4BA chips and broken masters */
- if (flash->chip->total_size > 16 * 1024 && spi_master_no_4ba_modes(flash)) {
- /* If we can't use native instructions, bail out */
- if ((flash->chip->feature_bits & FEATURE_4BA_NATIVE) != FEATURE_4BA_NATIVE
- || !spi_master_4ba(flash)) {
- msg_cerr("Programmer doesn't support this chip. Aborting.\n");
- return 1;
+ if (flash->chip->total_size > 16 * 1024 && spi_bus_no_4ba_modes(flash)) {
+ if (spi_master_no_4ba_modes(flash)) {
+ /* If we can't use native instructions, bail out */
+ if ((flash->chip->feature_bits & FEATURE_4BA_NATIVE) != FEATURE_4BA_NATIVE
+ || !spi_master_4ba(flash)) {
+ msg_cerr("Programmer doesn't support this chip. Aborting.\n");
+ return 1;
+ }
}
}

diff --git a/programmer.h b/programmer.h
index 29a100b..b575a72 100644
--- a/programmer.h
+++ b/programmer.h
@@ -820,8 +820,11 @@
}
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;
+ return flash->mst->spi.features & SPI_MASTER_NO_4BA_MODES;
+}
+static inline bool spi_bus_no_4ba_modes(const struct flashctx *const flash)
+{
+ return flash->mst->buses_supported & BUS_SPI;
}

/* usbdev.c */

To view, visit change 50245. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ieb59d9d69d5b4f5c1e5aac424898e94c9fe3790b
Gerrit-Change-Number: 50245
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange