Skip to contentSkip to conversation

pc-bios/s390-ccw: Re-initialize receive queue index before each boot attempt

PATCH In review Thomas Huth 2 participants 2 messages Nov 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pc-bios/s390-ccw: Re-initialize receive queue index before each boot attempt

Now that we can boot from multiple boot devices, we have to make sure to reinitialize static variables like rx_last_idx to avoid that they contain garbage data during the second boot attempt (which can lead to crashes when the code tries to access the wrong ring data).

---
 pc-bios/s390-ccw/virtio-net.c | 2 ++
 1 file changed, 2 insertions(+)
pc-bios/s390-ccw/virtio-net.c +2 -0
index f9854a22c3..578c89d0c5 100644
@@ -51,6 +51,8 @@ int virtio_net_init(void *mac_addr)
     void *buf;
     int i;
 
+    rx_last_idx = 0;
+
     vdev->guest_features[0] = VIRTIO_NET_F_MAC_BIT;
     virtio_setup_ccw(vdev);
 
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Thomas Huth

Now that we can boot from multiple boot devices, we have to make sure to reinitialize static variables like rx_last_idx to avoid that they contain garbage data during the second boot attempt (which can lead to crashes when the code tries to access the wrong ring data).

---
  pc-bios/s390-ccw/virtio-net.c | 2 ++
  1 file changed, 2 insertions(+)
pc-bios/s390-ccw/virtio-net.c +0 -0
index f9854a22c3..578c89d0c5 100644

pc-bios/s390-ccw/virtio-net.c int virtio_net_init(void *mac_addr) · line 58

Quoted 8 lines
pc-bios/s390-ccw/virtio-net.c +2 -0
@@ -51,6 +51,8 @@ int virtio_net_init(void *mac_addr)
      void *buf;
      int i;
 
+    rx_last_idx = 0;
+
      vdev->guest_features[0] = VIRTIO_NET_F_MAC_BIT;
      virtio_setup_ccw(vdev);
 

Thanks Thomas!