diff mbox series

[RFC,2/3] hw/net/tulip: Log descriptor overflows

Message ID 20200423231644.15786-3-f4bug@amsat.org
State New
Headers show
Series hw/net/tulip: Fix LP#1874539 | expand

Commit Message

Philippe Mathieu-Daudé April 23, 2020, 11:16 p.m. UTC
Log with GUEST_ERROR what the guest is doing wrong.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/net/tulip.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index 1295f51d07..470f635acb 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -172,6 +172,11 @@  static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
         }
 
         if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "%s: descriptor overflow "
+                          "(ofs: %u, len:%d, size:%zu)\n",
+                          __func__, s->rx_frame_len, len,
+                          sizeof(s->rx_frame));
             return;
         }
         pci_dma_write(&s->dev, desc->buf_addr1, s->rx_frame +
@@ -187,6 +192,11 @@  static void tulip_copy_rx_bytes(TULIPState *s, struct tulip_descriptor *desc)
         }
 
         if (s->rx_frame_len + len > sizeof(s->rx_frame)) {
+            qemu_log_mask(LOG_GUEST_ERROR,
+                          "%s: descriptor overflow "
+                          "(ofs: %u, len:%d, size:%zu)\n",
+                          __func__, s->rx_frame_len, len,
+                          sizeof(s->rx_frame));
             return;
         }
         pci_dma_write(&s->dev, desc->buf_addr2, s->rx_frame +
@@ -584,6 +594,9 @@  static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
     int len2 = (desc->control >> TDES1_BUF2_SIZE_SHIFT) & TDES1_BUF2_SIZE_MASK;
 
     if (s->tx_frame_len + len1 > sizeof(s->tx_frame)) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "%s: descriptor overflow (ofs: %u, len:%d, size:%zu)\n",
+                      __func__, s->tx_frame_len, len1, sizeof(s->tx_frame));
         return -1;
     }
     if (len1) {
@@ -593,6 +606,9 @@  static int tulip_copy_tx_buffers(TULIPState *s, struct tulip_descriptor *desc)
     }
 
     if (s->tx_frame_len + len2 > sizeof(s->tx_frame)) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "%s: descriptor overflow (ofs: %u, len:%d, size:%zu)\n",
+                      __func__, s->tx_frame_len, len2, sizeof(s->tx_frame));
         return -1;
     }
     if (len2) {