hw/intc/arm_gicv3: Some simple bugfixes
v2 cover hw/intc/arm_gicv3: Some simple bugfixes
This patchset fixes a couple of simple bugs in our GICv3 implementation.
Changes since v1:
* patches 3 and 4 from the old patchset are now in master
* patch 1 now covers both the read and write functions
I've also just noticed (via grep for IDREGS) that we made the same decode mistake in the SMMUv3. I'll send that out as a separate patch.
thanks
-- PMM
Peter Maydell (2):
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_dist.c | 12 +++++++++--- hw/intc/arm_gicv3_redist.c | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 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 | 4 ++-- hw/intc/arm_gicv3_redist.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
hw/intc/arm_gicv3_dist.c +2 -2
@@ -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 ;
@@ -744,7 +744,7 @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset,gicd_write_irouter (s, attrs, irq, r);return MEMTX_OK ; } - case GICD_IDREGS ... GICD_IDREGS + 0x1f: + case GICD_IDREGS ... GICD_IDREGS + 0x2f:case GICD_TYPER :case GICD_IIDR :/* RO registers, ignore the write */
hw/intc/arm_gicv3_redist.c +2 -2
@@ -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 :
@@ -363,7 +363,7 @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset,return MEMTX_OK ;case GICR_IIDR :case GICR_TYPER : - case GICR_IDREGS ... GICR_IDREGS + 0x1f: + case GICR_IDREGS ... GICR_IDREGS + 0x2f:/* RO registers, ignore the write */ qemu_log_mask (LOG_GUEST_ERROR , "%s: invalid guest write to RO register at offset "
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH v2 1/2] hw/intc/arm_gicv3: Fix decoding of ID register range
Quoted 47 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 | 4 ++-- hw/intc/arm_gicv3_redist.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)hw/intc/arm_gicv3_dist.c +2
-2@@ -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 ;@@ -744,7 +744,7 @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset,gicd_write_irouter (s, attrs, irq, r);return MEMTX_OK ; } - case GICD_IDREGS ... GICD_IDREGS + 0x1f: + case GICD_IDREGS ... GICD_IDREGS + 0x2f:case GICD_TYPER :case GICD_IIDR :/* RO registers, ignore the write */ 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 :
hw/intc/arm_gicv3_redist.c static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, · line 369
Quoted 8 lines
hw/intc/arm_gicv3_redist.c +1
-1@@ -363,7 +363,7 @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset,return MEMTX_OK ;case GICR_IIDR :case GICR_TYPER : - case GICR_IDREGS ... GICR_IDREGS + 0x1f: + case GICR_IDREGS ... GICR_IDREGS + 0x2f:/* RO registers, ignore the write */ qemu_log_mask (LOG_GUEST_ERROR , "%s: invalid guest write to RO register at offset "
PATCH v2 2/2 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
Re: [Qemu-arm] [PATCH v2 2/2] hw/intc/arm_gicv3: GICD_TYPER.SecurityExtn is RAZ if GICD_CTLR.DS == 1
Ping for code review, please?
thanks
-- PMM
Quoted 36 lines · Peter Maydell
The 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.
Signed-off-by Peter Maydell <[email protected]>--- hw/intc/arm_gicv3_dist.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/intc/arm_gicv3_dist.c +7
-2@@ -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 ; } --2.20.1