All of lore.kernel.org
 help / color / mirror / Atom feed
* virtio: why no full reset on virtio_set_status 0 ?
@ 2022-07-27 10:51 Claudio Fontana
  2022-07-27 15:32 ` Michael S. Tsirkin
  2022-07-27 16:17 ` Michael S. Tsirkin
  0 siblings, 2 replies; 18+ messages in thread
From: Claudio Fontana @ 2022-07-27 10:51 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel, Alex Bennée

Hi Michael and all,

I have started researching a qemu / ovs / dpdk bug:

https://inbox.dpdk.org/dev/322122fb-619d-96f6-5c3e-9eabdbf3819a@redhat.com/T/

that seems to be affecting multiple parties in the telco space,

and during this process I noticed that qemu/hw/virtio/virtio.c does not do a full virtio reset
in virtio_set_status, when receiving a status value of 0.

It seems it has always been this way, so I am clearly missing / forgetting something basic,

I checked the virtio spec at https://docs.oasis-open.org/

and from:

"
4.1.4.3 Common configuration structure layout

device_status
The driver writes the device status here (see 2.1). Writing 0 into this field resets the device.

"

and

"
2.4.1 Device Requirements: Device Reset
A device MUST reinitialize device status to 0 after receiving a reset.
"

I would conclude that in virtio.c::virtio_set_status we should unconditionally do a full virtio_reset.

Instead, we have just the check:

    if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) !=
        (val & VIRTIO_CONFIG_S_DRIVER_OK)) {
        virtio_set_started(vdev, val & VIRTIO_CONFIG_S_DRIVER_OK);
    }

which just sets the started field,

and then we have the call to the virtio device class set_status (virtio_net...),
but the VirtioDevice is not fully reset, as per the virtio_reset() call we are missing:

"
    vdev->start_on_kick = false;
    vdev->started = false;
    vdev->broken = false;
    vdev->guest_features = 0;
    vdev->queue_sel = 0;
    vdev->status = 0;
    vdev->disabled = false;
    qatomic_set(&vdev->isr, 0);
    vdev->config_vector = VIRTIO_NO_VECTOR;
    virtio_notify_vector(vdev, vdev->config_vector);

    for(i = 0; i < VIRTIO_QUEUE_MAX; i++) {
        ... initialize vdev->vq[i] ...
    }
"

Doing a full reset seems to fix the problem for me, so I can send tentative patches if necessary,
but what am I missing here?

Thanks,

Claudio

-- 
Claudio Fontana
Engineering Manager Virtualization, SUSE Labs Core

SUSE Software Solutions Italy Srl


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-08-01  8:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 10:51 virtio: why no full reset on virtio_set_status 0 ? Claudio Fontana
2022-07-27 15:32 ` Michael S. Tsirkin
2022-07-28  1:27   ` Jason Wang
2022-07-28  7:16     ` Claudio Fontana
2022-07-28  7:43     ` Claudio Fontana
2022-07-28  9:09       ` Claudio Fontana
2022-07-28 10:24         ` Cornelia Huck
2022-07-31 20:38           ` Claudio Fontana
2022-07-28 13:39         ` Michael S. Tsirkin
2022-07-29  9:46           ` Claudio Fontana
2022-07-29 10:13             ` Michael S. Tsirkin
2022-07-29 10:19               ` Claudio Fontana
2022-07-29 13:21                 ` Alex Bennée
2022-07-29 14:00                   ` Claudio Fontana
2022-07-31 20:42                     ` Claudio Fontana
2022-08-01  8:44                       ` Alex Bennée
2022-07-28 11:41       ` Michael S. Tsirkin
2022-07-27 16:17 ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.