[Skiboot] [PATCH v2] phb4: Enforce root complex config space size of 2048
Michael Neuling
mikey at neuling.org
Mon May 8 17:26:30 AEST 2017
The root complex config space size on PHB4 is 2048. This patch sets
that size and enforces it when trying to read/write the config space
in the root complex.
Without this someone reading the config space via /sysfs in linux will
cause an EEH on the PHB.
If too high, reads returns 1s and writes are silently dropped.
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
hw/phb4.c | 9 +++++++--
include/phb4-regs.h | 1 +
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/phb4.c b/hw/phb4.c
index 41468c98c1..9019c6bf9b 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -229,8 +229,10 @@ static int64_t phb4_rc_read(struct phb4 *p, uint32_t offset, uint8_t sz,
oval = p->rc_cache[(reg - 0x20) >> 2];
break;
default:
- /* XXX Add ASB support ? */
- oval = in_le32(p->regs + PHB_RC_CONFIG_BASE + reg);
+ oval = 0xffffffff; /* default if offset too big */
+ if (reg < PHB_RC_CONFIG_SIZE)
+ /* XXX Add ASB support ? */
+ oval = in_le32(p->regs + PHB_RC_CONFIG_BASE + reg);
}
switch (sz) {
case 1:
@@ -257,6 +259,9 @@ static int64_t phb4_rc_write(struct phb4 *p, uint32_t offset, uint8_t sz,
uint32_t old, mask, shift;
int64_t rc;
+ if (reg > PHB_RC_CONFIG_SIZE)
+ return OPAL_SUCCESS;
+
/* If size isn't 4-bytes, do a RMW cycle
*
* XXX TODO: Filter out registers that do write-1-to-clear !!!
diff --git a/include/phb4-regs.h b/include/phb4-regs.h
index 548094907a..92bee88f6b 100644
--- a/include/phb4-regs.h
+++ b/include/phb4-regs.h
@@ -235,6 +235,7 @@
// FIXME add more here
#define PHB_RC_CONFIG_BASE 0x1000
+#define PHB_RC_CONFIG_SIZE 0x800
/* PHB4 REGB registers */
#define PHB_PBL_CONTROL 0x1800
--
2.11.0
More information about the Skiboot
mailing list