]> Git Repo - qemu.git/commitdiff
hw/intc/arm_gicv3: fix an extra left-shift when reading IPRIORITYR
authorAmol Surati <[email protected]>
Fri, 22 Jun 2018 12:28:34 +0000 (13:28 +0100)
committerPeter Maydell <[email protected]>
Fri, 22 Jun 2018 12:28:34 +0000 (13:28 +0100)
When either GICD_IPRIORITYR or GICR_IPRIORITYR is read as a 32-bit
register, the post left-shift operator in the for loop causes an
extra shift after the least significant byte has been placed.

The 32-bit value actually returned is therefore the expected value
shifted left by 8 bits.

Signed-off-by: Amol Surati <[email protected]>
Message-id: 20180614054857[email protected]
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
hw/intc/arm_gicv3_dist.c
hw/intc/arm_gicv3_redist.c

index 93fe936862a1f94260607b5449cea0e13747b46d..53c55c5729102f90c0976d43bdab8aaea808f259 100644 (file)
@@ -441,7 +441,8 @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset,
         int i, irq = offset - GICD_IPRIORITYR;
         uint32_t value = 0;
 
-        for (i = irq + 3; i >= irq; i--, value <<= 8) {
+        for (i = irq + 3; i >= irq; i--) {
+            value <<= 8;
             value |= gicd_read_ipriorityr(s, attrs, i);
         }
         *data = value;
index 8a8684d76ede2e741a50f8336aef92f2192c96bf..3b0ba6de1ab5ead8450ecddb633cbc02daba5c91 100644 (file)
@@ -192,7 +192,8 @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset,
         int i, irq = offset - GICR_IPRIORITYR;
         uint32_t value = 0;
 
-        for (i = irq + 3; i >= irq; i--, value <<= 8) {
+        for (i = irq + 3; i >= irq; i--) {
+            value <<= 8;
             value |= gicr_read_ipriorityr(cs, attrs, i);
         }
         *data = value;
This page took 0.028973 seconds and 4 git commands to generate.