virtio-pci: fix queue_enable write
PATCH 1/1 virtio-pci: fix queue_enable write
Spec said: The driver uses this to selectively prevent the device from executing requests from this virtqueue. 1 - enabled; 0 - disabled.
Though write 0 to queue_enable is forbidden by the sepc, we should not assume that the value is 1.
Fix this by ignoring the write value other than 1.
--- hw/virtio/virtio-pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
hw/virtio/virtio-pci.c +6 -4
@@ -1273,16 +1273,18 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,virtio_queue_set_vector (vdev, vdev->queue_sel, val);break ;case VIRTIO_PCI_COMMON_Q_ENABLE : -virtio_queue_set_num (vdev, vdev->queue_sel, - proxy->vqs[vdev->queue_sel].num); -virtio_queue_set_rings (vdev, vdev->queue_sel, +if (val ==1 ) { +virtio_queue_set_num (vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); +virtio_queue_set_rings (vdev, vdev->queue_sel, ((uint64_t )proxy->vqs[vdev->queue_sel].desc[1 ]) <<32 | proxy->vqs[vdev->queue_sel].desc[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].avail[1 ]) <<32 | proxy->vqs[vdev->queue_sel].avail[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].used[1 ]) <<32 | proxy->vqs[vdev->queue_sel].used[0 ]); - proxy->vqs[vdev->queue_sel].enabled =1 ; + proxy->vqs[vdev->queue_sel].enabled =1 ; + }break ;case VIRTIO_PCI_COMMON_Q_DESCLO : proxy->vqs[vdev->queue_sel].desc[0 ] = val;
Signature · 1 line
2.20.1
Quoted 6 lines · Jason Wang
Spec said: The driver uses this to selectively prevent the device from executing requests from this virtqueue. 1 - enabled; 0 - disabled.
Though write 0 to
queue_enableis forbidden by the sepc, we should not assume that the value is 1.
Quoted 8 lines
Fix this by ignoring the write value other than 1.
Cc Michael S. Tsirkin <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Jason Wang <[email protected]>--- hw/virtio/virtio-pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Quoted 4 lines · Jason Wang
Spec said: The driver uses this to selectively prevent the device from executing requests from this virtqueue. 1 - enabled; 0 - disabled.
Though write 0 to
queue_enableis forbidden by the sepc, we should not
spec?
Quoted 7 lines
assume that the value is 1.
Fix this by ignoring the write value other than 1.
Cc Michael S. Tsirkin <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Jason Wang <[email protected]>
Do we want to call virtio_error here so we can figure out something's wrong?
Quoted 33 lines
--- hw/virtio/virtio-pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)hw/virtio/virtio-pci.c +6
-4@@ -1273,16 +1273,18 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,virtio_queue_set_vector (vdev, vdev->queue_sel, val);break ;case VIRTIO_PCI_COMMON_Q_ENABLE : -virtio_queue_set_num (vdev, vdev->queue_sel, - proxy->vqs[vdev->queue_sel].num); -virtio_queue_set_rings (vdev, vdev->queue_sel, +if (val ==1 ) { +virtio_queue_set_num (vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); +virtio_queue_set_rings (vdev, vdev->queue_sel, ((uint64_t )proxy->vqs[vdev->queue_sel].desc[1 ]) <<32 | proxy->vqs[vdev->queue_sel].desc[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].avail[1 ]) <<32 | proxy->vqs[vdev->queue_sel].avail[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].used[1 ]) <<32 | proxy->vqs[vdev->queue_sel].used[0 ]); - proxy->vqs[vdev->queue_sel].enabled =1 ; + proxy->vqs[vdev->queue_sel].enabled =1 ; + }break ;case VIRTIO_PCI_COMMON_Q_DESCLO : proxy->vqs[vdev->queue_sel].desc[0 ] = val;Signature · 1 line
2.20.1
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Spec said: The driver uses this to selectively prevent the device from executing requests from this virtqueue. 1 - enabled; 0 - disabled.
Though write 0 to
queue_enableis forbidden by the sepc, we should notspec?
Chapter 4.1.4.3.2 said:
"
The driver MUST NOT write a 0 to queue_enable.
"
Quoted 10 lines
Quoted 8 lines
assume that the value is 1.
Fix this by ignoring the write value other than 1.
Cc Michael S. Tsirkin <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Jason Wang <[email protected]>Do we want to call
virtio_errorhere so we can figure out something's wrong?
That looks better. Will do.
Thanks
Quoted 37 lines
Quoted 36 lines
--- hw/virtio/virtio-pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)hw/virtio/virtio-pci.c +6
-4@@ -1273,16 +1273,18 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,virtio_queue_set_vector (vdev, vdev->queue_sel, val);break ;case VIRTIO_PCI_COMMON_Q_ENABLE : -virtio_queue_set_num (vdev, vdev->queue_sel, - proxy->vqs[vdev->queue_sel].num); -virtio_queue_set_rings (vdev, vdev->queue_sel, +if (val ==1 ) { +virtio_queue_set_num (vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); +virtio_queue_set_rings (vdev, vdev->queue_sel, ((uint64_t )proxy->vqs[vdev->queue_sel].desc[1 ]) <<32 | proxy->vqs[vdev->queue_sel].desc[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].avail[1 ]) <<32 | proxy->vqs[vdev->queue_sel].avail[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].used[1 ]) <<32 | proxy->vqs[vdev->queue_sel].used[0 ]); - proxy->vqs[vdev->queue_sel].enabled =1 ; + proxy->vqs[vdev->queue_sel].enabled =1 ; + }break ;case VIRTIO_PCI_COMMON_Q_DESCLO : proxy->vqs[vdev->queue_sel].desc[0 ] = val;Signature · 1 line
2.20.1
Quoted 10 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Spec said: The driver uses this to selectively prevent the device from executing requests from this virtqueue. 1 - enabled; 0 - disabled.
Though write 0 to
queue_enableis forbidden by the sepc, we should notspec?
Quoted 8 lines
Chapter 4.1.4.3.2 said:
"
The driver MUST NOT write a 0 to
queue_enable."
I mean you misspelled spec as sepc :)
Quoted 54 lines
Quoted 10 lines
Quoted 8 lines
assume that the value is 1.
Fix this by ignoring the write value other than 1.
Cc Michael S. Tsirkin <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Jason Wang <[email protected]>Do we want to call
virtio_errorhere so we can figure out something's wrong?That looks better. Will do.
Thanks
Quoted 37 lines
Quoted 36 lines
--- hw/virtio/virtio-pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)hw/virtio/virtio-pci.c +6
-4@@ -1273,16 +1273,18 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,virtio_queue_set_vector (vdev, vdev->queue_sel, val);break ;case VIRTIO_PCI_COMMON_Q_ENABLE : -virtio_queue_set_num (vdev, vdev->queue_sel, - proxy->vqs[vdev->queue_sel].num); -virtio_queue_set_rings (vdev, vdev->queue_sel, +if (val ==1 ) { +virtio_queue_set_num (vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); +virtio_queue_set_rings (vdev, vdev->queue_sel, ((uint64_t )proxy->vqs[vdev->queue_sel].desc[1 ]) <<32 | proxy->vqs[vdev->queue_sel].desc[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].avail[1 ]) <<32 | proxy->vqs[vdev->queue_sel].avail[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].used[1 ]) <<32 | proxy->vqs[vdev->queue_sel].used[0 ]); - proxy->vqs[vdev->queue_sel].enabled =1 ; + proxy->vqs[vdev->queue_sel].enabled =1 ; + }break ;case VIRTIO_PCI_COMMON_Q_DESCLO : proxy->vqs[vdev->queue_sel].desc[0 ] = val;Signature · 1 line
2.20.1
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Jason Wang
Spec said: The driver uses this to selectively prevent the device from executing requests from this virtqueue. 1 - enabled; 0 - disabled.
Though write 0 to
queue_enableis forbidden by the sepc, we should notspec?
Chapter 4.1.4.3.2 said:
Quoted 8 lines
Quoted 6 lines
"
The driver MUST NOT write a 0 to
queue_enable."
I mean you misspelled spec as sepc :)
Oh, right.
Will fix.
Thanks
Quoted 50 lines
Quoted 50 lines
Quoted 9 lines
Quoted 8 lines
assume that the value is 1.
Fix this by ignoring the write value other than 1.
Cc Michael S. Tsirkin <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Jason Wang <[email protected]>Do we want to call
virtio_errorhere so we can figure out something's wrong?That looks better. Will do.
Thanks
Quoted 35 lines
Quoted 35 lines
--- hw/virtio/virtio-pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)hw/virtio/virtio-pci.c +6
-4@@ -1273,16 +1273,18 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,virtio_queue_set_vector (vdev, vdev->queue_sel, val);break ;case VIRTIO_PCI_COMMON_Q_ENABLE : -virtio_queue_set_num (vdev, vdev->queue_sel, - proxy->vqs[vdev->queue_sel].num); -virtio_queue_set_rings (vdev, vdev->queue_sel, +if (val ==1 ) { +virtio_queue_set_num (vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); +virtio_queue_set_rings (vdev, vdev->queue_sel, ((uint64_t )proxy->vqs[vdev->queue_sel].desc[1 ]) <<32 | proxy->vqs[vdev->queue_sel].desc[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].avail[1 ]) <<32 | proxy->vqs[vdev->queue_sel].avail[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].used[1 ]) <<32 | proxy->vqs[vdev->queue_sel].used[0 ]); - proxy->vqs[vdev->queue_sel].enabled =1 ; + proxy->vqs[vdev->queue_sel].enabled =1 ; + }break ;case VIRTIO_PCI_COMMON_Q_DESCLO : proxy->vqs[vdev->queue_sel].desc[0 ] = val;Signature · 1 line
2.20.1