Skip to contentSkip to conversation

virtio-net: Fix RSS

PATCH Superseded Akihiko Odaki 3 participants 5 messages Mar 26, 2024 – Apr 9, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover virtio-net: Fix RSS

Some recent changes made RSS unfunctional so here are fixes.

---
Akihiko Odaki (2):
virtio-net: Fix vhost virtqueue notifiers for RSS
ebpf: Fix indirections table setting

 ebpf/ebpf_rss.h     | 2 +-
 ebpf/ebpf_rss.c     | 5 +++--
 hw/net/virtio-net.c | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)

---
base-commit: ba49d760eb04630e7b15f423ebecf6c871b8f77b
change-id: 20240324-vhost-5e26c8a2da5a

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
#1 lore raw

PATCH 1/2 virtio-net: Fix vhost virtqueue notifiers for RSS

virtio_net_guest_notifier_pending() and virtio_net_guest_notifier_mask() checked VIRTIO_NET_F_MQ to know there are multiple queues, but VIRTIO_NET_F_RSS also enables multiple queues. Refer to n->multiqueue, which is set to true either of VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is enabled.

Fixes 68b0a6395f36 ("virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa")
---
 hw/net/virtio-net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/virtio-net.c +2 -2
index 9959f1932b1b..a6ff000cd9d3 100644
@@ -3426,7 +3426,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
     VirtIONet *n = VIRTIO_NET(vdev);
     NetClientState *nc;
     assert(n->vhost_started);
-    if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
+    if (!n->multiqueue && idx == 2) {
         /* Must guard against invalid features and bogus queue index
          * from being set by malicious guest, or penetrated through
          * buggy migration stream.
@@ -3458,7 +3458,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
     VirtIONet *n = VIRTIO_NET(vdev);
     NetClientState *nc;
     assert(n->vhost_started);
-    if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
+    if (!n->multiqueue && idx == 2) {
         /* Must guard against invalid features and bogus queue index
          * from being set by malicious guest, or penetrated through
          * buggy migration stream.
Signature · 1 line
2.44.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] virtio-net: Fix vhost virtqueue notifiers for RSS

Quoted 8 lines · Akihiko Odaki

virtio_net_guest_notifier_pending() and virtio_net_guest_notifier_mask() checked VIRTIO_NET_F_MQ to know there are multiple queues, but VIRTIO_NET_F_RSS also enables multiple queues. Refer to n->multiqueue, which is set to true either of VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is enabled.

Fixes 68b0a6395f36 ("virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa")

Jason, are you merging this?

Quoted 29 lines
---
 hw/net/virtio-net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/virtio-net.c +2 -2
index 9959f1932b1b..a6ff000cd9d3 100644
@@ -3426,7 +3426,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
     VirtIONet *n = VIRTIO_NET(vdev);
     NetClientState *nc;
     assert(n->vhost_started);
-    if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
+    if (!n->multiqueue && idx == 2) {
         /* Must guard against invalid features and bogus queue index
          * from being set by malicious guest, or penetrated through
          * buggy migration stream.
@@ -3458,7 +3458,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
     VirtIONet *n = VIRTIO_NET(vdev);
     NetClientState *nc;
     assert(n->vhost_started);
-    if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_MQ) && idx == 2) {
+    if (!n->multiqueue && idx == 2) {
         /* Must guard against invalid features and bogus queue index
          * from being set by malicious guest, or penetrated through
          * buggy migration stream.
Signature · 2 lines
-- 
2.44.0
#3 lore raw

Re: [PATCH 1/2] virtio-net: Fix vhost virtqueue notifiers for RSS

Quoted 8 lines · Michael S. Tsirkin
Quoted 6 lines · Akihiko Odaki

virtio_net_guest_notifier_pending() and virtio_net_guest_notifier_mask() checked VIRTIO_NET_F_MQ to know there are multiple queues, but VIRTIO_NET_F_RSS also enables multiple queues. Refer to n->multiqueue, which is set to true either of VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is enabled.

Quoted 6 lines
Quoted 2 lines
Fixes 68b0a6395f36 ("virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa")

Jason, are you merging this?

It has been merged:

https://gitlab.com/qemu-project/qemu/-/commit/ba6bb2ec953f10751f174b6f7da8fe7e5f008c08

Thanks

#4 lore raw

PATCH 2/2 ebpf: Fix indirections table setting

In reply to Akihiko Odaki

The kernel documentation says:

Quoted 2 lines

The value stored can be of any size, however, all array elements are aligned to 8 bytes.

https://www.kernel.org/doc/html/v6.8/bpf/map_array.html

Fixes 333b3e5fab75 ("ebpf: Added eBPF map update through mmap.")
---
 ebpf/ebpf_rss.h | 2 +-
 ebpf/ebpf_rss.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
ebpf/ebpf_rss.h +1 -1
index 239242b0d26e..7d15b600bf5b 100644
@@ -26,7 +26,7 @@ struct EBPFRSSContext {
     /* mapped eBPF maps for direct access to omit bpf_map_update_elem() */
     void *mmap_configuration;
     void *mmap_toeplitz_key;
-    void *mmap_indirections_table;
+    uint64_t *mmap_indirections_table;
 };
 
 struct EBPFRSSConfig {
ebpf/ebpf_rss.c +3 -2
index 2e506f974357..e0f300febb77 100644
@@ -190,8 +190,9 @@ static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx,
         return false;
     }
 
-    memcpy(ctx->mmap_indirections_table, indirections_table,
-            sizeof(*indirections_table) * len);
+    for (size_t i = 0; i < len; i++) {
+        ctx->mmap_indirections_table[i] = indirections_table[i];
+    }
     return true;
 }
 
Signature · 1 line
2.44.0