[Skiboot] [PATCH] phb4: Enforce root complex config space size of 2048

Benjamin Herrenschmidt benh at kernel.crashing.org
Sat May 6 02:05:29 AEST 2017


On Fri, 2017-05-05 at 16:51 +1000, Michael Neuling wrote:
> 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.
> 
> Signed-off-by: Michael Neuling <mikey at neuling.org>

Acked-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

> ---
>  hw/phb4.c           | 6 ++++++
>  include/phb4-regs.h | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/hw/phb4.c b/hw/phb4.c
> index 49d4a0f4c9..28bf6f75d7 100644
> --- a/hw/phb4.c
> +++ b/hw/phb4.c
> @@ -208,6 +208,9 @@ static int64_t phb4_rc_read(struct phb4 *p, uint32_t offset, uint8_t sz,
>  	uint32_t reg = offset & ~3;
>  	uint32_t oval;
>  
> +	if (reg >= PHB_RC_CONFIG_SIZE)
> +		return OPAL_PARAMETER;
> +
>  	/* Some registers are handled locally */
>  	switch (reg) {
>  		/* Bridge base/limit registers are cached here as HW
> @@ -257,6 +260,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_PARAMETER;
> +
>  	/* 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


More information about the Skiboot mailing list