* [PULL V2 0/3] Net patches @ 2020-07-28 9:10 Jason Wang 2020-07-28 9:10 ` [PULL V2 1/3] virtio-pci: fix wrong index in virtio_pci_queue_enabled Jason Wang ` (3 more replies) 0 siblings, 4 replies; 11+ messages in thread From: Jason Wang @ 2020-07-28 9:10 UTC (permalink / raw) To: peter.maydell; +Cc: Jason Wang, qemu-devel The following changes since commit 93ea484375ab473379dd9c836261ef484bd71ab1: Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-07-27 21:00:01 +0100) are available in the git repository at: https://github.com/jasowang/qemu.git tags/net-pull-request for you to fetch changes up to 22dc8663d9fc7baa22100544c600b6285a63c7a3: net: forbid the reentrant RX (2020-07-28 16:57:58 +0800) ---------------------------------------------------------------- Want to send earlier but most patches just come. - fix vhost-vdpa issues when no peer - fix virtio-pci queue enabling index value - forbid reentrant RX Changes from V1: - drop the patch that has been merged ---------------------------------------------------------------- Jason Wang (2): virtio-net: check the existence of peer before accessing vDPA config net: forbid the reentrant RX Yuri Benditovich (1): virtio-pci: fix wrong index in virtio_pci_queue_enabled hw/net/virtio-net.c | 30 +++++++++++++++++++----------- hw/virtio/virtio-pci.c | 2 +- net/queue.c | 3 +++ 3 files changed, 23 insertions(+), 12 deletions(-) ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PULL V2 1/3] virtio-pci: fix wrong index in virtio_pci_queue_enabled 2020-07-28 9:10 [PULL V2 0/3] Net patches Jason Wang @ 2020-07-28 9:10 ` Jason Wang 2020-07-28 9:10 ` [PULL V2 2/3] virtio-net: check the existence of peer before accessing vDPA config Jason Wang ` (2 subsequent siblings) 3 siblings, 0 replies; 11+ messages in thread From: Jason Wang @ 2020-07-28 9:10 UTC (permalink / raw) To: peter.maydell; +Cc: Yuri Benditovich, Jason Wang, qemu-devel From: Yuri Benditovich <yuri.benditovich@daynix.com> We should use the index passed by the caller instead of the queue_sel when checking the enablement of a specific virtqueue. This is reported in https://bugzilla.redhat.com/show_bug.cgi?id=1702608 Fixes: f19bcdfedd53 ("virtio-pci: implement queue_enabled method") Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com> Signed-off-by: Jason Wang <jasowang@redhat.com> --- hw/virtio/virtio-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4ad3ad8..ccdf54e 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1113,7 +1113,7 @@ static bool virtio_pci_queue_enabled(DeviceState *d, int n) VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { - return proxy->vqs[vdev->queue_sel].enabled; + return proxy->vqs[n].enabled; } return virtio_queue_enabled_legacy(vdev, n); -- 2.7.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL V2 2/3] virtio-net: check the existence of peer before accessing vDPA config 2020-07-28 9:10 [PULL V2 0/3] Net patches Jason Wang 2020-07-28 9:10 ` [PULL V2 1/3] virtio-pci: fix wrong index in virtio_pci_queue_enabled Jason Wang @ 2020-07-28 9:10 ` Jason Wang 2020-07-28 9:10 ` [PULL V2 3/3] net: forbid the reentrant RX Jason Wang 2020-07-28 16:14 ` [PULL V2 0/3] Net patches Peter Maydell 3 siblings, 0 replies; 11+ messages in thread From: Jason Wang @ 2020-07-28 9:10 UTC (permalink / raw) To: peter.maydell; +Cc: Jason Wang, qemu-devel, Cindy Lu We try to check whether a peer is VDPA in order to get config from there - with no peer, this leads to a NULL pointer dereference. Add a check before trying to access the peer type. No peer means not VDPA. Fixes: 108a64818e69b ("vhost-vdpa: introduce vhost-vdpa backend") Cc: Cindy Lu <lulu@redhat.com> Tested-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> --- hw/net/virtio-net.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 4895af1..a1fe9e9 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -125,6 +125,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) { VirtIONet *n = VIRTIO_NET(vdev); struct virtio_net_config netcfg; + NetClientState *nc = qemu_get_queue(n->nic); int ret = 0; memset(&netcfg, 0 , sizeof(struct virtio_net_config)); @@ -142,13 +143,16 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) VIRTIO_NET_RSS_SUPPORTED_HASHES); memcpy(config, &netcfg, n->config_size); - NetClientState *nc = qemu_get_queue(n->nic); - if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { + /* + * Is this VDPA? No peer means not VDPA: there's no way to + * disconnect/reconnect a VDPA peer. + */ + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, - n->config_size); - if (ret != -1) { - memcpy(config, &netcfg, n->config_size); - } + n->config_size); + if (ret != -1) { + memcpy(config, &netcfg, n->config_size); + } } } @@ -156,6 +160,7 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) { VirtIONet *n = VIRTIO_NET(vdev); struct virtio_net_config netcfg = {}; + NetClientState *nc = qemu_get_queue(n->nic); memcpy(&netcfg, config, n->config_size); @@ -166,11 +171,14 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); } - NetClientState *nc = qemu_get_queue(n->nic); - if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { - vhost_net_set_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, - 0, n->config_size, - VHOST_SET_CONFIG_TYPE_MASTER); + /* + * Is this VDPA? No peer means not VDPA: there's no way to + * disconnect/reconnect a VDPA peer. + */ + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { + vhost_net_set_config(get_vhost_net(nc->peer), + (uint8_t *)&netcfg, 0, n->config_size, + VHOST_SET_CONFIG_TYPE_MASTER); } } -- 2.7.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL V2 3/3] net: forbid the reentrant RX 2020-07-28 9:10 [PULL V2 0/3] Net patches Jason Wang 2020-07-28 9:10 ` [PULL V2 1/3] virtio-pci: fix wrong index in virtio_pci_queue_enabled Jason Wang 2020-07-28 9:10 ` [PULL V2 2/3] virtio-net: check the existence of peer before accessing vDPA config Jason Wang @ 2020-07-28 9:10 ` Jason Wang 2020-07-28 16:14 ` [PULL V2 0/3] Net patches Peter Maydell 3 siblings, 0 replies; 11+ messages in thread From: Jason Wang @ 2020-07-28 9:10 UTC (permalink / raw) To: peter.maydell; +Cc: Jason Wang, qemu-devel The memory API allows DMA into NIC's MMIO area. This means the NIC's RX routine must be reentrant. Instead of auditing all the NIC, we can simply detect the reentrancy and return early. The queue->delivering is set and cleared by qemu_net_queue_deliver() for other queue helpers to know whether the delivering in on going (NIC's receive is being called). We can check it and return early in qemu_net_queue_flush() to forbid reentrant RX. Signed-off-by: Jason Wang <jasowang@redhat.com> --- net/queue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/queue.c b/net/queue.c index 0164727..19e32c8 100644 --- a/net/queue.c +++ b/net/queue.c @@ -250,6 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState *from) bool qemu_net_queue_flush(NetQueue *queue) { + if (queue->delivering) + return false; + while (!QTAILQ_EMPTY(&queue->packets)) { NetPacket *packet; int ret; -- 2.7.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PULL V2 0/3] Net patches 2020-07-28 9:10 [PULL V2 0/3] Net patches Jason Wang ` (2 preceding siblings ...) 2020-07-28 9:10 ` [PULL V2 3/3] net: forbid the reentrant RX Jason Wang @ 2020-07-28 16:14 ` Peter Maydell 3 siblings, 0 replies; 11+ messages in thread From: Peter Maydell @ 2020-07-28 16:14 UTC (permalink / raw) To: Jason Wang; +Cc: QEMU Developers On Tue, 28 Jul 2020 at 10:10, Jason Wang <jasowang@redhat.com> wrote: > > The following changes since commit 93ea484375ab473379dd9c836261ef484bd71ab1: > > Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-07-27 21:00:01 +0100) > > are available in the git repository at: > > https://github.com/jasowang/qemu.git tags/net-pull-request > > for you to fetch changes up to 22dc8663d9fc7baa22100544c600b6285a63c7a3: > > net: forbid the reentrant RX (2020-07-28 16:57:58 +0800) > > ---------------------------------------------------------------- > Want to send earlier but most patches just come. > > - fix vhost-vdpa issues when no peer > - fix virtio-pci queue enabling index value > - forbid reentrant RX > > Changes from V1: > > - drop the patch that has been merged > > ---------------------------------------------------------------- > Jason Wang (2): > virtio-net: check the existence of peer before accessing vDPA config > net: forbid the reentrant RX > > Yuri Benditovich (1): > virtio-pci: fix wrong index in virtio_pci_queue_enabled Applied, thanks. Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1 for any user-visible changes. -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PULL V2 0/3] Net patches @ 2021-05-27 4:24 Jason Wang 2021-05-27 6:13 ` Bin Meng 2021-05-30 17:33 ` Peter Maydell 0 siblings, 2 replies; 11+ messages in thread From: Jason Wang @ 2021-05-27 4:24 UTC (permalink / raw) To: peter.maydell; +Cc: Jason Wang, qemu-devel The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672: Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100) are available in the git repository at: https://github.com/jasowang/qemu.git tags/net-pull-request for you to fetch changes up to 4f8a39494aded9f2026a26b137378ea2ee3d5338: tap-bsd: Remove special casing for older OpenBSD releases (2021-05-27 11:03:55 +0800) ---------------------------------------------------------------- ---------------------------------------------------------------- Brad Smith (1): tap-bsd: Remove special casing for older OpenBSD releases Guenter Roeck (1): hw/net/imx_fec: return 0xffff when accessing non-existing PHY Laurent Vivier (1): virtio-net: failover: add missing remove_migration_state_change_notifier() hw/net/imx_fec.c | 8 +++----- hw/net/trace-events | 2 ++ hw/net/virtio-net.c | 1 + net/tap-bsd.c | 8 -------- 4 files changed, 6 insertions(+), 13 deletions(-) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL V2 0/3] Net patches 2021-05-27 4:24 Jason Wang @ 2021-05-27 6:13 ` Bin Meng 2021-05-27 6:35 ` Jason Wang 2021-05-30 17:33 ` Peter Maydell 1 sibling, 1 reply; 11+ messages in thread From: Bin Meng @ 2021-05-27 6:13 UTC (permalink / raw) To: Jason Wang; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers Hi Jason, On Thu, May 27, 2021 at 12:24 PM Jason Wang <jasowang@redhat.com> wrote: > > The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672: > > Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100) > > are available in the git repository at: > > https://github.com/jasowang/qemu.git tags/net-pull-request > > for you to fetch changes up to 4f8a39494aded9f2026a26b137378ea2ee3d5338: > > tap-bsd: Remove special casing for older OpenBSD releases (2021-05-27 11:03:55 +0800) > > ---------------------------------------------------------------- > > ---------------------------------------------------------------- > Brad Smith (1): > tap-bsd: Remove special casing for older OpenBSD releases > > Guenter Roeck (1): > hw/net/imx_fec: return 0xffff when accessing non-existing PHY > > Laurent Vivier (1): > virtio-net: failover: add missing remove_migration_state_change_notifier() > > hw/net/imx_fec.c | 8 +++----- > hw/net/trace-events | 2 ++ > hw/net/virtio-net.c | 1 + > net/tap-bsd.c | 8 -------- > 4 files changed, 6 insertions(+), 13 deletions(-) What happened to patch 5-12 in the following series? http://patchwork.ozlabs.org/project/qemu-devel/cover/20210317062638.72626-1-bmeng.cn@gmail.com/ Regards, Bin ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL V2 0/3] Net patches 2021-05-27 6:13 ` Bin Meng @ 2021-05-27 6:35 ` Jason Wang 2021-05-27 7:14 ` Bin Meng 0 siblings, 1 reply; 11+ messages in thread From: Jason Wang @ 2021-05-27 6:35 UTC (permalink / raw) To: Bin Meng; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers 在 2021/5/27 下午2:13, Bin Meng 写道: > Hi Jason, > > On Thu, May 27, 2021 at 12:24 PM Jason Wang <jasowang@redhat.com> wrote: >> The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672: >> >> Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100) >> >> are available in the git repository at: >> >> https://github.com/jasowang/qemu.git tags/net-pull-request >> >> for you to fetch changes up to 4f8a39494aded9f2026a26b137378ea2ee3d5338: >> >> tap-bsd: Remove special casing for older OpenBSD releases (2021-05-27 11:03:55 +0800) >> >> ---------------------------------------------------------------- >> >> ---------------------------------------------------------------- >> Brad Smith (1): >> tap-bsd: Remove special casing for older OpenBSD releases >> >> Guenter Roeck (1): >> hw/net/imx_fec: return 0xffff when accessing non-existing PHY >> >> Laurent Vivier (1): >> virtio-net: failover: add missing remove_migration_state_change_notifier() >> >> hw/net/imx_fec.c | 8 +++----- >> hw/net/trace-events | 2 ++ >> hw/net/virtio-net.c | 1 + >> net/tap-bsd.c | 8 -------- >> 4 files changed, 6 insertions(+), 13 deletions(-) > What happened to patch 5-12 in the following series? > http://patchwork.ozlabs.org/project/qemu-devel/cover/20210317062638.72626-1-bmeng.cn@gmail.com/ I want to do some test before the merging. Or if possible, could you please write a test for this function? Thanks > > Regards, > Bin > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL V2 0/3] Net patches 2021-05-27 6:35 ` Jason Wang @ 2021-05-27 7:14 ` Bin Meng 2021-05-27 7:23 ` Jason Wang 0 siblings, 1 reply; 11+ messages in thread From: Bin Meng @ 2021-05-27 7:14 UTC (permalink / raw) To: Jason Wang; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers On Thu, May 27, 2021 at 2:35 PM Jason Wang <jasowang@redhat.com> wrote: > > > 在 2021/5/27 下午2:13, Bin Meng 写道: > > Hi Jason, > > > > On Thu, May 27, 2021 at 12:24 PM Jason Wang <jasowang@redhat.com> wrote: > >> The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672: > >> > >> Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100) > >> > >> are available in the git repository at: > >> > >> https://github.com/jasowang/qemu.git tags/net-pull-request > >> > >> for you to fetch changes up to 4f8a39494aded9f2026a26b137378ea2ee3d5338: > >> > >> tap-bsd: Remove special casing for older OpenBSD releases (2021-05-27 11:03:55 +0800) > >> > >> ---------------------------------------------------------------- > >> > >> ---------------------------------------------------------------- > >> Brad Smith (1): > >> tap-bsd: Remove special casing for older OpenBSD releases > >> > >> Guenter Roeck (1): > >> hw/net/imx_fec: return 0xffff when accessing non-existing PHY > >> > >> Laurent Vivier (1): > >> virtio-net: failover: add missing remove_migration_state_change_notifier() > >> > >> hw/net/imx_fec.c | 8 +++----- > >> hw/net/trace-events | 2 ++ > >> hw/net/virtio-net.c | 1 + > >> net/tap-bsd.c | 8 -------- > >> 4 files changed, 6 insertions(+), 13 deletions(-) > > What happened to patch 5-12 in the following series? > > http://patchwork.ozlabs.org/project/qemu-devel/cover/20210317062638.72626-1-bmeng.cn@gmail.com/ > > > I want to do some test before the merging. Or if possible, could you > please write a test for this function? > For each of these network adapter models? What kind of tests are needed? Any pointers? Regards, Bin ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL V2 0/3] Net patches 2021-05-27 7:14 ` Bin Meng @ 2021-05-27 7:23 ` Jason Wang 0 siblings, 0 replies; 11+ messages in thread From: Jason Wang @ 2021-05-27 7:23 UTC (permalink / raw) To: Bin Meng; +Cc: Peter Maydell, qemu-devel@nongnu.org Developers 在 2021/5/27 下午3:14, Bin Meng 写道: > On Thu, May 27, 2021 at 2:35 PM Jason Wang <jasowang@redhat.com> wrote: >> >> 在 2021/5/27 下午2:13, Bin Meng 写道: >>> Hi Jason, >>> >>> On Thu, May 27, 2021 at 12:24 PM Jason Wang <jasowang@redhat.com> wrote: >>>> The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672: >>>> >>>> Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100) >>>> >>>> are available in the git repository at: >>>> >>>> https://github.com/jasowang/qemu.git tags/net-pull-request >>>> >>>> for you to fetch changes up to 4f8a39494aded9f2026a26b137378ea2ee3d5338: >>>> >>>> tap-bsd: Remove special casing for older OpenBSD releases (2021-05-27 11:03:55 +0800) >>>> >>>> ---------------------------------------------------------------- >>>> >>>> ---------------------------------------------------------------- >>>> Brad Smith (1): >>>> tap-bsd: Remove special casing for older OpenBSD releases >>>> >>>> Guenter Roeck (1): >>>> hw/net/imx_fec: return 0xffff when accessing non-existing PHY >>>> >>>> Laurent Vivier (1): >>>> virtio-net: failover: add missing remove_migration_state_change_notifier() >>>> >>>> hw/net/imx_fec.c | 8 +++----- >>>> hw/net/trace-events | 2 ++ >>>> hw/net/virtio-net.c | 1 + >>>> net/tap-bsd.c | 8 -------- >>>> 4 files changed, 6 insertions(+), 13 deletions(-) >>> What happened to patch 5-12 in the following series? >>> http://patchwork.ozlabs.org/project/qemu-devel/cover/20210317062638.72626-1-bmeng.cn@gmail.com/ >> >> I want to do some test before the merging. Or if possible, could you >> please write a test for this function? >> > For each of these network adapter models? e1000 and virtio-net should be sufficient. > What kind of tests are > needed? Test whether padding works. > Any pointers? You can start to look at virtio-net-test.c. Thanks > > Regards, > Bin > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL V2 0/3] Net patches 2021-05-27 4:24 Jason Wang 2021-05-27 6:13 ` Bin Meng @ 2021-05-30 17:33 ` Peter Maydell 1 sibling, 0 replies; 11+ messages in thread From: Peter Maydell @ 2021-05-30 17:33 UTC (permalink / raw) To: Jason Wang; +Cc: QEMU Developers On Thu, 27 May 2021 at 05:24, Jason Wang <jasowang@redhat.com> wrote: > > The following changes since commit d90f154867ec0ec22fd719164b88716e8fd48672: > > Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210504' into staging (2021-05-05 20:29:14 +0100) > > are available in the git repository at: > > https://github.com/jasowang/qemu.git tags/net-pull-request > > for you to fetch changes up to 4f8a39494aded9f2026a26b137378ea2ee3d5338: > > tap-bsd: Remove special casing for older OpenBSD releases (2021-05-27 11:03:55 +0800) > > ---------------------------------------------------------------- > > ---------------------------------------------------------------- Applied, thanks. Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1 for any user-visible changes. -- PMM ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-05-30 17:35 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-07-28 9:10 [PULL V2 0/3] Net patches Jason Wang 2020-07-28 9:10 ` [PULL V2 1/3] virtio-pci: fix wrong index in virtio_pci_queue_enabled Jason Wang 2020-07-28 9:10 ` [PULL V2 2/3] virtio-net: check the existence of peer before accessing vDPA config Jason Wang 2020-07-28 9:10 ` [PULL V2 3/3] net: forbid the reentrant RX Jason Wang 2020-07-28 16:14 ` [PULL V2 0/3] Net patches Peter Maydell -- strict thread matches above, loose matches on Subject: below -- 2021-05-27 4:24 Jason Wang 2021-05-27 6:13 ` Bin Meng 2021-05-27 6:35 ` Jason Wang 2021-05-27 7:14 ` Bin Meng 2021-05-27 7:23 ` Jason Wang 2021-05-30 17:33 ` Peter Maydell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).