hw/intc/arm_gicv3: Four simple bugfixes
cover hw/intc/arm_gicv3: Four simple bugfixes
This patchset fixes four bugs in our implementation of the GICv3. They're all fairly small fixes, largely typo/cut-n-paste errors...
thanks
-- PMM
Peter Maydell (4):
hw/intc/arm_gicv3: Fix decoding of ID register range hw/intc/arm_gicv3: GICD_TYPER.SecurityExtn is RAZ if GICD_CTLR.DS == 1 hw/intc/arm_gicv3: Fix write of ICH_VMCR_EL2.{VBPR0,VBPR1} hw/intc/arm_gicv3: Fix writes to ICC_CTLR_EL3
hw/intc/arm_gicv3_cpuif.c | 6 +++--- hw/intc/arm_gicv3_dist.c | 10 ++++++++-- hw/intc/arm_gicv3_redist.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/4 hw/intc/arm_gicv3: Fix decoding of ID register range
The GIC ID registers cover an area 0x30 bytes in size (12 registers, 4 bytes each). We were incorrectly decoding only the first 0x20 bytes.
--- hw/intc/arm_gicv3_dist.c | 2 +- hw/intc/arm_gicv3_redist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/intc/arm_gicv3_dist.c +1 -1
@@ -533,7 +533,7 @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, }return MEMTX_OK ; } - case GICD_IDREGS ... GICD_IDREGS + 0x1f: + case GICD_IDREGS ... GICD_IDREGS + 0x2f:/* ID registers */ *data =gicv3_idreg (offset -GICD_IDREGS );return MEMTX_OK ;
hw/intc/arm_gicv3_redist.c +1 -1
@@ -233,7 +233,7 @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, } *data = cs->gicr_nsacr;return MEMTX_OK ; - case GICR_IDREGS ... GICR_IDREGS + 0x1f: + case GICR_IDREGS ... GICR_IDREGS + 0x2f: *data =gicv3_idreg (offset -GICR_IDREGS );return MEMTX_OK ;default :
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH 1/4] hw/intc/arm_gicv3: Fix decoding of ID register range
Quoted 5 lines · Peter Maydell
The GIC ID registers cover an area
0x30bytes in size (12 registers, 4 bytes each). We were incorrectly decoding only the first0x20bytes.Signed-off-by Peter Maydell <[email protected]>
"8.1.13 Identification registers" OK.
Quoted 32 lines
--- hw/intc/arm_gicv3_dist.c | 2 +- hw/intc/arm_gicv3_redist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/intc/arm_gicv3_dist.c +1
-1@@ -533,7 +533,7 @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, }return MEMTX_OK ; } - case GICD_IDREGS ... GICD_IDREGS + 0x1f: + case GICD_IDREGS ... GICD_IDREGS + 0x2f:/* ID registers */ *data =gicv3_idreg (offset -GICD_IDREGS );return MEMTX_OK ;hw/intc/arm_gicv3_redist.c +1
-1@@ -233,7 +233,7 @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, } *data = cs->gicr_nsacr;return MEMTX_OK ; - case GICR_IDREGS ... GICR_IDREGS + 0x1f: + case GICR_IDREGS ... GICR_IDREGS + 0x2f: *data =gicv3_idreg (offset -GICR_IDREGS );return MEMTX_OK ;default :
Re: [Qemu-arm] [PATCH 1/4] hw/intc/arm_gicv3: Fix decoding of ID register range
In reply to Peter MaydellQuoted 29 lines · Peter Maydell
The GIC ID registers cover an area
0x30bytes in size (12 registers, 4 bytes each). We were incorrectly decoding only the first0x20bytes.Signed-off-by Peter Maydell <[email protected]>--- hw/intc/arm_gicv3_dist.c | 2 +- hw/intc/arm_gicv3_redist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)hw/intc/arm_gicv3_dist.c +1
-1@@ -533,7 +533,7 @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, }return MEMTX_OK ; } - case GICD_IDREGS ... GICD_IDREGS + 0x1f: + case GICD_IDREGS ... GICD_IDREGS + 0x2f:/* ID registers */ *data =gicv3_idreg (offset -GICD_IDREGS );return MEMTX_OK ;hw/intc/arm_gicv3_redist.c +0
-0
hw/intc/arm_gicv3_redist.c static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, · line 239
Quoted 8 lines
hw/intc/arm_gicv3_redist.c +1
-1@@ -233,7 +233,7 @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, } *data = cs->gicr_nsacr;return MEMTX_OK ; - case GICR_IDREGS ... GICR_IDREGS + 0x1f: + case GICR_IDREGS ... GICR_IDREGS + 0x2f: *data =gicv3_idreg (offset -GICR_IDREGS );return MEMTX_OK ;default :
Just noticed that I forgot to also update the case statements in the *writel functions :-(
thanks
-- PMM
PATCH 2/4 hw/intc/arm_gicv3: GICD_TYPER.SecurityExtn is RAZ if GICD_CTLR.DS == 1
In reply to Peter MaydellThe GICv3 specification says that the GICD_TYPER.SecurityExtn bit is RAZ if GICD_CTLR.DS is 1. We were incorrectly making it RAZ if the security extension is unsupported. "Security extension unsupported" always implies GICD_CTLR.DS == 1, but the guest can also set DS on a GIC which does support the security extension. Fix the condition to correctly check the GICD_CTLR.DS bit.
--- hw/intc/arm_gicv3_dist.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/intc/arm_gicv3_dist.c +7 -1
@@ -378,8 +378,14 @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset,* ITLinesNumber == (num external irqs / 32) - 1 */ int itlinesnumber = ((s->num_irq -GIC_INTERNAL ) /32 ) -1 ; +/* +* SecurityExtn must be RAZ if GICD_CTLR.DS == 1, and +* "security extensions not supported" always implies DS == 1, +* so we only need to check the DS bit. +*/ +bool sec_extn = !(s->gicd_ctlr &GICD_CTLR_DS ); - *data = (1 <<25 ) | (1 <<24 ) | (s->security_extn <<10 ) | + *data = (1 <<25 ) | (1 <<24 ) | (sec_extn <<10 ) | (0xf <<19 ) | itlinesnumber;return MEMTX_OK ; }
Signature · 1 line
2.20.1
PATCH 3/4 hw/intc/arm_gicv3: Fix write of ICH_VMCR_EL2.{VBPR0, VBPR1}
In reply to Peter MaydellIn ich_vmcr_write() we enforce "writes of BPR fields to less than their minimum sets them to the minimum" by doing a "read vbpr and write it back" operation. A typo here meant that we weren't handling writes to these fields correctly, because we were reading from VBPR0 but writing to VBPR1.
--- hw/intc/arm_gicv3_cpuif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gicv3_cpuif.c +1 -1
@@ -2366,7 +2366,7 @@ static void ich_vmcr_write(CPUARMState *env, const ARMCPRegInfo *ri,/* Enforce "writing BPRs to less than minimum sets them to the minimum" * by reading and writing back the fields. */ -write_vbpr (cs,GICV3_G1 ,read_vbpr (cs,GICV3_G0 )); +write_vbpr (cs,GICV3_G0 ,read_vbpr (cs,GICV3_G0 ));write_vbpr (cs,GICV3_G1 ,read_vbpr (cs,GICV3_G1 ));gicv3_cpuif_virt_update (cs);
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH 3/4] hw/intc/arm_gicv3: Fix write of ICH_VMCR_EL2.{VBPR0, VBPR1}
Quoted 7 lines · Peter Maydell
In
ich_vmcr_write()we enforce "writes of BPR fields to less than their minimum sets them to the minimum" by doing a "read vbpr and write it back" operation. A typo here meant that we weren't handling writes to these fields correctly, because we were reading from VBPR0 but writing to VBPR1.Signed-off-by Peter Maydell <[email protected]>
Quoted 18 lines
--- hw/intc/arm_gicv3_cpuif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/intc/arm_gicv3_cpuif.c +1
-1@@ -2366,7 +2366,7 @@ static void ich_vmcr_write(CPUARMState *env, const ARMCPRegInfo *ri,/* Enforce "writing BPRs to less than minimum sets them to the minimum" * by reading and writing back the fields. */ -write_vbpr (cs,GICV3_G1 ,read_vbpr (cs,GICV3_G0 )); +write_vbpr (cs,GICV3_G0 ,read_vbpr (cs,GICV3_G0 ));write_vbpr (cs,GICV3_G1 ,read_vbpr (cs,GICV3_G1 ));gicv3_cpuif_virt_update (cs);
PATCH 4/4 hw/intc/arm_gicv3: Fix writes to ICC_CTLR_EL3
In reply to Peter MaydellThe ICC_CTLR_EL3 register includes some bits which are aliases of bits in the ICC_CTLR_EL1(S) and (NS) registers. QEMU chooses to keep those bits in the cs->icc_ctlr_el1[] struct fields. Unfortunately a missing '~' in the code to update the bits in those fields meant that writing to ICC_CTLR_EL3 would corrupt the ICC_CLTR_EL1 register values.
--- hw/intc/arm_gicv3_cpuif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/intc/arm_gicv3_cpuif.c +2 -2
@@ -1856,7 +1856,7 @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri,trace_gicv3_icc_ctlr_el3_write (gicv3_redist_affid (cs), value);/* *_EL1NS and *_EL1S bits are aliases into the ICC_CTLR_EL1 bits. */ - cs->icc_ctlr_el1[GICV3_NS ] &= (ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE ); + cs->icc_ctlr_el1[GICV3_NS ] &= ~(ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE );if (value &ICC_CTLR_EL3_EOIMODE_EL1NS ) { cs->icc_ctlr_el1[GICV3_NS ] |=ICC_CTLR_EL1_EOIMODE ; }
@@ -1864,7 +1864,7 @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, cs->icc_ctlr_el1[GICV3_NS ] |=ICC_CTLR_EL1_CBPR ; } - cs->icc_ctlr_el1[GICV3_S ] &= (ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE ); + cs->icc_ctlr_el1[GICV3_S ] &= ~(ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE );if (value &ICC_CTLR_EL3_EOIMODE_EL1S ) { cs->icc_ctlr_el1[GICV3_S ] |=ICC_CTLR_EL1_EOIMODE ; }
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH 4/4] hw/intc/arm_gicv3: Fix writes to ICC_CTLR_EL3
Hi Peter,
Quoted 6 lines · Peter Maydell
The
ICC_CTLR_EL3register includes some bits which are aliases of bits in theICC_CTLR_EL1(S)and (NS) registers. QEMU chooses to keep those bits in the cs->icc_ctlr_el1[] struct fields. Unfortunately a missing '~' in the code to update the bits in those fields meant that writing toICC_CTLR_EL3would corrupt theICC_CLTR_EL1register values.
How did you notice? Simply reviewing?
Quoted 2 lines
Signed-off-by Peter Maydell <[email protected]>
Quoted 27 lines
--- hw/intc/arm_gicv3_cpuif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/intc/arm_gicv3_cpuif.c +2
-2@@ -1856,7 +1856,7 @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri,trace_gicv3_icc_ctlr_el3_write (gicv3_redist_affid (cs), value);/* *_EL1NS and *_EL1S bits are aliases into the ICC_CTLR_EL1 bits. */ - cs->icc_ctlr_el1[GICV3_NS ] &= (ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE ); + cs->icc_ctlr_el1[GICV3_NS ] &= ~(ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE );if (value &ICC_CTLR_EL3_EOIMODE_EL1NS ) { cs->icc_ctlr_el1[GICV3_NS ] |=ICC_CTLR_EL1_EOIMODE ; }@@ -1864,7 +1864,7 @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, cs->icc_ctlr_el1[GICV3_NS ] |=ICC_CTLR_EL1_CBPR ; } - cs->icc_ctlr_el1[GICV3_S ] &= (ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE ); + cs->icc_ctlr_el1[GICV3_S ] &= ~(ICC_CTLR_EL1_CBPR |ICC_CTLR_EL1_EOIMODE );if (value &ICC_CTLR_EL3_EOIMODE_EL1S ) { cs->icc_ctlr_el1[GICV3_S ] |=ICC_CTLR_EL1_EOIMODE ; }
Quoted 4 lines · Peter Maydell
This patchset fixes four bugs in our implementation of the GICv3. They're all fairly small fixes, largely typo/cut-n-paste errors...
Quoted 8 lines
thanks
-- PMMPeter Maydell (4):
hw/intc/arm_gicv3: Fix decoding of ID register range hw/intc/arm_gicv3: GICD_TYPER.SecurityExtn is RAZ if GICD_CTLR.DS == 1 hw/intc/arm_gicv3: Fix write of ICH_VMCR_EL2.{VBPR0,VBPR1} hw/intc/arm_gicv3: Fix writes toICC_CTLR_EL3
I put patches 3 and 4 into the arm pullreq; will respin with a fixed patch 1 plus this patch 2.
thanks
-- PMM