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

Thomas Huth posted 1 patch 1 week, 5 days ago
pc-bios/s390-ccw/virtio-net.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] pc-bios/s390-ccw: Re-initialize receive queue index before each boot attempt
Posted by Thomas Huth 1 week, 5 days ago
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).

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/virtio-net.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pc-bios/s390-ccw/virtio-net.c b/pc-bios/s390-ccw/virtio-net.c
index f9854a22c3..578c89d0c5 100644
--- a/pc-bios/s390-ccw/virtio-net.c
+++ b/pc-bios/s390-ccw/virtio-net.c
@@ -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);
 
-- 
2.47.0
Re: [PATCH] pc-bios/s390-ccw: Re-initialize receive queue index before each boot attempt
Posted by Jared Rossi 1 week, 5 days ago

On 11/11/24 8:11 AM, Thomas Huth wrote:
> 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).
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   pc-bios/s390-ccw/virtio-net.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/pc-bios/s390-ccw/virtio-net.c b/pc-bios/s390-ccw/virtio-net.c
> index f9854a22c3..578c89d0c5 100644
> --- a/pc-bios/s390-ccw/virtio-net.c
> +++ b/pc-bios/s390-ccw/virtio-net.c
> @@ -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!

Reviewed-by: Jared Rossi <jrossi@linux.ibm.com>