Nico Huber has uploaded this change for review.

View Change

ichspi: "Fix" access permission reporting for regions > 7

Can't find bits that tell us the actual permissions in charge. So report
them as unknown.

Original-Change-Id: Ib73f95e0348f5c6d89988e3ea3529af0ec3b23a6
Original-Reviewed-on: https://review.coreboot.org/21106
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: David Hendricks <david.hendricks@gmail.com>

Change-Id: I59cce146c96e3c1f33b51265084c1352602ea5ac
Signed-off-by: Nico Huber <nico.huber@secunet.com>
---
M ichspi.c
1 file changed, 18 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/18/21818/1
diff --git a/ichspi.c b/ichspi.c
index 5f3e394..9ee8044 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1543,6 +1543,7 @@
static const char *const access_names[4] = {
"locked", "read-only", "write-only", "read-write"
};
+ const int rwperms_unknown = ARRAY_SIZE(access_names);
static const char *const region_names[5] = {
"Flash Descriptor", "BIOS", "Management Engine",
"Gigabit Ethernet", "Platform Data"
@@ -1550,10 +1551,20 @@
const char *const region_name = i < ARRAY_SIZE(region_names) ? region_names[i] : "unknown";

uint32_t base, limit;
- int rwperms = (((ICH_BRWA(frap) >> i) & 1) << 1) |
- (((ICH_BRRA(frap) >> i) & 1) << 0);
+ int rwperms;
int offset = ICH9_REG_FREG0 + i * 4;
uint32_t freg = mmio_readl(ich_spibar + offset);
+
+ if (i < 8) {
+ rwperms = (((ICH_BRWA(frap) >> i) & 1) << 1) |
+ (((ICH_BRRA(frap) >> i) & 1) << 0);
+ } else {
+ /* Datasheets don't define any access bits for regions > 7. We
+ can't rely on the actual descriptor settings either as there
+ are several overrides for them (those by other masters are
+ not even readable by us, *shrug*). */
+ rwperms = rwperms_unknown;
+ }

base = ICH_FREG_BASE(freg);
limit = ICH_FREG_LIMIT(freg);
@@ -1569,6 +1580,11 @@
region_name, base, limit, access_names[rwperms]);
return 0;
}
+ if (rwperms == rwperms_unknown) {
+ msg_pdbg("FREG%i: %s region (0x%08x-0x%08x) has unknown permissions.\n",
+ i, region_name, base, limit);
+ return 0;
+ }

msg_pwarn("FREG%i: Warning: %s region (0x%08x-0x%08x) is %s.\n", i,
region_name, base, limit, access_names[rwperms]);

To view, visit change 21818. To unsubscribe, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: stable
Gerrit-MessageType: newchange
Gerrit-Change-Id: I59cce146c96e3c1f33b51265084c1352602ea5ac
Gerrit-Change-Number: 21818
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>