Skip to contentSkip to conversation

ftgmac100: fix dblac write test

PATCH In review erik-smit 4 participants 5 messages Jun 28, 2020 – Jul 14, 2020

lore
Share & tools
lore

erik-smit

author
#0 lore raw

PATCH v2 1/1 ftgmac100: fix dblac write test

The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.

---
Changes since v1:

Changed %ld to HWADDR_PRIx to fix building on mingw

 hw/net/ftgmac100.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
hw/net/ftgmac100.c +8 -6
index 043ba61b86..b69e3dd14e 100644
@@ -810,16 +810,18 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
         s->phydata = value & 0xffff;
         break;
     case FTGMAC100_DBLAC: /* DMA Burst Length and Arbitration Control */
-        if (FTGMAC100_DBLAC_TXDES_SIZE(s->dblac) < sizeof(FTGMAC100Desc)) {
+        if (FTGMAC100_DBLAC_TXDES_SIZE(value) < sizeof(FTGMAC100Desc)) {
             qemu_log_mask(LOG_GUEST_ERROR,
-                          "%s: transmit descriptor too small : %d bytes\n",
-                          __func__, FTGMAC100_DBLAC_TXDES_SIZE(s->dblac));
+                          "%s: transmit descriptor too small: %" HWADDR_PRIx
+                          " bytes\n", __func__,
+                          FTGMAC100_DBLAC_TXDES_SIZE(value));
             break;
         }
-        if (FTGMAC100_DBLAC_RXDES_SIZE(s->dblac) < sizeof(FTGMAC100Desc)) {
+        if (FTGMAC100_DBLAC_RXDES_SIZE(value) < sizeof(FTGMAC100Desc)) {
             qemu_log_mask(LOG_GUEST_ERROR,
-                          "%s: receive descriptor too small : %d bytes\n",
-                          __func__, FTGMAC100_DBLAC_RXDES_SIZE(s->dblac));
+                          "%s: receive descriptor too small : %" HWADDR_PRIx
+                          " bytes\n", __func__,
+                          FTGMAC100_DBLAC_RXDES_SIZE(value));
             break;
         }
         s->dblac = value;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · erik-smit

The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.

---
Changes since v1:

Changed %ld to HWADDR_PRIx to fix building on mingw

Bit of a nitpick, but the type of the value argument is uint64_t, so shouldn't the result of the expression captured by FTGMAC100_DBLAC_TXDES_SIZE() and FTGMAC100_DBLAC_RXDES_SIZE() be printed with a straight PRIx64 rather than HWADDR_PRIx?

Otherwise the change seems sensible, so:

author
#2 lore raw

Hi Andrew,

Quoted 9 lines · Andrew Jeffery
Quoted 8 lines · erik-smit

The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.

---
Changes since v1:

Quoted 6 lines
Quoted 1 line

Changed %ld to HWADDR_PRIx to fix building on mingw

Bit of a nitpick, but the type of the value argument is uint64_t, so shouldn't the result of the expression captured by FTGMAC100_DBLAC_TXDES_SIZE() and FTGMAC100_DBLAC_RXDES_SIZE() be printed with a straight PRIx64 rather than HWADDR_PRIx?

You are correct. I didn't understand the meaning of the PRI macros and just grabbed the other PRI macro I saw getting used in the file.

Signature · 3 lines
Best regards,

Erik Smit
Reviewed-by
#3 lore raw
Quoted 14 lines · Erik Smit

Hi Andrew,

Quoted 11 lines · Andrew Jeffery
Quoted 9 lines · erik-smit

The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.

---
Changes since v1:

Changed %ld to HWADDR_PRIx to fix building on mingw

Quoted 7 lines
Quoted 4 lines

Bit of a nitpick, but the type of the value argument is uint64_t, so shouldn't the result of the expression captured by FTGMAC100_DBLAC_TXDES_SIZE() and FTGMAC100_DBLAC_RXDES_SIZE() be printed with a straight PRIx64 rather than HWADDR_PRIx?

You are correct. I didn't understand the meaning of the PRI macros and just grabbed the other PRI macro I saw getting used in the file.

With that fixed,

Thanks,

C.

#4 lore raw
Quoted 20 lines · Cédric Le Goater
Quoted 12 lines · Erik Smit

Hi Andrew,

Quoted 9 lines · Andrew Jeffery
Quoted 8 lines · erik-smit

The test of the write of the dblac register was testing the old value instead of the new value. This would accept the write of an invalid value but subsequently refuse any following valid writes.

---
Changes since v1:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Changed %ld to HWADDR_PRIx to fix building on mingw

Bit of a nitpick, but the type of the value argument is uint64_t, so shouldn't the result of the expression captured by FTGMAC100_DBLAC_TXDES_SIZE() and FTGMAC100_DBLAC_RXDES_SIZE() be printed with a straight PRIx64 rather than HWADDR_PRIx?

You are correct. I didn't understand the meaning of the PRI macros and just grabbed the other PRI macro I saw getting used in the file.

Quoted 7 lines

With that fixed,

Thanks,

C.

Applied by switching to use PRIx64.

Thanks