diff mbox

[3/5] xscom: Harden indirect writes

Message ID 20170322025945.18182-3-mikey@neuling.org
State Superseded
Headers show

Commit Message

Michael Neuling March 22, 2017, 2:59 a.m. UTC
Indirect scoms can only set certain bits of data.  Ensure only these
are set when trying to write.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 hw/xscom.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Cédric Le Goater March 22, 2017, 1:38 p.m. UTC | #1
On 03/22/2017 03:59 AM, Michael Neuling wrote:
> Indirect scoms can only set certain bits of data.  Ensure only these
> are set when trying to write.
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
>  hw/xscom.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/xscom.c b/hw/xscom.c
> index 2f55f12855..1add658776 100644
> --- a/hw/xscom.c
> +++ b/hw/xscom.c
> @@ -369,6 +369,10 @@ static int xscom_indirect_write(uint32_t gcid, uint64_t pcb_addr, uint64_t val)
>  	if (proc_gen < proc_gen_p8)
>  		return OPAL_UNSUPPORTED;
> 
> +	/* Only 16 bit data with indirect */
> +	if (val & ~(XSCOM_ADDR_IND_ADDR))
> +		return OPAL_PARAMETER;

This is confusing. Shouldn't it be using XSCOM_ADDR_IND_DATA instead ?

Cheers,

C.

>  	/* Write indirect address & data */
>  	addr = pcb_addr & 0x7fffffff;
>  	data = pcb_addr & XSCOM_ADDR_IND_ADDR;
>
Michael Neuling March 23, 2017, 5:10 a.m. UTC | #2
> > +	/* Only 16 bit data with indirect */
> > +	if (val & ~(XSCOM_ADDR_IND_ADDR))
> > +		return OPAL_PARAMETER;
> 
> This is confusing. Shouldn't it be using XSCOM_ADDR_IND_DATA instead ?

Oops, yes, my bad....

Mikey
diff mbox

Patch

diff --git a/hw/xscom.c b/hw/xscom.c
index 2f55f12855..1add658776 100644
--- a/hw/xscom.c
+++ b/hw/xscom.c
@@ -369,6 +369,10 @@  static int xscom_indirect_write(uint32_t gcid, uint64_t pcb_addr, uint64_t val)
 	if (proc_gen < proc_gen_p8)
 		return OPAL_UNSUPPORTED;
 
+	/* Only 16 bit data with indirect */
+	if (val & ~(XSCOM_ADDR_IND_ADDR))
+		return OPAL_PARAMETER;
+
 	/* Write indirect address & data */
 	addr = pcb_addr & 0x7fffffff;
 	data = pcb_addr & XSCOM_ADDR_IND_ADDR;