[RFC v5 6/7] vhost: Validate transport device features for packed vqs

Sahil Siddiq posted 7 patches 1 week ago
[RFC v5 6/7] vhost: Validate transport device features for packed vqs
Posted by Sahil Siddiq 1 week ago
Validate transport device features required for utilizing packed SVQ
that both guests can use with the SVQ and SVQs can use with vdpa.

Signed-off-by: Sahil Siddiq <sahilcdq@proton.me>
---
Changes from v4 -> v5:
- Split from commit #2 in v4.

 hw/virtio/vhost-shadow-virtqueue.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index 8430b3c94a..035ab1e66f 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -33,6 +33,9 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)
          ++b) {
         switch (b) {
         case VIRTIO_F_ANY_LAYOUT:
+        case VIRTIO_F_RING_PACKED:
+        case VIRTIO_F_RING_RESET:
+        case VIRTIO_RING_F_INDIRECT_DESC:
         case VIRTIO_RING_F_EVENT_IDX:
             continue;
 
-- 
2.48.1
Re: [RFC v5 6/7] vhost: Validate transport device features for packed vqs
Posted by Eugenio Perez Martin 5 days, 20 hours ago
On Mon, Mar 24, 2025 at 3:00 PM Sahil Siddiq <icegambit91@gmail.com> wrote:
>
> Validate transport device features required for utilizing packed SVQ
> that both guests can use with the SVQ and SVQs can use with vdpa.
>
> Signed-off-by: Sahil Siddiq <sahilcdq@proton.me>
> ---
> Changes from v4 -> v5:
> - Split from commit #2 in v4.
>
>  hw/virtio/vhost-shadow-virtqueue.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
> index 8430b3c94a..035ab1e66f 100644
> --- a/hw/virtio/vhost-shadow-virtqueue.c
> +++ b/hw/virtio/vhost-shadow-virtqueue.c
> @@ -33,6 +33,9 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)
>           ++b) {
>          switch (b) {
>          case VIRTIO_F_ANY_LAYOUT:
> +        case VIRTIO_F_RING_PACKED:
> +        case VIRTIO_F_RING_RESET:
> +        case VIRTIO_RING_F_INDIRECT_DESC:

This should only enable _F_RING_PACKED, there is no code supporting
either reset or indirect descriptors.

>          case VIRTIO_RING_F_EVENT_IDX:
>              continue;
>
> --
> 2.48.1
>
Re: [RFC v5 6/7] vhost: Validate transport device features for packed vqs
Posted by Sahil Siddiq 4 days, 2 hours ago
Hi,

On 3/26/25 5:36 PM, Eugenio Perez Martin wrote:
> On Mon, Mar 24, 2025 at 3:00 PM Sahil Siddiq <icegambit91@gmail.com> wrote:
>>
>> Validate transport device features required for utilizing packed SVQ
>> that both guests can use with the SVQ and SVQs can use with vdpa.
>>
>> Signed-off-by: Sahil Siddiq <sahilcdq@proton.me>
>> ---
>> Changes from v4 -> v5:
>> - Split from commit #2 in v4.
>>
>>   hw/virtio/vhost-shadow-virtqueue.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
>> index 8430b3c94a..035ab1e66f 100644
>> --- a/hw/virtio/vhost-shadow-virtqueue.c
>> +++ b/hw/virtio/vhost-shadow-virtqueue.c
>> @@ -33,6 +33,9 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)
>>            ++b) {
>>           switch (b) {
>>           case VIRTIO_F_ANY_LAYOUT:
>> +        case VIRTIO_F_RING_PACKED:
>> +        case VIRTIO_F_RING_RESET:
>> +        case VIRTIO_RING_F_INDIRECT_DESC:
> 
> This should only enable _F_RING_PACKED, there is no code supporting
> either reset or indirect descriptors.
> 

Without _F_RING_RESET and _RING_F_INDIRECT_DESC, I get the following error:

qemu-system-x86_64: -netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-0,x-svq=true,id=vhost-vdpa0: SVQ Invalid device feature flags, offer: 0x1071011ffa7, ok: 0x70011ffa7

Evaluating 0x1071011ffa7 & ~0x70011ffa7 gives me 0x10010000000 as the
set of invalid features. This corresponds to _F_RING_RESET (1 << 40)
and _RING_F_INDIRECT_DESC (1 << 28) [1].

I get this error when x-svq=true irrespective of whether split vqs or packed
vqs are used.

Is there a way to turn them off in the QEMU command?

Thanks,
Sahil

[1] https://gitlab.com/qemu-project/qemu/-/blob/master/include/standard-headers/linux/virtio_config.h

Re: [RFC v5 6/7] vhost: Validate transport device features for packed vqs
Posted by Eugenio Perez Martin 4 days ago
On Fri, Mar 28, 2025 at 6:34 AM Sahil Siddiq <icegambit91@gmail.com> wrote:
>
> Hi,
>
> On 3/26/25 5:36 PM, Eugenio Perez Martin wrote:
> > On Mon, Mar 24, 2025 at 3:00 PM Sahil Siddiq <icegambit91@gmail.com> wrote:
> >>
> >> Validate transport device features required for utilizing packed SVQ
> >> that both guests can use with the SVQ and SVQs can use with vdpa.
> >>
> >> Signed-off-by: Sahil Siddiq <sahilcdq@proton.me>
> >> ---
> >> Changes from v4 -> v5:
> >> - Split from commit #2 in v4.
> >>
> >>   hw/virtio/vhost-shadow-virtqueue.c | 3 +++
> >>   1 file changed, 3 insertions(+)
> >>
> >> diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
> >> index 8430b3c94a..035ab1e66f 100644
> >> --- a/hw/virtio/vhost-shadow-virtqueue.c
> >> +++ b/hw/virtio/vhost-shadow-virtqueue.c
> >> @@ -33,6 +33,9 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)
> >>            ++b) {
> >>           switch (b) {
> >>           case VIRTIO_F_ANY_LAYOUT:
> >> +        case VIRTIO_F_RING_PACKED:
> >> +        case VIRTIO_F_RING_RESET:
> >> +        case VIRTIO_RING_F_INDIRECT_DESC:
> >
> > This should only enable _F_RING_PACKED, there is no code supporting
> > either reset or indirect descriptors.
> >
>
> Without _F_RING_RESET and _RING_F_INDIRECT_DESC, I get the following error:
>
> qemu-system-x86_64: -netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-0,x-svq=true,id=vhost-vdpa0: SVQ Invalid device feature flags, offer: 0x1071011ffa7, ok: 0x70011ffa7
>
> Evaluating 0x1071011ffa7 & ~0x70011ffa7 gives me 0x10010000000 as the
> set of invalid features. This corresponds to _F_RING_RESET (1 << 40)
> and _RING_F_INDIRECT_DESC (1 << 28) [1].
>
> I get this error when x-svq=true irrespective of whether split vqs or packed
> vqs are used.
>
> Is there a way to turn them off in the QEMU command?
>

In the case of nested virtualization you should be able to disable it by:

-device virtio-net-pci,indirect_desc=off,queue_reset=off,...

In L0 QEMU cmdline.

> Thanks,
> Sahil
>
> [1] https://gitlab.com/qemu-project/qemu/-/blob/master/include/standard-headers/linux/virtio_config.h
>