aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2017-05-08 17:26:30 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-05-10 16:58:18 +1000
commit4fbdcf6bd10b1c93977e789a42bb54b98458acd6 (patch)
tree76d43e1108c5da0c7598195d5c66ebbbbedaf4a8
parent8b1df791543bd0c390df01463a1601d4b5eb67ea (diff)
downloadskiboot-4fbdcf6bd10b1c93977e789a42bb54b98458acd6.zip
skiboot-4fbdcf6bd10b1c93977e789a42bb54b98458acd6.tar.gz
skiboot-4fbdcf6bd10b1c93977e789a42bb54b98458acd6.tar.bz2
phb4: Enforce root complex config space size of 2048
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@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--hw/phb4.c9
-rw-r--r--include/phb4-regs.h1
2 files changed, 8 insertions, 2 deletions
diff --git a/hw/phb4.c b/hw/phb4.c
index 41468c9..9019c6b 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 5480949..92bee88 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